ScanImage 2018 : Fast (X) Scan Optimization

Overview


As described above, the Acquisition Period portion of the X command signal consists of a linear ramp. To achieve optimal and correct imaging, it is required that:

  1. The physical scanner position ('response') must follow the ramp exactly for the duration of the Acquisition Period, save for some delay relative to the X command signal
  2. This delay must be known (in order to properly digitize the input signal(s))

Configuration


For both Sawtooth and Bidirectional modes, ScanImage requires three Configuration parameters be set to meet these requriments: Acquisition Delay, Scan Delay, and Fill Fraction. They are defined as follows:

  • Acquisition Delay: The delay (in microseconds) between the Acquisition Period of the X command signal and the (matching) physical scanner 'response'
  • Fill Fraction: The fraction of the X command signal Line Period ( True Ms/Line) occupied by the Acquisition Period portion of the signal.

    Icon

    This value determines how the Line Period ( True Ms/Line) value differs, if at all, from the specified Nominal Ms/Line value.

  • Scan Delay: The time (in microseconds) to 'extend' at the beginning of each Line Period the linear ramp of the X command signal Acquisition Period, allowing the physical scanner 'response' to be settled at the start of its matching (but delayed) Acquisition Period, following the Turnaround or Flyback time

 

Icon

The Scan Delay and Fill Fraction parameters affect the computation of the X command signal generated by ScanImage , whereas the Acq Delay does not affect the X command signal.

Icon

These parameters are referred to in ScanImage as the Live Scan Params, because they can be adjusted live while scanning in FOCUS mode

 

Their meanings are illustrated here:


Scan parameters used to configure and optimize the fast (X) dimension scan and data processing

 

Below, we discuss each of these further in turn – including their effects on the computation of the X command signal – and then discuss the Scan Param Array capability, which allows distinct values of these parameters to be stored as part of the ScanImage Configuration for different Zoom levels. Lastly, some practical tips are provided for optimizing these values in ScanImage.

Acquisition Delay


Bidirectional Scans

For Bidirectional scans, properly setting the Acquisition Delay is essential to correctly process the input data. As illustrated below, an incorrect setting of this value causes every-other-line to be misaligned in the image:


The correct value of acquisition delay must be set to correctly form an image when using bidirectional scans

Sawtooth Scans

For Sawtooth scans, the effect of setting the Acquisition Delay slightly incorrectly does not produce such a dramatic image artifact – this is the key advantage of Sawtooth scans. 
However, setting the value correctly remains important to ensure the acquired data is correctly aligned with the intended scan range and to avoid a 'reflected image' appearing on either side:


The correct value of acquisition delay must be set to properly align the image when using sawtooth scans

General Comments


Icon

