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
  • detect_partial_blinks

detect_partial_blinks#

pypillometry.signal.detect_partial_blinks(sy, smooth_winsize, low, high, min_len=5, max_len=None, unusable=None, max_bottom=None, method='velocity', noise=None, smooth=5, min_scale=10, max_scale=300, z=4.0)[source]#

Partial blinks in the pupil signal sy: a fast fall followed by a fast rise without missing samples between them (the lid covers part of the pupil, but the tracker does not lose it).

With method="excess", the tip of the dip takes the place of the dropout of a blink: from each minimum of the signal (smoothed with a running median of smooth samples) that stands out by more than the threshold of the test, the signal has to grow faster than the pupil can manage on both sides (the fall before and the rise after it, see excess_flank(); high is the largest plausible rate of the pupil). The partial blink extends to where the excess is largest on each side. A dip whose flank reaches missing or masked samples is the flank of a blink, not a partial blink.

With method="velocity", the fall and the rise are runs of at least min_len samples beyond high of the centred velocity; each fall is paired with the next rise, unless another fall comes first. The partial blink extends from the fall and the rise with hysteresis down to low (see flank_run()), so its edges come from the data. A fall right after a fast rise, or a rise right before a fast fall (within smooth_winsize), is the edge of an upward jump, not of a partial blink. Dips with missing samples are not partial blinks (see detect_blinks()).

A partial blink is V-shaped: the lid goes down and straight back up. With max_bottom, a dip with a longer bottom is not a partial blink (e.g., a step down and a later step up of the signal, such as the transients of two saccades). The bottom is measured on the signal, not on the (smoothed) velocity: the stretch from the first to the last sample within 20% of the depth of the dip above its minimum (the depth from the lower of its two edges), less the 20% of the width of the dip that a V of straight lines has there (so 0 for a sharp V, about the length of the flat part for a dip with a flat bottom).

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

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

  • low (float or np.ndarray) – rates (per sample, positive)

  • high (float or np.ndarray) – rates (per sample, positive)

  • min_len (int) – number of samples beyond high of the fall and of the rise

  • max_len (int or None) – maximum number of samples of a partial blink (None: no limit)

  • unusable (np.ndarray of bool, optional) – samples masked for other reasons: no partial blink includes them

  • max_bottom (int or None) – maximum number of samples of the bottom of a partial blink beyond that of a V (None: no limit)

  • method (str) – "velocity" (default) or "excess" (see above); with "excess", smooth_winsize, low and min_len are not used

  • noise (float, optional) – standard deviation of the noise of a sample (method="excess"; required)

  • smooth (int) – width of the running median and range of the scales (samples; method="excess", see excess_flank()); max_scale also bounds the length of each side of a partial blink

  • min_scale (int) – width of the running median and range of the scales (samples; method="excess", see excess_flank()); max_scale also bounds the length of each side of a partial blink

  • max_scale (int) – width of the running median and range of the scales (samples; method="excess", see excess_flank()); max_scale also bounds the length of each side of a partial blink

  • z (float) – threshold of the excess change (method="excess")

Return type:

ndarray

Returns:

array (n x 2) of first/last sample (both inclusive), sorted

previous

detect_blinks

next

detect_transients

On this page
  • detect_partial_blinks()
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.