SerialEM HowTo: Vary Defocus Value in Fly

Chen Xu

$BrandeisEM: ~emdoc-xml/en_US.ISO8859-1/articles/SerialEM-howto:change-target-defocus, 1 2013-02-11 02:31:56 xuchen Exp$

SerialEM is a powerful program for EM data collection. Although it is maybe originally designed for tomography data collection, it is equally powerful and flexible for single particle EM tasks.

One task that single particle user would like to do is to take images with slightly different defocus values, but within certain range. It would be better if this can be done without manually set for each image by user. In this document, I want to show you how to do this, automatically with SerialEM.

You can also get pdf version of this document here.

Table of Contents
1 The Task Description
2 Change Target Defocus using Macro

1 The Task Description

In single particle application, we take many images for the same sample. We wish to take them with defocus values in a certain range, but we like to have slightly different defocus values for CTF flattening purpose.

We can do it manually by setting to a different value to each shot. However, if we take images in automatic fashion, we would want to change the defocus value in fly.

2 Change Target Defocus using Macro

With SerialEM, the macro


will bring scope to the target defocus value which was pre-defined from Focus → Set Target. Runnig the command autofocus twice is perhaps needed if you want to get to the target defocus fairly close.

Luckily, SerialEM provides two macro commands that are target defocus related. They are IncTargetDefocus # and ReportTargetDefocus. Therefore, if we can set TargetDefocus value using those two commands, we are all set. Here is an example.

Example 1. CycleTargetDefocus.txt

MacroName CycleTargetDefocus
# by Chen Xu, modified @ 1/25/2013
# change Target Defocus in the fly
# define defocus up and down thresholds, and changing step
TD_low = -1.6
TD_high = -2.6
delta = 0.1

#==== no editing below ======
bigstep = $TD_low  - $TD_high 

# now check current TargetDefocus, if still in the range, increase
# or reset to TD_low by a bigstep up

TD = $reportedValue1

if $TD > $TD_low
   diff = $TD - $TD_low
   IncTargetDefocus -$diff
elseif $TD > $TD_high 
   IncTargetDefocus -$delta
   IncTargetDefocus $bigstep

Running this macro will cycle target defocus value between -1.6 and -2.6 μm with 0.1 μm as step size.

Thus, we only need to call this macro before running autofocus command in our macro, as below.

# change target defocus 
Call CycleTargetDefocus