systole.detection.ppg_peaks#
- systole.detection.ppg_peaks(signal: List | ndarray | Series, sfreq: int, new_sfreq: int = 1000, method: str = 'rolling_average', clipping: bool = True, clipping_thresholds: Tuple | List | str = 'auto', clean_nan: bool = False, verbose: bool = False, detector_kws: Dict = {}) Tuple[ndarray, ndarray] [source]#
Systolic peak detection for PPG signals.
Two methods are available: - an adaptation of the rolling average + standard deviation approach described in [R57c6d7365c14-1]. - The Multi-scale peak and trough detection algorithm (MSPTD) [R57c6d7365c14-2].
Before peaks detection, nans are interpolated (optional, Fale by default) the signal is resampled to the new sampling frequency (1000 Hz by default) and clipping artefacts are corrected using cubic spline interpolation (optional, True by default).
Note
This function will resample the signal to 1000 Hz by default.
- Parameters:
- signal
The raw signal recorded from the pulse oximeter time series.
- sfreq
The sampling frequency (Hz).
- new_sfreq
If resample is True, the new sampling frequency (Hz). Defaults to 1000.
- method
The systolic peaks detection algorithm to use, can be “rolling_average” [R57c6d7365c14-1] (default) or “msptd” [R57c6d7365c14-2].
- clipping
If True, will apply the clipping artefact correction described in [R57c6d7365c14-1]. Defaults to True.
- clipping_thresholds
The values of the minumum and maximum clipping thresholds. Can be a float or None. If None, no correction is applied. If “auto” is provided, will use
systole.utils.find_clipping()
to find the values. Defaults to “auto”.This parameter is only relevant if cliping is True.
- clean_nan
If True, will interpolate NaNs values if any before any other operation. Defaults to False.
- verbose
Control function verbosity. Defaults to False (do not print processing steps).
- detector_kws
Additional keyword arguments that will be passed to the detector function.
- Returns:
- resampled_signal
Signal resampled to the new_sfreq frequency.
- peaks
Boolean array of systolic peaks detection.
- Raises:
- ValueError
If clipping_thresholds is not a tuple, a list or “auto”. If method is not a valid method name.
References
[R57c6d7365c14-1] (1,2,3)van Gent, P., Farah, H., van Nes, N. and van Arem, B., 2019. Analysing Noisy Driver Physiology Real-Time Using Off-the-Shelf Sensors: Heart Rate Analysis Software from the Taking the Fast Lane Project. Journal of Open Research Software, 7(1), p.32. DOI: http://doi.org/10.5334/jors.241
[R57c6d7365c14-2] (1,2)S. M. Bishop and A. Ercole, ‘Multi-scale peak and trough detection optimised for periodic and quasi-periodic neuroscience data,’ in Intracranial Pressure and Neuromonitoring XVI. Acta Neurochirurgica Supplement, T. Heldt, Ed. Springer, 2018, vol. 126, pp. 189-195. <https://doi.org/10.1007/978-3-319-65798-1_39>
Examples
>>> from systole import import_ppg >>> from systole.detection import ppg_peaks >>> ppg = import_ppg().ppg.to_numpy() # Import PPG signal
Using the rolling average method (default)#
>>> signal, peaks = ppg_peaks(signal=ppg, method="rolling_average") >>> print(f'{sum(peaks)} peaks detected.') 378 peaks detected.
Using the Multi-scale peak and trough detection algorithm#
>>> signal, peaks = ppg_peaks(signal=ppg, method="msptd") >>> print(f'{sum(peaks)} peaks detected.') 378 peaks detected.