blink_stretches#
- pypillometry.signal.blink_stretches(sy, blinks, margin, blink_val=0)[source]#
The stretches of the signal that are replaced for the blinks: the core of each blink (from its first to its last missing sample, as in
blink_onsets_mahot(); the whole blink if it has no missing samples, e.g. a blink that does not close the eye completely) extended by margin on both sides. Stretches that overlap are merged.- Parameters:
sy (np.ndarray) – pupil data
blinks (np.ndarray or Intervals) – blink start/end sample indices (n x 2, end-exclusive)
margin (int or tuple of int) – samples (before, after) the core that are replaced too (the transients around it)
blink_val (float) – “missing value” code in addition to NaN (default 0)
- Return type:
- Returns:
the stretches (m x 2, end-exclusive, sorted)
Examples
>>> y = np.ones(100) >>> y[20:30] = np.nan >>> blink_stretches(y, [(18, 32), (60, 70)], (5, 10)) array([[15, 40], [55, 80]])