systole.interact.Editor#

class systole.interact.Editor(signal: ndarray, sfreq: int, signal_type: str, corrected_json: str | PathLike = 'corrected.json', figsize: Tuple[int, int] = (15, 7), viewer: Viewer | None = None, corrected_peaks: ndarray | None = None, bad_segments: list | None = None)[source]#

Visualization and manual edition of peaks vectors.

Parameters:
signal

The physiological signal.

sfreq

The sampling frequency of the pysiological signal.

signal_type

The type of signal that are being analyzed. Can be “PPG”, “ECG” or “RESP”. Defaults to “PPG”.

corrected_json

Path to the corrected JSON file.

figsize

The size of the interactive Matplotlib figure for peaks edition. Defaults to (15, 7).

viewer

The viewer instance from which the editor is called.

corrected_peaks

The 1d array of corrected peaks indexes, in case the signal was previously edited. This is mostly relevant for the :py:class`systole.interact.Viewer` when a pre-existing JSON file is found in the derivatives.

bad_segments

List of start_idx and end_idx annotating bad segments, in case the signal was previously edited. This is mostly relevant for the :py:class`systole.interact.Viewer` when a pre-existing JSON file is found in the derivatives.

Attributes:
bad_segments

List of start_idx and end_idx listing bad segments. The list is automatically generated by:py:func:systole.utils.norm_bad_segments to avoid overlaping segments.

uncorrected_peaks

The peaks vector as detected using the default peaks detection algorithm. If the signal was edited previously, this variable is directly imported from the JSON file.

json_file

Path to the sidecar JSON file.

peaks

The corrected peaks vector after manual insertion/deletion.

physio_filePathLike | None

Path to the physiological recording.

time

Time vector.

edition_, rejection_, command_box_, save_button_

Widgets controlling the type of modification to perform.

See also

Viewer

Notes

This module was largely inspired by the peakdet toolbox (physiopy/peakdet).

__init__(signal: ndarray, sfreq: int, signal_type: str, corrected_json: str | PathLike = 'corrected.json', figsize: Tuple[int, int] = (15, 7), viewer: Viewer | None = None, corrected_peaks: ndarray | None = None, bad_segments: list | None = None) None[source]#

Methods

__init__(signal, sfreq, signal_type[, ...])

find_peaks()

Find peaks depending on the signal type.

on_add(xmin, xmax)

Add a new peak on the maximum signal value from the selected range.

on_key(event)

Undo last span select or quits peak editor.

on_remove(xmin, xmax)

Remove peaks by either rejection / deletion, or mark bad segments.

plot_signals()

Clear axes and plots data / peaks / troughs.

quit()

Quits editor.

save()

Save the JSON file.