At high scan speeds (low Nominal Ms/Line), the Acquisition Delay may be large enough so that data collected from one line 'wraps' to the next line period. ScanImage 3.6 can handle this situation, but Disable Image Striping must be selected. See [Input Data Processing|SI3.6_InputDigita must be disabled (see Advanced Configuration Options)

Icon

Fortunately, the Acquisition Delay is typically a robustly repeatable value for a given physical scanner system, so that it does not typically require frequent readjustment. Physical scanner considerations are discussed further below.

Icon

As its name implies, the Acquisition Delay only affects the processing of the input signal – it does not affect the X command signal

Fill Fraction (and True Ms/Line)


Formal Definition

Recall that the Acquisition Period – the period during which input data is processed – is defined as:

Acquisition Period = 0.8192 * Nominal Ms/Line

The value 0.8192 represents one of the available Fill Fraction values in ScanImage, which is defined formally as:

Fill Fraction Acquisition Period / True Ms/Line

The Fill Fraction value simply specifies the fraction of the Line Period ( True Ms/Line) occupied by the Acquisition Period.

Effect of Fill Fraction Selection

Rearranging the above, we obtain the following:

True Ms/Line = (0.8192 * Nominal Ms/Line/ Fill Fraction

We see therefore that the Fill Fraction determines how the True Ms/Line value differs, if at all, from the Nominal Ms/Line. The value 0.8192 is simply a reference value at which the True Ms/Line equals the user-configuredNominal Ms/Line. ScanImage allows selection among a list of possible Fill Fraction values.

(Increasing/decreasing) the Fill Fraction value away from 0.8192 directly (decreases/increases) the True Ms/Line value away from the Nominal Ms/Line value.

The value of Fill Fraction must practically be chosen to allow the physical scanner sufficient time for flyback/turnaround and to ensure the physical scanner 'response' is 'settled' by the start of the Acquisition Window.

Icon

The choices provided for the Fill Fraction correspond to fixed increments of time.

Icon

Adjusting the Fill Fraction therefore also adjusts the Frame Rate of the Configuration

Effect of Fill Fraction on X Command Signal

For Bidirectional scans, the Fill Fraction is sufficient (along with the Scan Amplitude X and Nominal Ms/Line) to compute the X command signal to generate. The linear ramp of the Acquisition Period is simply extended in duration – symmetrically about the Scan Range (2 * Scan Amplitude X ) scanned during this period – to reach the True Ms/Line.

Icon

ScanImage does not at this time use a 'shaped' (rounded) waveform during the turnaround time for Bidirectional scans

 

For Sawtooth scans, the Fill Fraction is not sufficient to fully specify the X command signal to be generated by ScanImage. Because of the command signal's asymmetry, an additional parameter – the Scan Delay – is required, as described below.

Scan Delay


A physical scanner requires time to 'settle' on the linear ramp of the Acquisition Period – i.e. there should be no discernible 'ripple' and the slope of the 'response' must match that of the X command signal – at the completion of the flyback or turnaround. To help achieve this, ScanImage extends the linear ramp prior to the Acquisition Period, at the start of each Line Period.

Bidirectional Scans

For Bidirectional scans, the X scan command outside of the Acquisition Period is determined wholly by the Fill Fraction, which extends the Acquisition Period ramp symmetrically to fill the Line Period ( True Ms/Line). Since half of this extension occurs prior to the Acquisition Period (and the other half after), the Scan Period is a read-only parameter computed simply as:

Icon

Scan Delay = True Ms/Line * (1 - Fill Fraction ) / 2


Sawtooth Scans

For Sawtooth scans, the Scan Delay is a user-specified parameter. It is specified as a time, occurring at the start of each Line Period, during which the X command signal follows the same linear slope which occurs during the Acquisition Period. The Scan Delay also implicitly specifies the amplitude by which the X command signal is extended beyond the Scan Range (2 * Scan Amplitude X ).

Icon

The X command signal slope during the Acqusition Period and the Scan Delay is simply: Scan Amplitude X / Nominal Ms/Line

 

ScanImage fills in the remainder of the Line Period ( True Ms/Line) outside of the Acquisition Period and the Scan Delay with the Flyback Time, using a smooth sinusoidal function.

Practical Procedures for Optimizing the Live Scan Params


The following practical procedures have been developed based on experiences in the developers' laboratories:

  • Initial Measurement of the Acquisition Delay
  • Optimization of Sawtooth scan parameters
  • Optimization of Bidirectional scan parameters

It is recommended to first measure the Acquisition Delay and then follow either or both of the scan parameter optimization procedures as required, depending on the type(s) of scanning to be used in actual experiments.

Icon

The optimization procedures determine the Fill Fraction and Scan Delay (if needed), as well as refine the Acquisition Delay.

The procedure provided for initially measuring the Acquisition Delay is the fastest and most reliable, but may not be possible or desirable for all users. If so, the procedure for optimizing Bidirectional scan parameters should be followed to determine the Acquisition Delay, even if Bidirectional scanning will not actually be used.

Repeat!

Icon
  • The optimization procedures for Sawtooth and Bidirectional scans should typically be repeated for every value of Nominal Ms/Line to be used – it is common to save a separate Configuration for each nominal scan speed used with a given scan type.
  • In addition, the optimal values can often vary with the Zoom values employed while imaging, so the optimization procedure often should repeated for several Zoom levels. ScanImage employs the Scan Param Array feature to allow the parameters to be stored at several Zoom levels as part of a single Configuration.
  • In contrast, the initial measurement (estimate) of the Acquisition Delay (whether obtained directly or by Bidirectional scan optimization), need only be done once, because the parameter is largely invariant for a given physical scanner system.
Icon

Some aspects of the procedures given in this section are quite general; some aspects may be somewhat specific to the physical scanner system(s) used in the developers' laboratories – (6210H and 6215H galvos combined with671xx servos from Cambridge Technology.

Initial Measurement of the Acquisition Delay


If your physical scanner system provides a feedback signal indicating the scanner's actual position in real-time (the 671xx and 673xx servos from Cambridge Technology provide a POS OUT signal), then measuring the Acquisition Delay is straightforward and should be done first, using an oscilloscope.

No Feedback Signal or No Oscilloscope?

Icon

It is not strictly necessary to measure the Acquisition Delay using an oscilloscope, but is the fastest and most robust means to measure the value, if practical. If your scanner system does not provide a position feedback signal or if arranging such an oscilloscope measurement is not practical, then it is recommended to follow the procedure given below for optimizing Bidirectional scans – even if you don't plan to use or save such a Configuration – as that is the next fastest/robust means for determining this value accurately.

The procedure is as follows:

  1. Operate the scanner at a low rate and observe (e.g. with an oscilloscope) the response and X command waveforms simultaneously (i.e., 'tee' off the X command output channel). If needed, adjust the scaling for the response waveform so that the slopes of the two waveforms, during the main ramp, are matched.
  2. Measure the time lag between the X command signal and the response, measuring during the main ramp (i.e. the Acquisition Period) of both signals, at some amplitude crossing both ramps (e.g. the zero-crossing).

This is illustrated here:


The acquisition delay can be estimated visually by viewing the X command and 'response' signals together

This time lag represents a good estimate of the Acquisition Delay that should be used for ScanImage Configurations. The value can later be refined during imaging tests as described below. 

Icon

The Acquisition Delay is a relatively invariant parameter of a physical scanner system, so the value measured is a good estimate for all the Configurations using the particular physical scanner. As such, this measurement can be done using either a Sawtooth or Bidirectional X command signal

Optimizing Sawtooth Scans


One Down, Two to Go

Icon

It is assumed in this section that the Acquisition Delay is already quite close to optimal, either by having measured the value directly as described above, or by following the procedure for optimizing bidirectional scans. That leaves only the Scan Delay and Fill Fraction left to optimize.

The procedure for optimizing Sawtooth scans is aimed at determining the proper Scan Delay and Fill Fraction values for the particular Line Period ( Nominal Ms/Line) and Zoom level being optimized.

Recall that the Scan Delay is intended to allow the physical scanner to settle on the intended linear ramp by the start of the Acquisition Period, i.e. all 'ripple' associated with the change in direction following the Flyback Time should have subsided. It is therefore natural to match this value to the small-angle settling time of the physical scanner system – a basic characteristic of any scanner system. If specified by the physical scanner manufacturer, it would be reasonable to simply set the Scan Delay to match this value.

Another approach, in many ways preferable, is to recognize that the small-angle settling time is related to the measured Acquisition Delay. In particular, it can be computed that the settling time is equal to (2 * Acquisition Delay*)*. Therefore, it is recommended as a starting point to simply employ the constraint:

Scan Delay = 2 * Acquisition Delay
Icon

This relationship was arrived at based on notes from and communications with Cambridge Technology. In addition, it has been confirmed by observations in the developers' laboratories, with the particular hardware. However, it is not offered in any way as a guarantee.

Icon

Note that in ScanImage, the Scan Delay is adjustable in larger increments than the Acquisition Delay, so the best approximation of this ideal relationship should be used.

Fill Fraction Adjustment


Following this, only one free parameter remains – the Fill Fraction. It is desirable to employ the highest value for Fill Fraction as supported by the physical scanner – this allows the greatest utilization of input signal as well as the highest Frame Rate. The Fill Fraction value can be optimized while live imaging, i.e. using FOCUS mode, as follows:

  1. Ensure the Nominal Ms/Line, Zoom, and Scan Amplitude X are set to the desired values to be configured.
  2. Select the lowest (or a known low) value of Fill Fraction.

    Icon

    For high scan speeds, the lower Fill Fraction values will not be allowed, as there is not sufficient time for the Scan Delay. Start with the lowest value permitted.

  3. Increase the Fill Fraction one step at time until a reflection of the image appears on the right side of the displayed image

    Icon

    It is helpful to move the specimen laterally (i.e. dither back-and-forth along the X axis) while viewing the image to help identify if there is an image 'reflection'

  4. Reduce the Fill Fraction one step back so the reflection disappears
  5. Reduce the Acquisition Delay slightly – the reflection should again appear on the right with only a small adjustment. After verifying this, increase the Acquisition Delay value until the reflection just disappears (i.e. only a fine step or two beyond this point).

 

Acquisition Delay Check

Icon

If the Acquisition Delay value must be reduced significantly to make the 'reflection' appear on the right side, then the initial Acquisition Delay adjustment should be rechecked, either with an oscilloscope or by following the Bidirectional scan optimization procedure below.

Physical Scanner Limits!

Icon

The procedure provided does not take into account Physical Scanner Limits such as current drive limits, servo rate limits, and thermal limits – limits on acceleration, velocity, and power, respectively. If a physical scanner limit is reached at a Fill Fraction below which a reflection is observed, then one should reduce the Fill Fraction one step from the physical scanner limit instead.

 

At this point, all three of the Live Scan Parameters have been set and the Configuration can be considered fairly optimized – the highest imaging speed has been achieved that should allow:

  1. The full scan specified by Scan Amplitude X and Zoom to be covered during the Acquisition Period, and
  2. No position 'ripple' to occur within the Acquisition Period

Going Further


In some circumstances, however, it may be possible to exceed the Fill Fraction obtained by the procedure given. The procedure described employs the minimum required Scan Delay given the known or determined small-angle settling time of the physical scanner system. Any additional available time at a given Fill Fraction is allocated to the Flyback Time. By maximizing the Flyback Time, the procedure employed has allowed the X command function to utilize the least acceleration/velocity for each Fill Fraction, has avoided reaching the physical scanner's systems limits (nonlinearities) to the greatest extent possible (including the possibility of exciting any dangerous resonances, etc, if the system is not well-safeguarded).

If the physical scanner can tolerate being more strongly driven, it can be advantageous to reduce the Flyback Time, by simply increasing the Scan Delay and repeating the procedure above to find the optimal Fill Fraction at the higherScan Delay value. As the Scan Delay is increased, it may be possible to reach a limit on the where the Flyback Time disappears entirely in the X command signal. Such an extreme command signal, and the response for a 6210H galvo/671xx servo from Cambridge Technology, is shown here:


The extreme-case of zero-flyback-time is used for the X command signal; the response from this system exhibits slew-rate limiting, but nonetheless achieves a faster settling than is achieved using a 'softer' X command signal (i.e. lower Scan Delay)

Of course, stretching the performance further in this fashion requires more attention and understanding of the Physical Scanner Limits. In particular, thermal limits become an increasing concern with such strongly driving Xcommand signals.

Optimizing Bidirectional Scans


For bidirectional scanning, the Scan Delay becomes a read-only parameter – the non-acquiring time specified by the Fill Fraction simply extends the linear ramp of the X command signal symmetrically (i.e. in both directions) about the Acquisition Period . Therefore only the Acquisition Delay and Fill Fraction need to be optimized at a given Nominal Ms/Line and Zoom level.

Final (or initial) Acquisition Delay measurement


First, the Acquisition Delay value should be refined (or measured for the first time, if not done already). The procedure is as follows:

  1. Select the lowest Fill Fraction value available
  2. Commence live imaging of a test specimen using FOCUS mode
  3. Set the Acquisition Delay to the initially measured value, if available.
  4. Adjust the Acquisition Delay value while live imaging, until the every-other-line artifact is minimized or eliminated. Use the Fine control to achieve the best correction.

The following tips and warnings should be noted:

(tick) For the fastest adjustment of Acquisition Delay, the options Blank Flyback and Staircase Cmd should be disabled temporarily (if they were in force). These options force the Y and Pockels command signals, respectively, to be recomputed following an Acqusisition Delay adjustment. With both options disabled, no command waveforms need to be updated when Acquisition Delay is changed, and scanning continues uninterrupted.

(warning) It is important to avoid any detector saturation from the test specimen image (as can occur when using bright test objects, such as fluorescent beads). With some photodetectors, or their associated electronics, saturation can have a lingering effect which will create a pronounced every-other-line saturation artifact. Accidentally attempting to compensate such an effect will lead to an incorrect determination of the Acquisition Delay.

(warning) If there is notable variation in the optimal Acquisition Delay between the center and edges of the test specimen image, then the Fill Fraction is too high. If this occurs at the lowest possible value, then it will not be possible to fully optimize scanning at the current Nominal Ms/Line value.

(tick) To visualize the image adjustment with the finest detail, it can be useful to use the Display Zoom SI3.6_ImageControls feature on the *IMAGE CONTROLS* panel. It may also be useful/required to increase thePixels/Line value above what will actually be configured.

(tick) The Acquisition Delay value determined at various Zoom or Nominal Ms/Line levels should not vary substantially. Any significant variation in the Acquisition Delay is an indication

Fill Fraction optimization


Following this, the Fill Fraction should be optimized by increasing the value one step at a time, slightly adjusting the Acquisition Delay at each level to minimize the every-other-line image artifact by employing live-imaging as above, until a desired level is achieved, or one of the following limits is reached:

  • A concrete Physical scanner limit is reached – i.e., current drive limit or thermal limit
  • Every-other-line artifact becomes unevenly corrected throughout the field-of-view – i.e. the optimal Acquisition Delay differs between the center and one or both edges of the field-of-view.

Icon

Translating test specimen back-and-forth can help to assess the relative image quality between the center and edges of the field-of-view

Icon

This is indicative of a physical scanner limit – either insufficient settling time prior to the Acquisition Period or a 'slew rate limit' preventing response from matching the X command signal slope through the Acquisition Period.

Scan Param Array


Ideally, the physical scanner system would be linear, so that changes to the amplitude of the X command signal would produce a completely proportional response of the physical scanner position. In reality, however, physical scanners have nonlinearities, so that the response is amplitude-dependent.

As a result, the optimal values for the Live Scan Params may vary for different scan amplitudes. To address this issue, ScanImage provides the capability to store multiple values for each of the parameters, associated with differentZoom levels. These multiple values are stored all together as part of the ScanImage Configuration.

The Scan Param Array refers to this set of multiple values for each parameters. The length of the array is user-set as the Constant @ Zoom >= value. Values for each of the Live Scan Params are stored for Zoom levels ranging from 1 to this value. At higher Zoom levels, the values stored at this level are used. 

Icon

Physical scanners become more and more linear in their response – and hence the optimal parameters become more invariant – as the command amplitude is decreased (i.e. the Zoom is increased).

During ScanImage operation, when the Zoom is altered – including during live scanning in FOCUS mode – the current values for each of the Live Scan Params are automatically updated according to the values stored in the Scan Param Array.

Icon

The most common use case of the Scan Param Array is to employ lower Fill Fraction values at lower Zoom values.

Icon

Typically variations, if any, of the Acquisition Delay for different Zoom values should be quite small.

Usage Example

Icon

A typical scenario is to set up a Configuration primarily intended for use at higher Zoom levels, above the configured Constant @ Zoom >= value, when used for data to be saved (either GRAB or LOOP modeacquisitions). Then the Fill Fraction – and hence the True Ms/Line and Frame Rate – will be constant at those Zoom levels. 

For FOCUS mode operation, however, it may be desired to operate at lower Zoom to help find regions to record/save from. The Fill Fraction can be set lower at these levels, as required for the particular physical scanner. The Zoom display in the *MAIN CONTROLS* panel is highlighted yellow when the level is below the Constant @ Zoom >= value, warning that the Live Scan Params have changed – in this case causing a lower Frame Rate.

Min Zoom


Because of physical scanner considerations – such as current drive limits, servo slew rate limits, or thermal limits – it is sometimes required or desired when configuring the fastest scans (smallest Nominal Ms/Line values), to prevent scans from occurring at Zoom levels below a specified level.

The Min Zoom level prevents the Zoom from reducing below the specified level for a given Configuration.

Icon

The same effect could be achieved by reducing the Scan Amplitude X for the given Configuration. However, it is common – though by no means required – to maintain the Scan Amplitude X constant across the Configurations maintained by a user. This ensures that particular Zoom levels correspond to consistent field-of-view sizes.