Skip to content

Not understanding ecg_wave_detector and plot_events_in_signal? #102

@windowshopr

Description

@windowshopr

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions