systole.utils.get_valid_segments#
- systole.utils.get_valid_segments(signal: ndarray, bad_segments: ndarray | List[Tuple[int, int]] | None = None) List[ndarray] [source]#
Return the longest signal or intervals time series after dropping segments marked as bads.
- Parameters:
- signal
The physiological time serie that should be filtered.
- bad_segments
Bad segments in the signal where RR interval or peaks to peaks intervals could not be accurately estimated. Intervals from these segments will be dropped and the time domain parameters will be computed over the remaining intervals. A warning is printed if the final intervals range is less than 2 minutes.
Examples
From a given physiological signal, and a set of bad segments, return the list of valid time series, sorted according to their length.
>>> import numpy as np >>> from systole.utils import get_valid_segments >>> signal = np.random.normal(size=1000) >>> bad_segments = [(500, 550), (700, 800)] >>> valids = get_valid_segments(signal=signal, bad_segments=bad_segments) >>> [len(sig) for sig in valids] `[500, 200, 150]`