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
    • HeadMountedEyeData
    • SceneNamespace
    • keephistory
    • QualityReport
    • QualityReports
    • QualityMetric
    • Table
    • RecordDict
  • Pupil methods (d.pupil)
    • PupilNamespace
  • Gaze methods (d.gaze)
    • GazeNamespace
  • Pipelines
    • crop
    • downsample
    • scale
    • unscale
    • merge_eyes
    • reset_time
    • mask_intervals
    • mask_signal
    • mask_islands
    • interpolate_intervals
    • exclude_intervals
    • keep_intervals
    • remove_intervals
    • merge_masks
    • clear_layer
    • set_blinks
    • set_events
    • add_events
    • set_experimental_setup
    • drop_data
    • rename_variable
    • copy_variable
    • rename_eye
    • copy_eye
    • 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_tobii_prolab
    • read_gazepoint
    • read_file
    • write_file
    • download
    • fetch_url
    • local_copy
    • get_osf_project_files
    • osf_authenticate
    • get_figshare_files
    • fetch_figshare_file
    • figshare_session
    • list_datasets
    • get
    • default_cache_dir
    • make_manifest
    • read_manifest
    • Dataset
    • PreprocessedDataset
    • Exclude
    • RobisonBrewer2022
    • RLMW
    • get_available_datasets
    • get_example_data
    • get_rlmw_002
    • get_rlmw_002_short
    • get_rlmw_010_edf
    • get_nback_001
    • get_robison_pxb
    • get_robison_pvt
    • get_robison_cd
  • 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
    • detect_partial_blinks
    • detect_transients
    • detect_transients_excess
    • excess_flank
    • find_islands
    • detect_comb
    • local_level
    • flank_run
    • blink_onsets_mahot
    • interpolate_blinks_mahot
    • interpolate_blinks_kalman
    • blink_stretches
    • transplant_blinks
    • transplant_error
    • blink_cores
    • blink_donors
    • extract_blink_artifacts
    • blink_artifact_profile
    • shrink_blink_artifacts
    • clean_stretches
    • place_blink_artifacts
    • insert_blink_artifacts
    • BlinkTransplant
    • tune_blinks_mahot
    • transplant_error_mahot
    • tune_blinks_kalman
    • transplant_error_kalman
    • tune_post_margins
    • BlinkTuneResult
    • PostMarginResult
    • 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
  • Geometry and gaze
    • ExperimentalSetup
    • SpatialCalibration
    • ForeshorteningCalibration
    • ROI
    • CircularROI
    • RectangularROI
  • Timescale model (experimental)
    • TimescaleModel
    • TimescaleGroup
    • TimescalePlots
    • TimescaleGroupPlots
    • block_mean
    • coarsen
    • semivariogram
    • plot_variogram
    • spectrum
    • plot_spectrum
    • Variogram
    • Spectrum
    • TimescaleBank
    • GaussianPrior
    • BankFit
    • GroupFit
    • VariogramCheck
    • GaussMarkovModel
    • Matern
    • OU
    • Constant
    • LGSSM
    • fit_bank
    • general_prior
    • reference_prior
    • fit_group
    • blocked_cv
    • variogram_check
    • kalman_filter
    • kalman_loglik
    • rts_smoother
    • forecast_errors
    • simulate
  • Simulated data: pp.sim
    • Simulation
    • SimEyeData
    • SimPlotNamespace
    • Task
    • parse_dist
    • pvt
    • sart
    • ftrsgt
    • nback
    • TimescalePupil
    • Fixations
    • Foreshortening
    • Units
    • Blinks
    • WhiteNoise
    • TrackerLoss
    • Comb
    • blink_occlusion
    • parse_rate
  • Units
    • Quantity
    • Unit
    • parse_time
    • parse_distance
    • parse_angle
  • Viewer, settings and logging
    • view
    • tweak
    • tweak_blink_interpolation
    • 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, rate_onset, rate_offset, margin, blinkwindow, min_onset_len=1, min_offset_len=1, max_gap=None)[source]#

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

The search starts from the core of each blink: the stretch from its first to its last missing (NaN or 0) sample, or its smallest pupil if it has no missing samples. The onset is the start of the closest closing transient (falling faster than rate_onset) that starts before the core, the offset the end of the closest opening transient (rising faster than rate_offset) that ends after it. The search (and the margins) stop at the neighbouring blinks, so that a transient of a neighbour is not taken for one of the blink. The result therefore does not depend on how far the blinks were extended when they were detected, and for a blink that contains several transients (e.g., merged blinks), the outermost ones are used.

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)

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), e.g. 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)

  • rate_onset (float or np.ndarray) – rate (in units per sample) of the fall at the onset of the blink (its absolute value is used; one for all samples, or one per sample)

  • rate_offset (float or np.ndarray) – rate (in units per sample) of the rise at the offset of the blink

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

  • blinkwindow (int) – how far before and after the core of 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

  • max_gap (int or None) – runs of threshold crossings separated by at most this many samples are joined into one transient; None (default) uses smooth_winsize

Return type:

ndarray

Returns:

array (n x 2) of refined onset/offset sample indices, one row per input blink; if no transient is found before (after) the core of a blink, the start (end) of the core is used

previous

flank_run

next

interpolate_blinks_mahot

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.