interpolate_blinks_mahot#
- pypillometry.signal.interpolate_blinks_mahot(sy, blinks, smooth_winsize, rate_onset, rate_offset, margin, blinkwindow, interp_type='cubic', tx=None, missing=None, max_duration=None)[source]#
Interpolate blinks with the method by Mahot (2013).
The on- and offset of each blink (including the transients) are found in the velocity profile (see
blink_onsets_mahot()), and the samples between them are replaced by a curve through four anchor points: the onset t2, the offset t3, and the points one blink duration before and after them (t1 = t2-(t3-t2),t4 = t3+(t3-t2)). Blinks that are so close that the anchor points of one fall into the other are merged and interpolated together. Blinks that are too short or have an unusable anchor point are skipped.- Parameters:
sy (np.ndarray) – pupil data (can contain NaN or zeros for missing values)
blinks (np.ndarray or Intervals) – blink start/end sample indices (nblinks x 2, end-exclusive); only the core of each blink is used (see
blink_onsets_mahot())smooth_winsize – see
blink_onsets_mahot()(samples, and units per sample)rate_onset – see
blink_onsets_mahot()(samples, and units per sample)rate_offset – see
blink_onsets_mahot()(samples, and units per sample)margin – see
blink_onsets_mahot()(samples, and units per sample)blinkwindow – see
blink_onsets_mahot()(samples, and units per sample)interp_type (str) – type of interpolation accepted by
scipy.interpolate.interp1d()tx (np.ndarray, optional) – time of each sample; default: the sample index
missing (np.ndarray of bool, optional) – samples that cannot be used as anchor points (e.g., excluded periods); NaN samples never can
max_duration (int, optional) – maximum number of samples that are replaced for one blink (with its margins, or after merging it with neighbouring blinks); longer ones are skipped (e.g., chains of merged blinks); None: no limit
- Return type:
tuple[ndarray,ndarray,list[tuple[int,tuple[int,...],str]]]- Returns:
filled (np.ndarray) – copy of sy with the blinks replaced
interpolated (np.ndarray of bool) – the replaced samples
skipped (list) – the blinks that were not interpolated, as tuples
(index, (t1, t2, t3, t4), reason)
References
Mahot, 2013: https://figshare.com/articles/A_simple_way_to_reconstruct_pupil_size_during_eye_blinks/688001.