z-stack

Automatic Control of Laser Power

A new checkbox within the Laser panel (labeled AGC) allows you to turn an automatic control of laser power on and off.

When AGC is on, Scanbox checks the distribution of pixel values on the image every T seconds, and increases or decreases the laser power by a certain factor if the fraction of pixels above a threshold is outside the desired range.

The values of these parameters are found in a new section of the sbconfig.m file:

% Laser AGC
sbconfig.agc_period = 1;            % adjust power every T seconds
sbconfig.agc_factor = [0.93 1.08];  % factor to change laser power down or up if outside prctile bounds
sbconfig.agc_prctile = [1e-5 1e-3]; % bounds on percent pixels saturated wanted
sbconfig.agc_threshold = 250;       % threshold above which is considered saturated (255 is max value)

 

Below is a video showing AGC in action.

At the beginning of the video,  I focus on pollen grains using low power. When the AGC is turned on, it brings the power up. Then, if I increase the PMT gain, the laser power is decreased in response.  If the laser power is changed manually, AGC will re-adjust it to bring the pixel distribution within the desired limits.

 

AGC of laser power is useful when running a z-stack with a range that is larger than 100um or so.  In that case, engaging AGC will make Scanbox adjust laser power as a function of depth. Another situation where AGC may be useful is while running very long experiments/sessions where water may evaporate slowly leading to a reduction of the signal. In that case, turning AGC would compensate and could render the data usable.

 

Automatic Optotune Calibration

We previously explained how to calibrate the optotune manually.  With the introduction of Knobby 2, we are able to make this process automatic.  You will now find a ‘Calibration’ button in the Optotune panel.  To use it, do the following:

  1. Set the optotune slider to its lowest value (slide all the way down)
  2. Bring some pollen grains into focus
  3. Stop focusing
  4. Make sure the data directory has a directory named xx0
  5. Click the ‘Calibrate’ button
  6. Sit back and relax.  Wait for the process to complete.

Knobby will run some z-stack acquisitions for different values of the optotune current setting.  The volumetric data will be used to calculate the shift in z at various values of the current. A panel will display the progress in processing the images (it takes about 2 min). Scanbox will then plot the raw data and a fit by a quadratic polynomial, which may look something like this:

opto_calib

Scanbox will write a calibration file which will take effect next time you start Scanbox.

After restarting Scanbox, you can check the calibration as follows:

  1. Set the optotune slider to its lowest value (slide all the way down)
  2. Set Knobby to super-fine mode
  3. Focus on some pollen grains
  4. Zero Knobby (XYZ)
  5. Move out-of-focus by moving the optotune slider up to some value
  6. Now bring sample back into focus using the z-axis knob
  7. Compare the reading of the z-axis in Knobby’s screen with the depth noted in the optotune panel. These two numbers should match very closely.

 

Spatial Calibration and return to origin

We added two new features to the knobby scheduler panel, as shown below by the arrows.

knobby2nf

One (left arrow) allows knobby to perform an automatic spatial calibration of the system, measuring the (x,y) size of pixels at all magnifications.  To perform this calculation do the following:

  1. Focus on some pollen grains.  Make sure one of the pollen grains is well centered on the screen at the highest magnification (x8).
  2. Make you there is an empty folder named xx0 in the data directory you selected.
  3. Hit the calibration button (pointed by the left arrow).
  4. The system will ask you if you want to proceed.
  5. Scanbox will then loop over all magnifications, collecting data for 8 sec and moving the sample by a known distance.
  6. When it finishes, Scanbox will display the optimal value of a resonant gain magnification variable that will make your pixels square.  Note that value.

Now, when you restart Scanbox the system will read the new spatial calibration in the calibration button.  The format is [xsize ysize] [xfov yfov].  The left pair shows the width and height of a pixel (in micrometers), and the right pair shows the width and height of the field-of-view at the current magnification setting (also in micrometers).  In the example above, the (x,y) size is [0.72 0.70] um, meaning the aspect ratio is close to one.

If the aspect ratio is far from one, and you prefer square pixels, do the following:

  1. Change the value of the “gain_resonant_mult” variable in the configuration file to the one suggested by the Scanbox spatial calibration, restart Scanbox.
  2. Re-run the spatial calibration.  Thi will create a new calibration file.
  3. Restart Scanbox to read the newly created calibration file.  Now the aspect ratio should be close to one.

The second feature is one is a checkbox labeled Return. When you run a knobby schedule you have click this box to make knobby return to the initial position it started from. So, for example, upon completion of a z-stack the system will go back to where it started. Note: this feature uses the Store/Recall C function, so if you have anything stored there it will be erased.

 

 

Knobby improvements

We have added a couple of new features to Knobby based on user feedback that some may find useful. These features are presented in different screen pages. You can switch between the three available pages by touching one of the 3 gray disks on the bottom left of the screen.

knobby_v3

The first screen is the familiar position control screen. Here, changes in the position of the dials are interpreted as commands to change the positions of the axes by a certain distance. Use this window to navigate small distances (millimeters) around your sample.

When you need to move long distances (centimeters) between experiments, you can now use the velocity control mode in the second screen (instead of trying to move fast by spinning the knobs quickly). In velocity control mode you can move each of the axes while touching the + or – signs on the screen. The movement will continue at a fixed speed until you stop touching the screen. Velocity control is similar to what is achieved with the 3D mouse.

Warning: The microscope moves very fast in this mode, so make sure you know which direction you are moving and verify that there are no obstacles that will impede the movement. In this mode the knobs are disabled.

The third screen is the z-stack control, which allows knobby to automatically step and cover a given depth, in a given number of steps, while stepping a given number of microscope frames. This allows for an efficient collection of z-stack imagery without starting/stopping the microscope.

For Knobby to have access to the microscope frame timing you need to connect the left SMA connector (the one closer to the screen) to the CAM0 trigger output of Scanbox. The parameter values can be changed by moving the X (range), Y (steps), Z (frames) and A (arm/disarm) knobs.  The variable range represents the total travel length you want the z-stack to cover (values can be positive or negative).  The variable steps represents the total number of slices in the z-stack.  For example, if range = 100um and steps = 11, then the spacing between slices is 10um. Finally, the variable frames represents how many frames the microscope will acquire per slice.

After the parameters are set and z-stack armed, switch back to position mode before imaging. To have the best possible resolution set the position step size to S-Fine. If the objective is rotated away from vertical you can choose normal or rotated mode to decide how to move.  In rotated mode the steps will be along the axis of the objective. Now start imaging. You will notice that Knobby will automatically as selected by the parameter values.  During scanning Knobby will display changes in Z (or X and Z in rotated mode), stop once the range has been covered, and disarm automatically. You can use this feature to acquire z-stacks if you have a need to cover a range larger than what you can achieve with the optotune alone.

Here is an example of a z-stack acquired with knobby with 81 planes at 5 um separation:

To use the latest features just update the software and the knobby firmware.

Play with these options and familiarize yourself with their use before using them in an actual experiment. Let us know if you have any questions.