Month: October 2016

Sub-pixel alignment in bidirectional scanning mode

When imaging at low magnification in bidirectional mode cells can be small, with a diameter of ~6 pixels or so.  In this and other situations the mechanism offer by the ncolbi variable to align even and odd lines may prove too coarse for optimal alignment.

We added a new variable to the configuration file, named bishift, that allows for sub-pixel alignment.  Like ncolbi, this array contains one entry per magnification factor.  At the beginning of your calibration set all the entries in bishift to zero and follow the same procedure as described earlier to find the best ncolbi possible.

The bishift variable allows for sub-pixel shifts only in one direction.  Thus, to use it, we need to begin with the images slightly misaligned in the opposite direction.

As an example, assume that you determined that for magnification factor of 1, the best ncolbi(1) value was 1264. Select a new value by reducing this number by 2, in this case it will result will be 1262.  Now, when you look at the images they will be misaligned, but you can start increasing the value of bishift (which is a non-negative, integer number), to bring them into alignment.

The example below shows zoomed images of a single pollen grain after this misalignment (top left) and increasing values of bishift(1), from 0 to 15. A setting of bishift equal to 7 brings the lines into optimal alignment with sub-pixel accuracy. You can repeat the procedure for each magnification factor.

subpixel

A change of 4 in bishift is equivalent to a change of 1 unit in ncolbi.  So, you can see that if we are caught in a situation similar to the panel 5 below, where the images are only slightly misaligned, a change in ncolbi by 1 unit will bring it to the situation in panel 9, which is also slightly misaligned but in the opposite direction.  The addition of bishift now allows for finer control.

Perform your calibration of ncolbi/bishift while the mirror is in continuous resonant mode and has been running for at least 5-10 min, to allow the frequency to stabilize.

There is no need to restart Scanbox to change the ncolbi and bishift variables.  To have access to these variables while Scanbox is running simply define a global sbconfig variable in Matlab’s command window and you can now change their values between acquisition runs.

We will soon be modifying the sbautocalbd function to make use of both ncolbi and bishift.

Here is one more example at higher magnification (x4) of a pollen grain:

subpixel_highmag

 

Important enhancements in Scanbox 3.3 firmware

Good news!

The latest Scanbox version in Github includes a few important improvements and fixes:

  1. The new firmware substantially decreases line jitter producing even shaper images.
  2. It removes the artifactual horizontal lines from the mean of bidirectional scanning acquisitions.
  3. It fixes a bug in the phase of the camera trigger signal.
  4. It checks for cases where no cameras are present (which produced an error on startup before).
  5. It fixes a bug where the objective moved by a small amount (~10′ of arc) after being zeroed.
  6. It increases the velocities of the x/y stages in Knobby’s velocity mode.

Scanbox firmware must be updated to run this release.  There are no changes to the Motor Box or Knobby firmware.

As always, remember to keep a copy of your latest version.

goodnews

Latest Scanbox Release brings cool performance improvements

The latest Scanbox release brings a major performance improvement.  The main bottleneck in the acquisition loop consists of a function that re-arranges the incoming pixel stream into the images that are displayed and stored in real-time. This function now makes use of OpenMP to distribute the work among different physical cores available in your machine and thereby improving the performance in your machine.

Performance improvements should be reflected in your ability to scan at higher rates in both unidirectional and bidirectional modes without running into a buffer overflow fatal message.

The number of cores used in unidirectional and bidirectional modes are variables in the scanbox_config file.  By default they are both set to the actual number of physical cores in your machine:

sbconfig.phys_cores = uint16(feature('numCores')); % total number of physical cores
sbconfig.cores_uni = sbconfig.phys_cores; % number of cores in unidirectional scanning
sbconfig.cores_bi = sbconfig.phys_cores; % number of cores in bidirectional scanning

A second major change is the addition of more options for magnification, which now default to factors ranging from 1 to 16 in logarithmic steps, 4 steps per octave. Needless to say, be sure to reduce your laser power setting when using magnifications larger than 4.

magfactors

These settings can be changed in the configuration file by means of two variables:

sbconfig.gain_galvo = logspace(log10(1),log10(16),13); % more options now!
sbconfig.gain_resonant = 1.4286 * sbconfig.gain_galvo;

If you want to customize your settings, please follow the instructions here.

The latest release requires the update of the firmware, which you can do by following the second part of the post here.

There are two associated variables, nroi_auto_size and ncolbi that need to be changed so they include entries for all of the magnification settings.

Finally, the PMT gain control panel has been simplified by removing the enable checkbox and zero gain button, as their behavior was causing some confusion. The behavior now is as follows.  If the microscope is not scanning the PMT gains are always zero.  Only when the microscope is scanning the PMT sliders are enabled and the PMT gains are dictated by their values.  Moreover, upon initialization and shutdown Scanbox enforces gains to be zero — as a defensive mechanism.

Note: Please save the latest working version of your Scanbox software so you can go back to it in case you run into any issues with this new distribution.  Also, please note that Scanbox no longer supports the 3D mouse. You have to use Knobby from now on.  Finally, make sure you install Visual C++ Redistributable 2015 which is required for this update as well.