systole icon indicating copy to clipboard operation
systole copied to clipboard

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

Open martager opened this issue 7 months ago • 0 comments
trafficstars

https://github.com/embodied-computation-group/systole/blob/e515392b44dd6f75b6801f48f11f16c3851ac2ad/systole/interact/interact.py#L579-L589

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

martager avatar Apr 04 '25 14:04 martager