Skip to content

Editor displays incorrect time scale and RR intervals when sfreq is not 1000 Hz #76

@martager

Description

@martager

plot_raw(
signal=self.signal,
peaks=self.peaks,
modality=self.signal_type.lower(),
backend="matplotlib",
show_heart_rate=True,
show_artefacts=True,
bad_segments=bad_segments,
sfreq=1000,
ax=[self.ax[0], self.ax[1]],
)

Dear @LegrandNico ,

on a related note to my previous issue, I've noticed that the default sfreq=1000 similarly creates a visualization issue when using the interactive Editor for manual R-peak correction.

Example:
In the screenshot below, I am using the Editor to manually correct a 10-min ECG recording acquired at 500 Hz. Despite setting the correct sfreq=500 in the function's arguments, the Editor squeezes the time scale by assuming the default sampling frequency of 1000 Hz. This is also reflected in inaccurate RR interval durations (e.g., 300-475 ms range, half of what would be expected).

editor = Editor(
       signal=ecg_clean, 
       corrected_json=ecg_corr_fpath,
       sfreq=500, 
       signal_type="ECG", figsize=(10, 6)
)

display(editor.commands_box)

Image

Luckily, this seems to be only a visualization issue, as the manually corrected R-peaks indices are saved correctly in the output JSON file. However, it could be misleading for those working with sfreq values other than 1000 Hz, as it results in inaccurate time scales and plotted HR values.

I have tried to identify where this bug arises in the interact.py script (see code lines above), but you might want to double check the entire code.

Thanks again for all the work behind this great package!
All the best,

Marta

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