We describe here PyOKR, a semi-automated quantitative analysis method that directly measures eye movements resulting from visual responses to two-dimensional image motion. A Python-based user interface and analysis algorithm allows for higher throughput and more accurate quantitative measurements of eye-tracking parameters than previous methods.
The study of behavioral responses to visual stimuli is a key component of understanding visual system function. One notable response is the optokinetic reflex (OKR), a highly conserved innate behavior necessary for image stabilization on the retina. The OKR provides a robust readout of image tracking ability and has been extensively studied to understand visual system circuitry and function in animals from different genetic backgrounds. The OKR consists of two phases: a slow tracking phase as the eye follows a stimulus to the edge of the visual plane and a compensatory fast phase saccade that resets the position of the eye in the orbit. Previous methods of tracking gain quantification, although reliable, are labor intensive and can be subjective or arbitrarily derived. To obtain more rapid and reproducible quantification of eye tracking ability, we have developed a novel semi-automated analysis program, PyOKR, that allows for quantification of two-dimensional eye tracking motion in response to any directional stimulus, in addition to being adaptable to any type of video-oculography equipment. This method provides automated filtering, selection of slow tracking phases, modeling of vertical and horizontal eye vectors, quantification of eye movement gains relative to stimulus speed, and organization of resultant data into a usable spreadsheet for statistical and graphical comparisons. This quantitative and streamlined analysis pipeline, readily accessible via PyPI import, provides a fast and direct measurement of OKR responses, thereby facilitating the study of visual behavioral responses.
Image stabilization relies on precise oculomotor responses to compensate for global optic flow that occurs during self-motion. This stabilization is driven primarily by two motor responses: the optokinetic reflex (OKR) and the vestibulo-ocular reflex (VOR)1,2,3. Slow global motion across the retina induces the OKR, which elicits reflexive eye rotation in the corresponding direction to stabilize the image1,2. This movement, known as the slow phase, is interrupted by compensatory saccades, known as the fast phase, in which the eye rapidly resets in the opposite direction to allow for a new slow phase. Here, we define these fast-phase saccades as eye-tracking movements (ETMs). Whereas the VOR relies on the vestibular system to elicit eye movements to compensate for head movements3, the OKR is initiated in the retina by the firing of ON and subsequent signaling to the Accessory Optic System (AOS) in the midbrain4,5. Due to its direct reliance on retinal circuits, the OKR has been frequently used to determine visual tracking ability in both research and clinical settings6,7.
The OKR has been studied extensively as a tool for assessing basic visual ability2,6,8, DSGC development9,10,11,12, oculomotor responses13, and physiological differences among genetic backgrounds7. The OKR is evaluated in head-fixed animals presented with a moving stimulus14. Oculomotor responses are typically captured using a variety of video tools, and eye-tracking motions are captured as OKR waveforms in the horizontal and vertical directions9. To quantify tracking ability, two primary metrics have been described: tracking gain (the velocity of the eye relative to the velocity of the stimulus) and ETM frequency (the number of fast phase saccades over a given time frame). Calculation of gain has been used historically to directly measure angular velocity of the eye to estimate tracking ability; however, these calculations are labor intensive and can be arbitrarily derived based on video-oculography collection methods and subsequent quantification. For more rapid OKR assessment, counting of ETM frequency has been used as an alternate method for measuring tracking acuity7. Although this provides a fairly accurate estimation of tracking ability, this method relies on an indirect metric to quantify the slow phase response and introduces a number of biases. These include an observer bias in saccade determination, a reliance on temporally consistent saccadic responses across a set epoch, and an inability to assess the magnitude of the slow phase response.
In order to address these concerns with current OKR assessment approaches and to enable a high throughput in-depth quantification of OKR parameters, we have developed a new analysis method to quantify OKR waveforms. Our approach uses an accessible Python-based software platform named "PyOKR." Using this software, modeling and quantification of OKR slow phase responses can be studied in greater depth and with increased parameterization. The software provides accessible and reproducible quantitative assessments of responses to a myriad of visual stimuli and also two-dimensional visual tracking in response to horizontal and vertical motion.
All animal experiments performed at The Johns Hopkins University School of Medicine (JHUSOM) were approved by the Institutional Animal Care and Use Committee (IACUC) at the JHUSOM. All experiments performed at the University of California, San Francisco (UCSF) were performed in accordance with protocols approved by the UCSF Institutional Animal Care and Use Program.
1. Behavioral data collection
2. Installation of analysis software
3. Analysis of wave data
To validate the analysis method described above, we quantified OKR tracking gain on wave traces collected from wild-type mice and a conditional knockout mutant with a known tracking deficit. In addition, to test the broader applicability of our analysis method, we analyzed traces derived from a separate cohort of wild-type mice acquired using a different video-oculography collection method. The automatic filtering of saccades facilitates OKR data processing and analysis (Figure 3). Using recordings from unidirectional and sinusoidal stimuli (Figure 1D), we calculated OKR tracking gains in the four cardinal directions (Figure 2F) for wild-type animals (n = 13) to unidirectional stimuli and also tracking gains in response to horizontal and vertical sinusoidal stimuli (Figure 4). The disparity in tracking ability relative to stimulus direction for both unidirectional and sinusoidal stimuli is consistently observed in all wild-type mice, with equally robust horizontal responses that demonstrate significantly higher tracking gains than vertical responses, as has been described2. Further, asymmetric tracking gains between upward and downward responses are also observed in wild-type mice using both video-oculography collection methods, as has been previously reported2,10. The relative magnitudes and the consistency of tracking gains compared to published characterization of OKR responses indicate that tracking gains calculated using the software accurately reflect tracking ability. In addition to single-directional gain calculations, horizontal and vertical eye movement can be modeled simultaneously (Figure 5), allowing for a three-dimensional reconstruction of eye movement in response to a given stimulus. This provides an additional quantification capability that is useful for future studies investigating cross-coupled horizontal and vertical responses9.
To validate the utility of the software for identifying significant behavioral changes across different experimental conditions, we re-analyzed our published data9 to confirm that deficits in vertical tracking assessed in that study by manual counting of fast phase saccades are reflected in tracking gains using the methodology presented here. Previous work shows that genetic inactivation in the retina of the transcription factor T-box Transcription Factor 5 (Tbx5) through conditional knockout using Protocadherin 9-Cre (Pcdh9-Cre) causes specific loss of upward-tuned ON Direction-Selective Ganglion Cells (up-oDSGCs), and that Tbx5 Flox/Flox (Tbx5f/f); Pcdh9-Cre mutants exhibit specific loss of vertical OKR tracking9. Quantitative analysis using the method described here shows that Tbx5f/f; Pcdh9-Cre animals retain normal horizontal tracking gains (Figure 6A), similar to those described previously and obtained by manual counting of fast phase saccades (ETMs) (Figure 2F); however, these mice show significant loss of vertical tracking, with near zero gains in response to both upward and downward stimuli (Figure 6B,C). Additionally, analysis of sinusoidal responses confirms that Tbx5 cKO animals exhibit greater horizontal tracking gains while showing significantly decreased vertical tracking (Figure 6D–F). A reanalysis of this previously described phenotype using PyOKR demonstrates the precision and sensitivity of this new methodology, which allows for quantitative comparisons of OKR responses in mice of different genetic strains.
Finally, we analyzed wild-type vertical OKR traces collected at UCSF to validate the software application's utility with different video-oculography methods and stimulus parameters. Data from UCSF were collected using a hemispherical projection system in which moving gratings are presented to the mouse through the reflection of a 405 nm wavelength projector onto a hemisphere surrounding the head-fixed animal10 (Figure 7A). Unidirectional vertical gratings were presented to mice at a speed of 10 degrees per second, and the OKR responses were recorded over 60-s intervals (Figure 7B,C). Vertical traces were quantitatively analyzed via the PyOKR, and upward responses were compared to downward responses (Figure 7D). Upward responses were significantly stronger than downward, as expected10; however, tracking gains were slightly reduced compared to traces recorded at JHUSOM (Figure 2F). In addition, the quantification of sinusoidal responses was analyzed via PyOKR (Figure 7E), and a significant asymmetry in the vertical responses to sinusoidally moving stimuli is reflected in calculated gains (Figure 7F). Differences between gain values collected at JHUSOM and UCSF can be attributed to differences between stimulus parameters, including different stimulus speeds, types, and wavelengths; however, the overall consistency we observe in our analysis of data obtained using each collection method shows that our PyOKR can be easily adapted beyond our JHUSOM OKR data collection system and applied to other OKR recordings, independent of video-oculography methods. These results demonstrate that the software platform described here is accurate and can be generally applied to the study of oculomotor responses, allowing for precise quantitative comparisons among animals belonging to different groups to further the study of visual image stabilization circuitry.
Figure 1: Collection of OKR response data. (A) OKR virtual arena apparatus for behavioral stimulation, as previously described9,13. Four monitors surround a head-fixed animal (1), displaying a continuously moving checkerboard stimulus (2). The virtual drum can present unidirectional movement in all four cardinal directions as well as oscillatory sinusoidal stimuli. The mouse's left eye is illuminated by an infrared (IR) light and recorded with a camera (3) to record visual system responses reflected in eye tracking. (B) Analysis of eye tracking occurs by capturing the pupil and a corneal reflection generated by IR light. Data collection and calculation of eye movements in response to the virtual drum were performed as described previously9,13. (C) Schematic of eye vectors moving vertically (Y wave) and horizontally (X wave). (D) Sample traces of an eye's tracking response to unidirectional upwards and backwards motion, and also vertical and horizontal sinusoidal motion. Please click here to view a larger version of this figure.
Figure 2: Tracking analysis of unidirectional visual responses. (A–D) Identification and selection of slow tracking phases for gain analysis. Sample unidirectional traces are shown with visual responses to forward (A), backward (B), upward (C), and downward (D) motion in relation to the mouse's eye. Slow phases are identified by the addition of red and green points described in Step 3 to remove saccades, and the selected slow phases are highlighted in yellow. Polynomial regressions are overlaid on the traces as lines. (E) Quantification of the sample traces (A–D) as organized in the PyOKR readout. For each trace, total XY speeds and respective gains are calculated, regardless of directionality. In unidirectional responses, these total speeds will usually reflect the individual velocity in a certain direction; however, for sinusoidal responses, this value will reflect the average overall speed of the eye. Horizontal and vertical velocity components are broken down to show velocity in each respective direction. Gain is then calculated based on the presented stimulus velocities. (F) Calculated tracking gains of wild-type animals (n = 13) in the four cardinal directions compared to their associated ETM quantification. Data are presented as mean ± SD. Data analyzed with a one-way ANOVA with multiple comparisons. *p<0.05, **p<0.01,***p<0.005, ****p<0.0001. Please click here to view a larger version of this figure.
Figure 3: Automatic filtering of saccades facilitates OKR data processing and analysis. (A–D) Automatic filtering of traces from Figure 2A–D removes saccades and models only slow phase motion by removing rapid velocity changes and stitching slow phases together. The final slope represents the total eye movement over the given epoch. (E) Quantification of gains from filtered sample data, as organized in the PyOKR readout. (F) Comparison of gain values between unfiltered vs. filtered sample eye traces reflects no significant differences. Data are presented as mean ± SD. Data analyzed with a Mann-Whitney U test between unfiltered and filtered results. Please click here to view a larger version of this figure.
Figure 4: Derivation of tracking gains in response to oscillatory visual stimuli. (A,B) Vertical (A) and horizontal (B) eye movement responses to sinusoidally moving stimuli can be modeled relative to defined oscillatory stimulus parameters. Selected regions are labeled in yellow with the polynomial approximation overlaid on top of the trace. A model of the stimulus is presented as an orange sinusoid wave behind the trace to allow for reference to what the stimulus is at each point. (C) Gain calculations of wild-type sinusoidal responses (n = 7) reflect asymmetrical responses between horizontal and vertical tracking ability. Data are presented as mean ± SD. Data analyzed with a one-way ANOVA with multiple comparisons. **p<0.01,***p<0.005. Please click here to view a larger version of this figure.
Figure 5: Directional tracking can be modeled in its horizontal and vertical components. (A) Vertical component of an eye tracking wave in response to an upward stimulus. (B) Horizontal component of an eye tracking wave in response to an upward stimulus. (C) Overall eye trajectory in both vertical and horizontal directions. (D) Three-dimensional model of the eye's movement vector over time in response to downward motion. Raw trace data is displayed in red and the regression model of trajectory is displayed in blue. Please click here to view a larger version of this figure.
Figure 6: Analysis of the OKR in Tbx5f/f; Pcdh9-Cre mice shows significant deficits in unidirectional vertical tracking gains. (A) Tbx5f/f; Pcdh9-Cre animals show no significant change in horizontal tracking gain. (B,C) Tbx5f/f; Pcdh9-Cre animals show a significant reduction of gain in their vertical responses: upwards (B) and downwards (C). (D,E) Sinusoidal responses of Tbx5f/f; Pcdh9-Cre animals in response to horizontal (D) and vertical (E) oscillatory stimuli. (F) Quantification of Tbx5f/f; Pcdh9-Cre oscillatory responses show significant increases in horizontal tracking gains, but show decreases in vertical responses. Data are presented as mean ± SD. Data analyzed with Mann-Whitney U tests. *p<0.05, **p<0.01, ****p<0.0001. Please click here to view a larger version of this figure.
Figure 7: Application of PyOKR to data acquired from alternative video-oculography methods. (A) Apparatus for OKR virtual drum stimulation, as described10. A 405 nm wavelength DLP projector is reflected via a convex mirror onto a hemisphere to create a virtual drum that surrounds the animal's field of view. Eye movements are measured using an NIR camera positioned outside of the hemisphere. Unidirectional and sinusoidal bar gratings are shown to a head-fixed animal in vertical directions. (B,C) Upward (B) and downward (C) tracking phases are identified and selected for quantitative analysis. Slow phases are highlighted in yellow. (D) Tracking gains calculated from vertical tracking of wild-type animals (n=5) using methods described here. Asymmetric tracking ability is observed, with a significant decrease in downward tracking. (E) Oscillatory response to sinusoidal stimuli modeled to quantify tracking gains in wild-type animals (n=8). Slow phases are highlighted in yellow. (F) Quantification of sinusoidal gains reveals decreased downward tracking gains compared to upward gains. Data are presented as mean ± SD. Data analyzed with Mann-Whitney U tests. *p<0.05. Please click here to view a larger version of this figure.
Supplementary Coding File 1: PyOKR Windows Please click here to download this File.
Supplementary Coding File 2: PyOKR Mac Please click here to download this File.
PyOKR provides several advantages for studying visual responses reflected in eye movements. These include accuracy, accessibility, and data collection options, in addition to the ability to incorporate parameterization and variable stimulus speeds.
Direct eye tracking gain assessment provides an accurate characterization of eye movement that is a more direct quantitative metric than traditional manual counting of fast phase saccades (ETMs). Although useful, saccade counting provides an indirect assessment of the actual tracking motion. The PyOKR software platform provides direct quantification of tracking speeds, taking into account additional parameters including saccade amplitudes and the length of slow phases. In addition, fast-phase saccade counting relies on the assessment of saccade frequency over a set period of time, requiring that each trace has little to no noise, including random saccades from animal stress. These factors result in many collected traces being unusable and, therefore, add significant time for data collection in order to accurately assess eye tracking. However, the software descibed here addresses this issue by directly quantifying individual slow phases within a given trace and calculating gains at instantaneous points along the trace. It accomplishes this by comparing the velocity of the eye motion to the speed of the stimulus at a given point. Since saccadic frequency is no longer the defining parameter for analysis, noise can be easily removed by user supervision, reducing the impact of noise on the quality of the analysis. This allows for more usable collected data and, higher statistical power when analyzing these data, increasing accuracy and reproducibility when quantifying eye tracking and characterizing OKR parameters for individual mice and different groups of mice. Automated filtering of saccades based on rapid changes in eye velocity found via a Z-score method has also been used to characterize tracking gain10. To incorporate this filtering method within the software, we included this type of velocity filtering but with additional tools such as threshold parameterization and manual saccadic supervision to reduce potential errors generated by this approach. If raw traces are used for analysis instead of using automated filtering, rapid changes in eye movement caused by saccades, blinks, or mouse distress are identified through maximal velocity changes via a Gaussian kernel density estimation of trace velocity. This allows for the automatic selection of segmenting regions and, eventually, removal based on manual user supervision. Manual supervision provides a higher tolerance of noisy traces, allowing users to quickly correct false positive or false negative markings for rapid eye changes. Additionally, since PyOKR uses polynomial approximations to model general eye motion in a given direction, noise at individual points is smoothed out, allowing for trajectory speeds to be assessed with some tolerance for noise in the trace. Only in the event of extremely poor data quality across the entire trace or improper calibration during data collection will the software be unable to generate accurate data analysis. Taken together, by incorporating user supervision, filtering, and instantaneous gain calculation tools, the PyOKR software application described here generates tracking gains with high accuracy and more direct metrics than previous methods.
PyOKR also has many features that allow for OKR analyses to be customized to meet user needs. The input of stimulus parameters, as well as raw stimulus vectors, allows the user to precisely define any desired stimulus. These may include unidirectional, sinusoidal, or oblique stimuli, all of which the software can use to generate accurate tracking gains for the associated visual responses. With the stimulus parameterization of this methodology, instantaneous gains calculated at each frame can be reliably generated with high accuracy regardless of the inputted stimulus. Although oblique stimuli data were not analyzed here, accurate gains can be calculated through decomposed XY velocity vectors to reconstruct an oblique angle, allowing for accurate gain calculations of oblique stimuli. Through accessible parameterization of stimuli settings, our tool is widely applicable to wave tracing in response to any visual stimulus. Additionally, the software facilitates higher throughput and reproducible quantification compared to previous methods. Sorting through OKR traces is time-consuming and labor-intensive; however, the PyOKR streamlined user interface is able to easily screen through many traces at a higher rate than previously possible. This not only allows for faster trace quantification but also reveals additional OKR parameters, including direct quantification of eye velocities, directional vector components of eye motion, and instantaneous gains relative to the stimulus in both the horizontal and vertical components of the movement vector. Further, given the automated identification of saccades and calculation of tracking speeds afforded by our method, potential experimenter bias in data analysis is greatly reduced compared to other quantification methods, such as manual ETM counting or automated trace filtering, which can generate false negatives. Further, large amounts of behavioral data can be generated and automatically compiled for simplified downstream analysis. Through the data export and sorting functions available in PyOKR, tracking data across multiple animals and conditions can be automatically processed to allow for organized data storage as well as rapid statistical analysis. For conducting experiments that employ multiple conditions during the same recording session, such as circuit manipulation or visual responses, we recommend collecting data in discrete wave files or subsetted epochs that allow for the storage of separate datasets based on the independent variables of interest derived from this single recording session. An example would be if one is testing differences in responses to different sinusoidal wave frequencies within an experimental paradigm, we would recommend saving different parameters into different wave files for separate analysis, such as WT_1_Freq0.1Analysis, WT_1_Freq0.2Analysis, and WT_1_Freq0.3Analysis. In the current version, once epochs are analyzed, there is no functionality for selecting individual epoch values within the dataset, though this could be added in the future if necessary.
Finally, our method is adaptable to multiple video-oculography collection methods and provides a robust analysis platform that can be easily tailored to a laboratory's specific needs. Through analysis of wild-type and existing mutant OKR data, and also wild-type OKR data collected using different methods and stimuli, we show here that our analysis tool is capable of a) quantifying OKR tracking from any directional stimulus with high accuracy and throughput; b) identifying visual system behavioral differences resulting from genetic perturbation; and c) assessing visual tracking data from different video-oculography methods. The accessibility and general adaptability of our analysis platform facilitate further study of OKR responses and will enhance behavioral studies that characterize neural circuit assembly and dynamics in the context of oculomotor responses.
To obtain accurate measurements and subsequent useful data analyses, several steps are necessary for data collection. We recommend collecting OKR data over multiple sessions to allow the animal to acclimate to the behavioral testing apparatus and reduce the impact of animal stress on behavioral responses; however, excessive recording may lead to potentiation of the OKR response13, so care in designing testing regimes is recommended. During OKR data collection, proper calibration of the video-oculography equipment is critical for accurate quantification since the quality of analyzed data is a direct function of the processed trace. Importantly, the use of the Spyder IDE is necessary for graph supervision through Matplotlib. Given the accessibility and framework design of our platform, all the necessary tools are available for others to expand the software's capabilities and tailor this platform for distinct behavioral experimental paradigms.
In conclusion, we describe here a new, accessible, and versatile tool for the analysis of OKR behavioral responses in more depth and with more quantitative power than is currently available using existing methodologies. PyOKR can be easily used by novice Python users and contains an established analysis pipeline and interface for the rapid and accurate analysis of OKR waves with increased rigor and reproducibility. The adaptability of this software provides a flexible framework that users can easily tailor to fit their specific needs and data collection procedures. We anticipate that this quantitative method will advance the study of oculomotor responses and further our understanding of the development and function of the neural circuitry that drives visual system behaviors.
The authors have nothing to disclose.
This work was supported by R01 EY032095 (ALK), VSTP pre-doctoral fellowship 5T32 EY7143-27 (JK), F31 EY-033225 (SCH), R01 EY035028 (FAD and ALK) and R01 EY-029772 (FAD).
C57BL/6J mice | Jackson Labs | 664 | |
Igor Pro | WaveMetrics | RRID: SCR_000325 | |
MATLAB | MathWorks | RRID: SCR_001622 | |
Optokinetic reflex recording chamber – JHUSOM | Custom-built | N/A | As described in Al-Khindi et al.(2022)9 and Kodama et al. (2016)13 |
Optokinetic reflex recording chamber – UCSF | Custom-built | N/A | As described in Harris and Dunn, 201510 |
Python | Python Software Foundation | RRID: SCR_008394 | |
Tbx5 flox/+ mice | Gift from B. Bruneau | N/A | As described in Al-Khindi et al.(2022)9 |
Tg(Pcdh9-cre)NP276Gsat/Mmucd | MMRRC | MMRRC Stock # 036084-UCD; RRID: MMRRC_036084-UCD |