systole.interact.Editor#
- class systole.interact.Editor(signal: ndarray, sfreq: int, signal_type: str, corrected_json: Union[str, PathLike] = 'corrected.json', figsize: Tuple[int, int] = (15, 7), viewer: Optional[Viewer] = None, corrected_peaks: Optional[ndarray] = None, bad_segments: Optional[list] = None)[source]#
This class handle the visualization and manual edition of peaks vectors associated with physiological signals.
- 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.
See also
Notes
This module was largely inspired by the peakdet toolbox (physiopy/peakdet).
- 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.
- __init__(signal: ndarray, sfreq: int, signal_type: str, corrected_json: Union[str, PathLike] = 'corrected.json', figsize: Tuple[int, int] = (15, 7), viewer: Optional[Viewer] = None, corrected_peaks: Optional[ndarray] = None, bad_segments: Optional[list] = 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)Undoes last span select or quits peak editor
on_remove
(xmin, xmax)Removes specified peaks by either rejection / deletion, or mark bad segments.
plot_signals
()Clears axes and plots data / peaks / troughs.
quit
()Quits editor
save
()Save the JSON file containing the corrected peaks, bad segments and signal quality.