ScanImage 2018 : Automatic Scan Phase Compensation for Resonant Scanner Frequency Drift (In Progress)


The resonant frequency of the resonant scanner can change over time due to environmental and mechanical factors (heat, zoom factor, etc.) Two-photon lasers can also heat the resonant mirror which contributes to these changes.

Variation in Resonant Scanner Frequency

In ScanImage, variation in the Resonant Scanner Frequency may impact acquisition in the following ways:

  1. Missing frame triggers
  2. Increases or decreases in the field of view.
  3. Changes in bidirectional alignment in bidi mode.

For example, on a ScanImage system equipped with an 8kHz Cambridge Resonant Scanner, the resonant scanner frequency just 30 seconds after start of acquisition measures 7.9145kHz (126.35 us). After 5 minutes, the resonant scanner frequency was measured again and found to be 7.9176kHz (126.30 us) which is a change of -50ns, or -25ns per line in bidi mode. As detailed in the Scan Phase documentation, the minimum scan phase adjustment is one tick. The length of this tick depends on the digitizer sampling rate, but is either 12.5ns or 8.33ns. Therefore, a correction must be made to the scan phase of 2 or 3 ticks for the 80mHz and 120mHz digitizers, respectively.

Automatic Scan Phase Correction in ScanImage

ScanImage continuously monitors the resonant frequency and adjusts the scan phase accordingly. Because the monitoring and adjustment are performed on the FPGA, ScanImage can react to very quick changes in the resonant frequency. This is especially relevant for high zoom levels, since the resonant frequency is less stable at a smaller resonant scanner amplitude.


The user must have correctly set the bidirectional scan phase at the frequency measured at a particular zoom level. This feature will not work properly if the user has not set the bidirectional scan phase properly beforehand.


This feature is not intended to automatically set the bidirectional scan phase. The feature is only intended to correct for drift of the scan phase that occurs due to variations in the resonant scanner frequency.


The scan phase drift compensation happens transparently to the user (i.e. there is no indicator in the ScanImage GUI showing the applied adjustment). However, the applied correction value can be directly queried from the FPGA:


The return value is in units of FPGA ticks, where the duration of one tick is the reciprocal value of the digitizer sample rate. To deactivate the automatic scan phase drift adjustment, set

hSI.hScan2D.hAcq.hFpga.AutoAdjustTriggerHoldOff = false;