Month: December 2016

Surface sampling in Scanbox

Answering a request from colleagues in London, the upcoming version of the Scanbox firmware will allow users to change the depth of imaging on a line-by-line basis.

Up to now, during volumetric imaging, users were allowed to change the setting of the electronically tunable lens (ETL) once per frame (during the transition from one frame to another).

The new version offers the possibility of changing the depth (z) as a function of the line number (y).  For example, the image of a pollen grain below, was obtained using a sinusoidal modulation in depth.

capture-1

There are at least two potential uses for this new feature.

First, one can increase the yield of imaged cells by first measuring a z-stack and then designing a (smooth) sampling surface z = f(y) that maximizes the number of cells that can be imaged.

For example, assume the projection of cell bodies within the volume is given by the scatter-plot below. Then sampling with the solid curve line will yield many more cells (red circles) than sampling with any horizontal plane (such as the dashed horizontal lines).

sampling

I will explain how to calculate an optimal (smooth) function of depth that maximizes the number of cells sampled in a separate post (the algorithm is too large to fit in the margin here.) [Actually, I added it below].

The surface sampling method offers a compromise between random access and volumetric imaging across planes, many of which may not contain many cells, thereby reducing the temporal resolution unnecessarily.  Have any groups done something like this before?

The second use of this new feature is that it can allow us to correct for the ringing in ETL focal plane that results from a step change.

If you have been doing volumetric imaging, where N frames are sampled at each depth, you might have realized that a few of the lines at the top of the frame on the first frame after a depth transition is screwy.  This is due to the ringing of the ETL. One can potentially use the ability to change ETL command on the fly to compensate for this ringing.

I have not yet implemented this.  Are there any Scanbox users doing volumetric imaging that are willing to help?

Algorithm: 

Given a set of cell body projections (y_i, z_i) we want to find a smooth function z=f(y) that intersects as many cell bodies as  possible.

We do this by restricting z(y) to be sum of the first N harmonics, z(y) =a_0+\sum_{k=1}^N a_k \cos ( 2 \pi k y + \phi_k ), so it is both smooth and periodic as well, which will prevent ringing in the ETL during fly back to the first line. The function has 2N+1 parameters.  For simplicity, here we normalize the total number of lines in the frame is normalized to be in the range [0,2 \pi].

Given a set of parameters, denote by d_i the minimum distance between the location of cell i and any of the points on the curve z(y). Our objective function is J= \sum_{k=1}^M \tanh ( (d_i - r_0)  \beta ).  Here, r_0 represents the average radius of a cell and \beta controls the sharpness of the error function near that boundary, M is the total number of cells in the volume. For a give sent of points, we used Matlab’s fminsearch to find the optimal parameters for the curve.

How much improvement in yield can we expect using surface sampling versus just one plane?

We ran a few simulations where the number of points is uniformly distributed within the volume and calculated the fraction of cells we can intersect as a function of the number of harmonics used. Zero harmonics means just the horizontal plane that intersects the maximum number of cells.yield  The graph on the left shows the results.

Even in the simple case of a uniform distribution one can more than double the yield expected from a single plane by having a few (~5-6) harmonics. In other words, using surface sampling we can double the number of cells with respect to a horizontal plane without any penalty in temporal resolution.  Not bad at all.

We will re-do this analysis with some actual volumetric data from our Lab soon. I suspect this estimate represents a lower bound on what can actually be achieved.

 

Disabling Knobby’s automatic reset

[Note: please do not use this feature yet — there are some bugs that need to be worked out. I will keep you posted.]

Up to now starting a new Scanbox session from Matlab causes knobby will auto-reset, bringing all the position counters back to zero and clearing all its position memories. This is done because there is no way for Scanbox to know if the microscope stages were moved manually from its last position (there are no absolute encoders), or if the motor box was powered off, since its last session.

Some users have asked for the option of not resetting Knobby between Scanbox sessions under the assumption that neither the stages nor the motor box have experienced  any changes between runs.  This would preserve the position counters and memories.

You can now obtain this behavior by using the knobbyreset configuration variable in the scanbox_config.m file.  Setting the variable to one will force automatic reset when starting a new Scanbox session (the default behavior up to now); a value of zero will disable the automatic reset.

The feature is now in beta testing so users should make sure everything works as expected before running new experiments with this feature turned on.  Try storing and retrieving memories across sessions, zeroing, and so on.  If you see inconsistent behavior across sessions let me know.

You can use this feature only with the wired version of knobby.  Knobby tablet does not yet support this feature.

 

New Features in Scanbox 3.4

The latest release adds a few new features and fixes.

A new panel called “Deadband & Alignment” offers the option to change some of the configuration variables on the fly.

dbalign

The deadband sliders allow to dynamically change the size of the left and right margins respectively, where the laser is blanked out.  You can optionally click the save button to save the settings at the end of the configuration file for future use.

Within this panel there is also the option of adjusting the alignment of even/odd lines during bidirectional scanning on the fly.  To use this first make sure the resfreq and lasfreq configuration variables are set to the correct values of the resonant and laser frequencies.

Typically the resonant frequency will be around 7930Hz, while the laser frequency, measured at 920nm wavelength, will be slightly over 80MHz.  Try to measure these values are accurately as possible.

The ncolbi configuration variable is now gone from this and any future versions. Only bishift is used at each magnification to adjust the line alignment, which can now be positive or negative.

To calibrate, pick a magnification, set the scope in continuous resonant mode for a few minutes, and start scanning.  You can now dynamically adjust the alignment by clicking on the << and >> buttons.  Using pollen grains is ideal for this step.

To have a closer look at the alignment you can digitally zoom into some features of the image by clicking Zoom in the navigation panel and then zooming into the region of interest.

The adjustment will look something like this:

Once satisfied with the adjustment you can stop scanning, move to another zoom setting, and repeat the process.  At any point you can hit the Save button to the right.  This will append a line with the new bishift settings to the end of the configuration file (effectively overriding the previous setting).

In the previous release a rounding bug caused some pixels to appear displaced in the image during bidirectional scanning.  This has now been fixed. The new version should allow you to get a very good results. Here is an example of a 40 LPMM Ronchi at a magnification of 1 and digitally zooming in to see details:

ub0

Zooming in…

ub1

And zooming in…

ub2

And zooming in again (you can click on the images to get them in full size):

u3

If you have trouble with bidirectional alignment let me know.

Make sure the HSYNC signal is symmetric and approximately in-phase before starting the calibration process as described in the first section here.

Note: you should not change magnifications on the fly during bidirectional scanning. You need to stop the scope, change magnification, and start scanning again.  The next version will allow you to do this.

Another feature in the new version is the ability to change the warm up time for the resonant mirror.  This is the time the resonant is turned on before the scan begins.  The default is 500 ms but can be changed with the wdelay configuration variable, which dictates the delay in units of tens of msec (so 50 = 500 ms).

Finally, you will see some new controls under the Laser panel.  These are additional controls to control the Coherent Discovery laser.  They provide control of the shutter for the fixed laser and the GDD slider for the pre-compensator.  To enable these controls the laser_type should be set to ‘DISCOVERY’ — otherwise they will be grayed out.