Bidirectional Z-scanning with Micro-manager and an ASI Z-stage

Conventional (unidirectional) Z-stack acquisition as compared with bidirectional Z-stack acquisition. In the conventional case, the time for the Z-stage to return to its starting position (the rescan time) limits how fast stacks can be acquired. In the bidirectional case, the stage is continuously moving, first up, then down, allowing continuous image acquisition.

Long time readers of this blog know that I’ve spent a lot of time working to make acquisition on our systems as fast as possible. Recently, I was approached with a request from Saul Kato, a new faculty member at UCSF, to go even faster. He wanted to be able to image neuronal activity in C. elegans at > 5 volumes per second.

What limits the acquisition speed of multiple volumes in Micro-manager is that it acquires Z-stacks unidirectionally and then has to return to the start position at the end of the Z-stack. This return time, also known as the retrace time, can actually add quite a bit of overhead (> 100 ms). In part, this overhead is to allow time for the piezo to return to its start position (I remember working with a Micro-manager version, many years ago, that didn’t allow enough time to return to the start, so all Z stacks after the first were missing the first plane or two). There is also some software overhead in this retrace time.

To eliminate this overhead, Saul and I set up bidirectional Z-scanning in Micro-manager. To avoid the rescan time, bidirectional Z-scanning first acquires one Z-stack ascending, followed by one descending. Because there are no large stage moves, the camera can acquire continuously during the entire process and so the overall acquisition rate is much faster.

We implemented this by taking advantage of the same trick in talking to the ASI stage that I’ve used before: Micro-manager allows you to communicate directly with the stage over the already open serial port from a script. Saul’s script then loads the ring buffer on the ASI stage with positions for both the ascending and descending Z stacks, and sets it so that camera triggers cause it to move from one plane to the next. With this set up, you just acquire a time lapse with as many frames as you want, and the Z-stacks are automatically acquired. You need to post-process the resulting stack to assemble the frames in the right order but the acquisition is very simple.

The script for doing this is on Github, as is one for turning off the bidirectional movement.