Hardware

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.

 

 

External TTL trigger

To automatically start /stop acquisition by means of an external TTL signal follow the following instructions.

First, connect an appropriate TTL control signal to the P1.6 (pin #21) of the extension header of the Scanbox board.  The view below shows a top view of the Scanbox control board.  The pin in question is located on the back row of connectors when viewing the board from the front.  As a ground pin, you can use pin #3.  To make it easier to make the appropriate connections it helps to get the this cable and route it outside the box.

Capture

StartCapture the Scanbox software and operate as usual by focusing and selecting the area you want to record.  When ready to switch to external trigger control, simply click the “External TTL Trigger” checkbox, which is located in the middle of the Scanner control panel.

After enabling the TTL trigger, the manual Focus/Grab buttons will be grayed out and blocked from usage.  If you want to go back to manual control simply deselect the TTL Trigger checkbox.

The rising edge of the TTL control signal is used to start/stop the microscope.  Minimum pulse width is 1 ms.

While controlling the microscope using an external TTL signal it is useful to run it in continuous resonant mode (so you avoid waiting for the resonant mirror to warm up) , and set the “autoinc” configuration variable to “true”, so file numbers increment automatically after the completion of each session.

To use this feature you have to update to the latest version of the firmware/software.

Update [6/23/17]:

If you are willing to give use of TTL1 as an event line, a new trig_sel configuration variable allows you to use it instead of the signal from the header to start and stop the acquisition.  You will have to upgrade to the latest version of the software.  Follow the instructions here.  You can skip the steps asking you to update knobby, the motor box, and run vc_redist.x64.exe.  After the update, simple set the trig_sel configuration variable to true if you want to trigger with TTL1 (or false if you want to trigger using the header signal).

Knobby scheduler

CaptureA new Scanbox panel allows users to define arbitrary changes in (x,y,z) position over time (frames) which are then executed by Knobby (version 2 only) while imaging.

Each entry define changes in x, y and z (in micrometers) relative to the present position and the frame number at which they will take place.

The “mem” column allows one to specify one of the stored absolute coordinates instead (memory locations are coded A=1, B=2, C=3).  If a memory location is defined the other entries are ignored and the position in the referenced memory is used instead.

This mechanism extends the z-stack functionality to include the ability to tile a sample and brings back the control window to one of the panels in Scanbox (as opposed to being controlled in Knobby’s screen).  The Knobby table is also saved in the info.knobby_table variable.

Paths can be computed offline and stored in a Matlab file that can be loaded.  The example below shows knobby moving the sample along a circular path.

Update [ 7/3/17]: You will now note an additional checkbox in the Knobby Scheduler panel called “Return”. When you arm knobby scheduler and check this box the microscope will automatically return to the initial position after imaging is done.  This feature uses the Store/Recall C function for functionality.  Anything stored previously in C is going to be erased if you use this feature.

Bada boom! New system coming soon!

So why the long silence in the Scanbox blog?

We have been working hard on a the development of our new system. A modular, expandable system that will run the new line of Neurolabware microscopes (aka the Kraken microscope) and is backward compatible with our previous box.

Want a sneak peak?

Bada boom!

 

nlw-full-tower

Here is a closeup of some of the LCD/power modules…

nlw-lcd-module

nlw-pwr-open

If you are interested in the new features of the Kraken microscope and the new modular system please get in touch with Neurolabware.

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.

 

Installing knobby tablet

Before you start you will need an android tablet and a wireless router in the Lab.

I have a Samsung Galaxy Tab E and an Airport Express, but other tablets and routers should work as well.

To install knobby tablet follow the following steps:

  1. Download knobby tablet from the Google Play store.
  2. Download and install the latest version of Scanbox (as always keep a copy of previous version).
  3. Download and install PyOSC.  To install, open a terminal, go to the directory where you uncompressed PyOSC, and type “python setup.py install”.
  4. Copy over the settings in the scanbox_config.m file.
  5. Connect the computer running Scanbox to your local wireless router
  6. Open a terminal window and check the IP assigned to the computer by typing ifconfig.
  7. Set the tri_knob configuration variable in scanbox_config.m to a string that contains the IP address, for example, ‘164.34.123.31’.
  8. Start Scanbox.  You should also get a command window with the knobby tablet console.  We will check if commands from the tablet are received there.
  9. Open knobby tablet on your Android.  You will likely get a message saying that the default IP is invalid.  Click Ok.
  10. Click on the IP number button.  A keyboard will show up.  Enter the IP number you found above.  However, make sure that every section has 3 digits (use zeros if necessary).  Thus, in the example above, one would type 164.034.123.031
  11. If the tablet cannot connect, you will see an “Invalid IP” message.  Otherwise, you should be ready to go.  The IP gets stored in the tablet, so launching knobby tablet later will retrieve it.
  12. Remove the objective from the microscope (just in case).
  13. Make sure the scope is roughly in the middle of its travel for all axes.
  14. Click the “Normal” button on the tablet.  Do you see a message printed on the knobby console?  If so, communication is working Ok.  If not, something is wrong.  Contact me.
  15. Stand close to the motor box so you can quickly power it off if something does not work as expected.
  16.  Now touch the button corresponding to the Z axis on the red region.  The z-axis will begin to move so long as you keep touching it.  The speed of movement will be faster the farther away you are from the center.  Slide your finger left and right, the speed will change and it should reverse if you move over to the blue side.
  17. Test the other axes.screenshot_20161112-150708
  18. Touch “Velocity” to switch to velocity mode.
  19. Warning: the microscope will move fast now…  Touch the red or blue areas of each button.  The microscope will move at a fast/fixed speed so long as you keep touching the area.  It will stop when you release.
  20. Store/Recall buttons work as before
  21. Go back and try the Fine and Super-Fine modes.
  22. Play with it for a while and install the objective back after you familiarize yourself with the tablet interface and everything seems to be working Ok.
  23. You can minimize the knobby console once testing is done (I will do this automatically in future versions).
  24. The green buttons on the side lock the button area (bottom) or knob area (top).  So if you are acquiring data and don’t want to have a situation where people touch the tablet by mistake and move the microscope you can use the buttons to lock them.  Touching them again will unlock.
  25. Make sure you open knobby on your tablet  after you start Scanbox.

If you run into problems don’t hesitate to write.