mask_islands#

pypillometry.mask_islands(min_duration=50, max_gap=5, min_density=None, eyes=[], variables=['pupil'], policy='default')#

Pipeline step for mask_islands() (d | pp.mask_islands(...)).

Mask islands: short stretches of usable data between unusable ones.

After masking (dropouts, transients, off-screen gaze, quality signals, …), single fragments of data often remain between the masked stretches. They are usually artifacts as well and are too short to be of use. Unusable stretches of up to max_gap do not separate the data (e.g., single missing samples every few samples in otherwise good data), so that thinned-out data are not taken apart. The usable data then fall into segments, separated by longer unusable stretches (or the start and end of the recording); a segment is an island if its span (from its first to its last usable sample) is shorter than min_duration, or, with min_density, if less than this fraction of it is usable (e.g., flickering data).

Islands are found from all other masks, so this is best done after the other masking steps (and before interpolating). Each channel is treated separately. The islands are stored as the "island" layer; they replace the ones masked before (masking islands does not make new ones, so running it again gives the same result).

Parameters:
  • min_duration (float, str or Quantity) – minimum span of a segment (in ms, or with units; default 50 ms)

  • max_gap (float, str or Quantity) – longest unusable stretch that does not separate segments (in ms, or with units; default 5 ms)

  • min_density (Optional[float]) – minimum fraction (0-1) of usable samples in a segment; default None (no minimum)

  • eyes (str or list) – eyes to process (default: all)

  • variables (str or list) – variables to process (default: the pupil)

  • policy (str or MaskPolicy) – samples that are unusable under this policy (default "default"; the "island" layer itself does not count) separate the segments

  • inplace (bool or None) – 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

Return type:

Self

Returns:

the object with the islands masked (self or a copy, depending on inplace)

Examples

>>> import pypillometry as pp
>>> d = pp.get_example_data("rlmw_002_short")
>>> d = d.pupil.mask_transients().mask_islands()
>>> stats = d.layer_stats("island", variables="pupil")