baseline_envelope#
- pypillometry.signal.baseline_envelope(tx, sy, event_onsets, fs=1000, lp=2, prominence_thr=80, interp_method='cubic')[source]#
Extract baseline based on the lower envelope of the (filtered) signal.
Steps:
filter away noise
detect high-prominence troughs in the signal
calculate lower envelope based on these peaks
- Parameters:
tx (np.ndarray) – time-vector (any unit; the baseline is evaluated at tx)
sy (np.ndarray) – raw pupil signal (must not contain NaN)
event_onsets (np.ndarray) – onsets of events (stimuli/responses); currently not used
fs (float) – sampling rate in Hz
lp (float) – low-pass filter cutoff in Hz for removing random noise
prominence_thr (float) – percentile (in [0, 100]) of the prominence distribution (of the peaks) to use for determining prominent peaks (see
scipy.signal.peak_prominences())interp_method ({"cubic", "linear", "spline"}) –
“linear”: linear interpolation between the high-prominence peaks
”cubic”: cubic interpolation through all high-prominence peaks
”spline”: a smoothing spline that is guaranteed to go through all high-prominence peaks and smoothes through all the other (lower-prominence) peaks
- Returns:
base (np.ndarray) – baseline estimate (same length as tx)
- Raises:
ValueError – if interp_method is not one of the supported methods