Month: January 2015

Scanbox closes the loop with a quadrature encoder

If you have downloaded the latest version of Scanbox you may have noticed there is a new “Quadrature Encoder” panel and wondered what is does.

tracking_tools

In addition to ball tracking, you now have the option of tracking the 1D movement of a circular platform. The position of the platform is monitored by an optical quadrature encoder that relays the information back to Scanbox.  This allows for a trace of platform position to be displayed within the panel and saved along with the microscope data. Moreover, (and here is where the advantage over the ball is) the real-time position of the platform can be streamed to a second computer, which can use the information to control external stimuli in a closed-loop situation. Below is a simple demo, where the rotation of a square on the screen is controlled by the position of the platform.

The setup requires the use of a separate Arduino board and the code can be found within the quad/quad_encoder directory in the Scanbox distribution.  Let me know if you are interested in setting up something like this and I’ll walk you through the steps.

 

 

New features in latest Scanbox firmware

To take advantage of the new features in the latest release of the Yeti firmware you should start by getting rid of the half-wave plate control of the laser power. To do so start by removing the motor and half-wave plate from the optical path feeding the laser beam directly into the Pockels cell as shown in the picture below.  Make use of a detector card and/or power meter to check for alignment.
pockels

 

Make sure the Pockels cell is aligned so that there is minimum transmission when the reading in the front panel is zero.  The power of the laser in this new arrangement is controlled by a slider in the Chameleon panel, which provides control from 0% to 100% of the power.

powercontrol

The software takes into account the fact that at 920nm the relationship between power and control voltage is non-linear, so you should get an approximate linear control of the power using the slider.  This new feature provides for an absolute control of the power across experiments (as compared to the the relative position of the wave-plate in the original design).  You should also get increased power, as the new setup avoid loses via multiple reflections.

Using the new firmware you also have control over the size of the dead-band at the edges of the scanning.  A new variable in  the configuration file, sbconfig.deadband, can be changed by the user.  The two numbers of the vector reflect the size of the dead-band at the left and right margins of the scan in percent of the total number of samples before spatial correction.

The reason for this changes is that this new setup also allows the software to rapidly change the power, a feature that will be needed when the Optotune lens is incorporated for fast z-scanning in the near future.  If you plan to use the optotune, you should be upgrading to this new firmware as soon as possible.

Updating the firmware

The lastest firmware is located in the Scanbox/drivers/ subdirectory.

To update the driver start the Bootloader Host application (look under the Cypress Programs Folder).

Select the new Firmware file you want to upload (the one in the drivers/ directory), power cycle Scanbox to get it into boot loader mode.  Once you turn the box on you will have 20 sec to upload the new firmware (once the time elapses Scanbox will start running the existing firmware).

Select the USB Human Interface Device that will appear in the ports panel, and click the download button (the one highlighted in blue).

If everything works you will get a message that the firmware was successfully uploaded (it should take 3-4 seconds to complete).  Once the new software is uploaded Scanbox should be ready to use.

bootloader

If you have trouble with the  firmware updating process just let me know…

Note: You can download the PSoC suite from here but make sure you select “Custom” installation (instead of “Typical”) and select  the “bootloader host” only for installation (otherwise you will be installing the whole suite and it will take a very large amount of time/space).

 

Setting up the gige cameras

The following explains how to connect GigE cameras to your Scanbox.  If you have trouble following the instructions below just let me know — I can help remotely.

ScanBox has the ability to acquire images from cameras synchronized to the frames of the microscope.  We typically use one camera to monitor eye movements and  a second one to monitor the movement of the ball, but you can add more if you desire so long as your hardware can keep up with the data stream.

Any GigE camera supported by the Matlab image acquisition toolbox should work, but we have been using the Dalsa Genie series successfully.  In our current setup, we use an M640 camera for monitoring the ball and a M1280 to monitor the eye.

We have a dedicated Ethernet port for each camera, both set up with static (or persistent) IPs.  To begin, follow the instructions in the Genie manual to setup the persistent IP addresses for your NIC interface and card.  As an example, in our setup, one NIC has the IP 10.20.1.1 connected to a camera with 10.20.1.2 (mask 255.255.0.0), and the second pair has a NIC with 10.19.1.1 and a camera with 10.19.1.2 (mask 255.255.0.0).

Once you are done, start the Dalsa Network Configuration tool, and you should see both of your cameras show up in blue, as shown in the figure below.  If any of them appear in red, or do not appear at all, something is wrong.  You can find the Dalsa Configuration Tool can be found under All Programs -> DALSA -> Sapera Networking Package.

network_settting

 

If you get to this stage, you can test if the cameras are working within Matlab.  First, make sure you have the image acquisition toolbox.  You should have also downloaded the GigE Vision Hardware support package by following these instructions.  Restart Matlab after downloading the GigE support package.  Launch the image tool in matlab (by typing imaqtool in the Matlab console), and you should see both cameras listed on the top left.

imaqtool

 

If this is the case, you are ready to move to the next step.  Quit Matlab and launch the CamExpert and configure the cameras so that acquisition can be triggered.  This is done by settting the Trigger to True and Trigger Source to Input 2, as shown below:

trigger

After this configuration is set up, you should save it as “Camera Configuration 1” and make it the default configuration when the camera is powered up, by going to the Camera Information section on the left and clicking on Power-up config setting:

config

The final step is to let Matlab know which camera is which.  You do this by editing the configuration file and providing part of the name of the camera that will be in charge of eye and ball movement, as well as turning on the flags for the cameras you want to use.

camera_config

In this case,  the M640 will be used for the ball and the 1280 for the eye.  After editing the scanbox_config.m file you can start ScanBox and both camera boxes should be enabled.  (These fields will show up only if you are running the latest version of Yeti). If you hit the preview button you should be able to see a live feed of the corresponding camera. If both cameras work you, can proceed to the final test.

The final step is to make sure both cameras are working.  Select a ROI for both cameras by clicking the appropriate button and dragging the ROI to the desired location.  Check both of the ‘Enable’ boxes to tell ScanBox that you want to acquire data from the cameras.  Finally, collect 100 frames by setting the total frames field to 100 and hitting the grab button.  You should get two additional files — a *_ball.mat file and an * _eye.mat file.  These should have the imagery and the total number of entries should match the number of lines collected (they may contain an excess frames of 1 or 2 at the end that you may ignore.)

A note about the triggers sources: the rightmost connector on the ScanBox provides a trigger signal at the same frequency as the frames of the microscope.  We use it for the eye camera so we get an eye position at each frame.  The connector next to it provides a signal at twice the frequency; we use it to trigger the ball camera.

Happy tracking…