mask_intervals#
- pypillometry.mask_intervals(intervals, eyes=[], variables=[])#
Pipeline step for
mask_intervals()(d | pp.mask_intervals(...)).Apply Intervals as masks to selected data.
Takes detected intervals (e.g., blinks, artifacts) and applies them as masks to specified eyes and variables: they are added to the
"user"layer (existing masks are kept).- Parameters:
intervals (Intervals, Epochs, list of tuple or dict) –
Either:
A single Intervals (or
Epochs) object or a list of(start, end)tuples (in ms, or with units): applied to all specified eyes/variablesA dict of Intervals (or Epochs): keys like “left_pupil”, “right_x”, etc. When dict is provided, eyes and variables are ignored.
eyes (str or list of str, optional) – eye(s) to apply mask to (e.g.,
["left", "right"]); if empty, all available eyes. Ignored if intervals is a dict.variables (str or list of str, optional) – variable(s) to apply mask to (e.g.,
["pupil", "x", "y"]); if empty, all available variables. Ignored if intervals is a dict.inplace (bool or None, optional) – if True, make change in-place and return the object; if False, make and return copy before making changes; if None, use the object-level setting (specified in the constructor)
- Return type:
- Returns:
The object with masks applied (self or a copy, depending on inplace).
See also
pypillometry.eyedata.pupil.PupilNamespace.blinks_detectDetect blinks
get_blinksRetrieve stored blink intervals
Examples
Apply blinks from a single Intervals object to left eye pupil data:
>>> import pypillometry as pp >>> d = pp.get_example_data("rlmw_002_short").pupil.blinks_detect() >>> blinks = d.get_blinks() >>> d = d.mask_intervals(blinks["left_pupil"], eyes=["left"], variables=["pupil"])
Apply a dict of intervals (one per eye/variable):
>>> d = d.mask_intervals(blinks) # eyes and variables ignored
Chain with other operations:
>>> d = d.mask_intervals(blinks).pupil.lowpass_filter(cutoff=5)