Hardware

Intrinsic & epi-fluorescence imaging using the port camera

Some colleagues have asked about the possibility of integrating imaging acquisition from the port camera to do intrinsic and/or epi-fluorescence imaging ahead of targeting a region of interest with two-photon experiments in Scanbox.

We have now added this option to Scanbox.

To use this  option you will need to wire the I2C port on the faceplate of Scanbox.  As nobody seems to be making use of I2c sensors we changed the functionality of these pins.

You will first need a camera with an output TTL signal that provides a rising edge on each frame. Most advanced cameras provide such an option.  That signal needs to be connected to pin #2 (second from the left).  We also need a synchronization signal from our visual stimulus, so we know on which frames it is presented.  A rising edge on pin #3 will be timestamped by the system with the frame number when it occurred.

That’s all you need in terms of hardware connections.

Now, you will find an extra line in the scanbox_config.m file that allows you to select the format you want to use for the port camera.  Some cameras have an 8-bit depth format that is convenient and sufficient if all you are using the camera for is to navigate around the sample. For imaging, you will probably want to use formats with pixel depths ranging from 12 to 16.  You can use Matlab’s imaqtool to see what formats are available for your camera.  Set the pathcamera_format variable to a string reflecting your selection.  For example:


sbconfig.pathcamera_format = 'Mono14';

In Scanbox, you will see a new panel which, at the moment, is sparsely populated with only 3 buttons, but should be enough to get things going.  Two buttons behave in the same way as for the eye and ball cameras: they allow you to define a ROI that will be saved.  The third button “Grab” allows you to manually start and stop the acquisition.  You can only use this button when the port camera is active. Otherwise, you will get a message complaining about it. When the port camera is active, sending a command to start and stop sampling will engage this button as well.  So the same experimental scripts you are now using for two-photon imaging can be used for imaging with the camera port without any change at all.

The data are stored in two separate files, one that contains the images themselves and the other containing the TTL data from the visual stimulation.  To read them, there are two separate functions: sbx_get_ttlevents() and sbx_read_camport_frame().

The first function takes the file name as input and simply returns a list of frame numbers during which a rising edge was present in the “stimulation” input on the I2C connector above.

So, for example:


>> ttl = sbx_get_ttlevents('xx0_111_222')'

ttl =

    200  240  280  320  360  400

This means the onset of six stimuli occurred during those frames.

The second function takes the file name and a vector of frame numbers.  It returns a volume of data where the third dimension corresponds to the selected frames.

So, for example:


>> data = sbx_read_camport_frame('xx0_111_222',ttl(1)-10:ttl(1)+10);

Will read the volume from ten frames before the onset of stimulus #1 to 10 frames after.

As things are now you have to control illumination externally.  We will work to integrate illumination and histograms of ROI values soon.

Sampling on a Surface

Not long ago I mentioned Scanbox’s new ability to sample on a surface. Now you can access this new feature in the GUI by navigating to the Surface Sampling panel.

Surface sampling allows you to link lines of the resonant scan to depths determined by the optotune setting.  In other words, it allows you to sample on a surface along the galvo axis (the vertical axis in Scanbox).  Of course, limits are imposed by the range of the optotune and its dynamical response.

Below is an example of how the process works.  Here, I am imaging a slide of pollen grains that is tilted along the vertical axis.

Because the slide is tilted, different settings of the optotune bring the grains in different lines into focus, as shown at the beginning of the video.

To compensate for the tilt we can establish a link between lines in the scan and depth. To do this, change the optotune setting while focusing, then hit the Link button, and then click on the grains that are in focus.  In this example, I repeat this a handful (3) of times.

Now, when the Enable button is clicked, Scanbox interpolates a value of the optotune for each line given the established links and uploads the resulting values to the Scanbox firmware.  When we image the slide with the link active we see all the grains in focus. In other words, Scanbox is now sampling on a slanted surface and compensating for the tilt of the slide.

This is a useful feature to use when compensating for the curvature of a structure that is being imaged or tilting the imaging plane without physically tilting the objective.

Try it and let me know if you run into any problems.

The use of this feature requires an update of Scanbox and the firmware to version 4.0.

 

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.