neuropsychology / NeuroKit.py

A Python Toolbox for Statistics and Neurophysiological Signal Processing (EEG, EDA, ECG, EMG...).
http://neurokit.rtfd.io
MIT License
365 stars 102 forks source link

Computing HRV indices with missing data #111

Closed danibene closed 3 years ago

danibene commented 3 years ago

Hi!

I would like to compute HRV indices for heartbeat data, given peaks that I have already detected (so not e.g. raw ECG data).

# Compute HRV indices
hrv_info = nk.hrv(peaks, sampling_rate=100, show=False) 

I understand that NeuroKit takes a dataframe containing the samples, with each peak being 1 and the other samples being 0, for example:

ECG_R_Peaks
0   0
1   0
2   0
3   0
4   0
5   0
6   0
7   0
8   0
9   0
10  0
11  0
12  0
13  0
14  0
15  0
16  0
17  0
18  0
19  0
20  0
21  0
22  0
23  0
24  0
25  0
26  0
27  0
28  0
29  1
... ...
50652   0
50653   0
50654   0
50655   0
50656   0
50657   0
50658   0
50659   0
50660   0
50661   0
50662   0
50663   0
50664   0
50665   0
50666   0
50667   0
50668   0
50669   0
50670   0
50671   0
50672   0
50673   0
50674   0
50675   0
50676   0
50677   0
50678   0
50679   0
50680   0
50681   0

Now in my case, there are some anomalies in the peak detection that I would like to discard for the HRV analysis. Is there a way to indicate that in the input dataframe so that these anomalies are excluded when computing the HRV indicies?

Many thanks, Danielle

danibene commented 3 years ago

Moved here: https://github.com/neuropsychology/NeuroKit/issues/412