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.


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).

Verify the trigger!

You may encounter a situation where shortly after focusing and/or grabbing Scanbox quits and asks you to “verify the trigger”.  If this happens proceed as follows:

First, if  you hear the resonant mirror starting to work (meaning you hear the 8khz tone) when you press focus or grab, skip to the next step below.  Otherwise, make sure the connection from the resonant mirror to the controller is well seated. Also check the connectors to the resonant controller inside the Scanbox.  The resonant controller is the small square board that is mounted on top of the large Scanbox card.  Try scanning again.  If you still don’t hear the resonant mirror working, let us know.

Untitled 6.001

Second, assuming the resonant mirror works, there are two connections that you need to check that may cause this message to appear (see diagram above.)

The first connection runs form the laser SYNC OUT to the Alazartech External Clock input (via a microcircuits filter).  Verify by means of an oscilloscope that, when the laser is mode-locked, you see a clean sinusoidal signal at the input to the external clock with a peak-to-peak amplitude > 1.5V and a frequency equal to that of the laser (typically ~80MHz).

If you are using a Spectra Physics laser, you probably have a video amplifier in-between the output of the laser and the input to the Alazartech card.  Make sure the amplifier is powered and verify the amplitude of the signal. If the signal looks good then proceed to step #3.  Otherwise, let us know.

The second signal that must be checked originates from the Scanbox TRIG OUT SMA connector and must be connected to the external trigger (TRIG IN) input of the Alazartech card. Make the connectors are sitting properly and the cable is Ok.

If, after going through the above procedure, you still can’t get the microscope to trigger please contact us.

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 connected to a camera with (mask, and the second pair has a NIC with and a camera with (mask

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.



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.



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:


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:


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.


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…

Online trial averaging

It is often the case that you may want to do some quick on-line analyses on our data during the execution of an experiment.  Scanbox provides a quick way to save, at the end of each experiment, the mean image during each trial.  To use this feature do the following:
  1. Select “Accumulate” in the Image Display Panel
  2. Click the “TTL Ctrl” checkbox in the Image Display Panel
  3. Feed a TTL signal that is initially low and goes high during each stimulus trial to the AlazarTech 9440 X1 input.
  4. Start your experiment
The result will be the following:
  1. During the experiment itself the TTL Ctrl text next to the checkbox will be displayed in black when the signal is low and will be displayed in red when it is high.  You can use this feature to monitor your TTL signal. Such updates only occur when the microscope is running.
  2. At the end of the experiment there will be an additional file with _trials.mat appended at the end of the name in your data directory.
  3. The file contains two Matlab variables trials_n and trials_acc.  They are ordered sequentially by the trial #.
  4. trial_n(j) contains the number of frames that were accumulated during the j-th time the TTL pulse went high.
  5. trial_acc{j} contains the accumulated images during the j-th trial.
  6. The mean activity of the j-th trial will be trial_acc{j}/trial_n(j).
  7. If you want “blanks” you need to include them separately as trials themselves.

Happy online processing!