extract_blink_artifacts#
- pypillometry.signal.extract_blink_artifacts(sy, cores, window, edge=None, mode='additive', blink_val=0)[source]#
Cut the artifacts of blinks out of a signal.
For each blink, the window around its core is cut out and a slow baseline is removed: the straight line through the means of the first and the last edge samples of the window. What remains is the artifact of the blink (plus the fluctuations of the signal and the noise in the window). It fades out to zero over the edge samples at both ends (cosine taper), so it can be added to another signal without steps (see
insert_blink_artifacts()).- Parameters:
sy (np.ndarray) – pupil data
cores (np.ndarray) – cores of the blinks to cut out (n x 2, end-exclusive); their windows must be inside the data and should have no other missing samples (see
blink_donors())window (int or tuple of int) – number of samples (before, after) the core to cut out; should be generous, so that the whole artifact is inside the window
edge (int, optional) – number of samples at each end of the window for the baseline and the taper; default: a quarter of the smaller side of the window
mode (str) –
"additive"(default): the artifact is the difference to the baseline;"multiplicative": the artifact is the ratio to the baseline (e.g., an eyelid that covers a part of the pupil), which needs a positive signalblink_val (float) – “missing value” code in addition to NaN (default 0)
- Return type:
- Returns:
one artifact per blink, with before + len(core) + after samples; NaN at the missing samples. Additive artifacts are 0 where there is no artifact, multiplicative ones 1.