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

Not understanding ecg_wave_detector and plot_events_in_signal? #102

Open windowshopr opened 5 years ago

windowshopr commented 5 years ago

Hey,

I'm having an issue with these two functions. I am using the below code:

        ecg = nk.ecg_preprocess(ecg=data, sampling_rate=sample_rate)
        rpeaks = ecg["ECG"]["R_Peaks"]
        ecg = ecg["df"]["ECG_Filtered"]
        ecg_waves = nk.ecg_wave_detector(ecg=ecg, rpeaks=rpeaks)
        nk.plot_events_in_signal(ecg, [ecg_waves["P_Waves"], ecg_waves["Q_Waves_Onsets"], ecg_waves["Q_Waves"], list(rpeaks), ecg_waves["S_Waves"], ecg_waves["T_Waves_Onsets"], ecg_waves["T_Waves"], ecg_waves["T_Waves_Ends"]], color=["green", "yellow", "orange", "red", "black", "brown", "blue", "purple"])

...where 'data' is the ecg signal array, and sample rate is 250. I kept receiving Key Errors for:

ecg_waves["Q_Waves_Onsets"] ecg_waves["S_Waves"] ecg_waves["T_Waves_Onsets"] ecg_waves["T_Waves_Ends"]

...so I took them out of the above code, and removed 4 colours to compensate for their loss, but nothing plots? No images are created or anything. I put the missing 4 colours back in to see if that changed anything but still the same issue. The code runs through with no errors, but I don't see any plots or anything. What else could I try, and what is causing the key errors for those waves above? Thanks!