GithubHelp home page GithubHelp logo

signalanalysis's Introduction

signalanalysis

signalanalysis is a library including various tools for the reading, analysis and plotting of ECG and VCG data.

signalanalysis's People

Contributors

philip-gemmell avatar

Stargazers

Paul Smith avatar

Watchers

 avatar

Forkers

p-j-smith

signalanalysis's Issues

Performance of sa.signalanalysis.egm.Egm.get_rt

It is fast to calculate the activate time using sa.signalanalysis.egm.Egm.get_at, however calculating the repolarisation time withsa.signalanalysis.egm.Egm.get_rt is significantly slower.

Running this script:

import signalanalysis as sa
from signalanalysis.data import datafiles

egm = sa.signalanalysis.egm.Egm(
    data_location_uni=datafiles.EGM_UNIPOLAR,
    data_location_bi=datafiles.EGM_BIPOLAR,
    frequency=2034.5,
)
egm.get_at()
egm.get_rt()

produces the following output:

Finding AT...: 100%|██████████| 1188/1188 [00:01<00:00, 685.99it/s]
Finding RT...: 100%|██████████| 1188/1188 [00:52<00:00, 22.55it/s]

From profiling, it seems that most of the time is being spent on one or two lines (see the attached file). I'll submit a pr shortly where these lines are rewritten to improve performance.

profile-get_rt.txt

TypeError raised by sa.signalanalysis.egm.Egm.get_beats

To reproduce:

import signalanalysis as sa
from signalanalysis.data import datafiles

egm = sa.signalanalysis.egm.Egm(
    datafiles.EGM_UNIPOLAR,
    datafiles.EGM_BIPOLAR,
    frequency=2034.5,
)
egm.get_beats()

Output:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/var/folders/3x/026zvn0n35v9cg_b27xv40vm0000gn/T/ipykernel_79112/3975358815.py in <module>
----> 1 egm.get_beats()

~/github/signalanalysis/signalanalysis/signalanalysis/egm.py in get_beats(self, reset_index, offset_start, offset_end, plot, **kwargs)
    239             self.get_peaks(**kwargs)
    240 
--> 241         self.beat_start = pd.Series(dtype=pd.DataFrame, index=self.data_uni.columns)
    242         self.beats_uni = dict.fromkeys(self.data_uni.columns)
    243         self.beats_bi = dict.fromkeys(self.data_uni.columns)

/usr/local/Caskroom/miniconda/base/envs/signalanalysis/lib/python3.9/site-packages/pandas/core/series.py in __init__(self, data, index, dtype, name, copy, fastpath)
    371                 data = {}
    372             if dtype is not None:
--> 373                 dtype = self._validate_dtype(dtype)
    374 
    375             if isinstance(data, MultiIndex):

/usr/local/Caskroom/miniconda/base/envs/signalanalysis/lib/python3.9/site-packages/pandas/core/generic.py in _validate_dtype(cls, dtype)
    440         """validate the passed dtype"""
    441         if dtype is not None:
--> 442             dtype = pandas_dtype(dtype)
    443 
    444             # a compound dtype

/usr/local/Caskroom/miniconda/base/envs/signalanalysis/lib/python3.9/site-packages/pandas/core/dtypes/common.py in pandas_dtype(dtype)
   1789         return npdtype
   1790     elif npdtype.kind == "O":
-> 1791         raise TypeError(f"dtype '{dtype}' not understood")
   1792 
   1793     return npdtype

TypeError: dtype '<class 'pandas.core.frame.DataFrame'>' not understood

I've fixed this by making self.beat_start a list rather than pd.Series with dtype=pd.DataFrame, and will submit a PR shortly.

AssertionError raised by sa.signalanalysis.egm.Egm.get_beats

When #3 is fixed, the following error is raised by Egm.get_beats():

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
/var/folders/3x/026zvn0n35v9cg_b27xv40vm0000gn/T/ipykernel_79112/3502474742.py in <module>
      7     frequency=2034.5,
      8 )
----> 9 egm.get_beats()

~/github/signalanalysis/signalanalysis/signalanalysis/egm.py in get_beats(self, reset_index, offset_start, offset_end, plot, **kwargs)
    269             signal_beats_bi = list()
    270             for t_s, t_p, t_e in zip(self.beat_start[-1], self.t_peaks[key], beat_end):
--> 271                 assert t_s < t_p < t_e, "Error in windowing process"
    272                 signal_beats_uni.append(self.data_uni.loc[t_s:t_e, :])
    273                 signal_beats_bi.append(self.data_bi.loc[t_s:t_e, :])

AssertionError: Error in windowing process

I've fixed the stop times and will submit a PR shortly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.