Skip to main content
Ctrl+K

pypillometry

  • Getting started
  • User guide
  • Tutorials
  • API reference
  • Experimental features
  • Development
  • GitHub
  • PyPI
  • Getting started
  • User guide
  • Tutorials
  • API reference
  • Experimental features
  • Development
  • GitHub
  • PyPI

Section Navigation

  • Data classes
    • EyeData
    • EyeDataDict
    • MaskPolicy
    • FakeEyeData
    • keephistory
    • QualityReport
    • QualityMetric
    • Table
    • RecordDict
  • Pupil methods (d.pupil)
    • PupilNamespace
  • Gaze methods (d.gaze)
    • GazeNamespace
  • Pipelines
    • crop
    • downsample
    • scale
    • unscale
    • merge_eyes
    • reset_time
    • mask_intervals
    • interpolate_intervals
    • exclude_intervals
    • keep_intervals
    • remove_intervals
    • merge_masks
    • clear_layer
    • set_blinks
    • set_events
    • add_events
    • set_experimental_setup
    • drop_data
    • drop_original
    • fill_time_discontinuities
    • Step
    • Pipeline
  • Events and intervals
    • Events
    • Epochs
    • Intervals
    • ClockSync
    • concat_intervals
    • sync_clocks
  • Segmented data
    • SegmentedEyeData
    • concat_segments
    • group_segments
    • SegmentedPupilNamespace
    • SegmentedGazeNamespace
  • Plotting (d.plot)
  • Reading and writing data
    • read_eyelink
    • read_file
    • write_file
    • download
    • fetch_url
    • local_copy
    • load_study_local
    • load_study_osf
    • get_osf_project_files
    • osf_authenticate
    • get_figshare_files
    • fetch_figshare_file
    • get_available_datasets
    • get_example_data
    • get_rlmw_002
    • get_rlmw_002_short
    • get_rlmw_010_edf
    • get_nback_001
  • Signal processing
    • butter_lowpass
    • butter_lowpass_filter
    • lowpass_filter_iterative
    • smooth_window
    • downsample
    • zscale
    • bspline
    • baseline_envelope
    • baseline_envelope_iter_bspline
    • baseline_pupil_model
    • velocity_savgol
    • detect_blinks_velocity
    • detect_blinks_zero
    • blink_onsets_mahot
    • pupil_kernel
    • pupil_kernel_t
    • pupil_get_max_duration
    • plot_prf
    • pupil_build_design_matrix
    • pupil_response
    • pupil_response_coverage
    • pupilresponse_nnls
    • pupil_signal_quality
    • pupil_eye_offset
    • fake_pupil_baseline
    • fake_gaze_fixations
    • add_measurement_noise
    • generate_foreshortening_data
  • Geometry and gaze
    • ExperimentalSetup
    • SpatialCalibration
    • ForeshorteningCalibration
    • ROI
    • CircularROI
    • RectangularROI
  • Units
    • Quantity
    • Unit
    • parse_time
    • parse_distance
    • parse_angle
  • Viewer, settings and logging
    • view
    • tweak
    • set_default_inplace
    • get_default_inplace
    • logging_set_level
    • logging_get_level
    • logging_disable
    • logging_enable
    • loglevel
    • nologging
    • initialize_logging
  • API reference
  • Signal processing
  • blink_onsets_mahot

blink_onsets_mahot#

pypillometry.signal.blink_onsets_mahot(sy, blinks, smooth_winsize, vel_onset, vel_offset, margin, blinkwindow, min_onset_len=1, min_offset_len=1)[source]#

Method for finding the on- and offset for each blink (excluding transient). See https://figshare.com/articles/A_simple_way_to_reconstruct_pupil_size_during_eye_blinks/688001.

Uses asymmetric Savitzky-Golay velocity estimation: - Backward-looking velocity for onset detection (so future zeros/NaN don’t affect the estimate) - Forward-looking velocity for offset detection (so past zeros/NaN don’t affect the estimate)

The asymmetric approach naturally handles blink regions (zeros/NaN) because: - At blink onset: backward velocity only sees valid data before the blink → detects the drop - At blink offset: forward velocity only sees valid data after the blink → detects the rise

Parameters:
  • sy (np.ndarray) – pupil data (can contain NaN or zeros for missing values)

  • blinks (np.ndarray or Intervals) – blink onset/offset sample indices (nblinks x 2), e.g. from detect_blinks_zero() or an Intervals object in index units; anything that iterates over (start, end) pairs works

  • smooth_winsize (int) – size of the Savitzky-Golay window in samples (odd)

  • vel_onset (float) – velocity-threshold to detect the onset of the blink; in units per sample (negative value)

  • vel_offset (float) – velocity-threshold to detect the offset of the blink; in units per sample (positive value)

  • margin (tuple of int) – (before, after) margin that is subtracted/added to onset and offset (in samples)

  • blinkwindow (int) – how much time before and after each blink to search for the on-/offset (in samples)

  • min_onset_len (int) – minimum number of consecutive samples in an onset run to be considered valid

  • min_offset_len (int) – minimum number of consecutive samples in an offset run to be considered valid

Return type:

np.ndarray

Returns:

array (n x 2) of refined onset/offset sample indices, one row per input blink; if no valid velocity-threshold crossing is found before (after) a blink, its detected start (end) is used

previous

detect_blinks_zero

next

pupil_kernel

On this page
  • blink_onsets_mahot()
Edit on GitHub
Show Source

© Copyright 2020-2026, Matthias Mittner.

Created using Sphinx 9.2.0.

Built with the PyData Sphinx Theme 0.24.0.