pulsedet
biosigpy.ppg.pulsedet.pulsedet ¶
pulsedet(dppg: ArrayLike, sampling_frequency: float, *, method: str = 'adaptive', adaptive_alpha_amp: float = 0.2, adaptive_refract_period: float = 0.15, adaptive_tau_rr: float = 1.0, reset_after: float | None = None) -> tuple[np.ndarray, np.ndarray]
Return refined pulse maximum-upslope times and an adaptive threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dppg | array_like | Nonempty real PPG derivative after low-pass differentiation and any filter-delay compensation. NaNs are allowed; infinities are invalid. | required |
sampling_frequency | float | Finite positive sampling frequency in Hz. | required |
method | str | Detection algorithm: | 'adaptive' |
adaptive_alpha_amp | float | Positive amplitude multiplier defining the threshold floor, default 0.2. | 0.2 |
adaptive_refract_period | float | Positive refractory threshold-hold duration in seconds, default 0.15. | 0.15 |
adaptive_tau_rr | float | Positive decay duration after the refractory period, expressed as a fraction of the estimated pulse interval. Default is 1.0. | 1.0 |
reset_after | float or None | Positive seconds without a raw detection before restarting adaptation. Missing spans count toward elapsed time; initialization resumes when signal is available. None (default) or positive infinity disables resets. | None |
Returns:
| Name | Type | Description |
|---|---|---|
t_d | ndarray | One-dimensional array of quadratically refined detection times in seconds, with the first input sample at time zero. Undefined refined times are omitted. No detections yields an empty array. |
threshold | ndarray | One-dimensional adaptive threshold aligned with every input sample. |
Notes
Adaptive state is preserved throughout the signal, including NaN spans, unless the optional inactivity reset is enabled. Missing samples do not satisfy crossings, but a crossing region can span them. Raw detections update adaptation even if missing neighbors prevent time refinement.
A finite reset_after can help after a device gain reduction leaves pulses below the previous threshold floor. It is optional and its duration depends on the application. This function does not perform preprocessing.
Source code in src/biosigpy/ppg/pulsedet.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |