SerialEM HowTo: Align to Hole

Chen Xu

$BrandeisEM: ~emdoc-xml/en_US.ISO8859-1/articles/SerialEM-howto:align-to-hole/article.xml 1 2014-10-03 09:28:11 xuchen Exp$

This is almost a frequently asked question: can SerialEM use a hole template to align the position to each hole center, just like Leginon?

Well, as with current version, beta or release, SerialEM hasn't implemented hole searching as Leginon and EPU. However, with one of the most important functions autoalign, using a hole template to help positioning each hole to the center is a very easy job.

In this document, I try to show you how to do it using macros of SerialEM. It demonstrates how powerful and flexible the macro can provide.

You can also get pdf version of this document here.


Table of Contents
1 The Background
2 Macro AlignToP
3 Integrate macro AlignToP into main macro

1 The Background

First of all, SerialEM doesn't require specimen to have holes. As long as point items are added to a map, realign funtion will bring the the stage to each of the points, regardless the point is the middle of a hole or simply a spot on continous speimen such as continuous carbon film. Please refer to the SerialEM-howto:positioningXY for the details.

Certainly, if the specimen grid is holey based like Quantifoil or C-flat grid, one might just want the center of the holes to be targets. Therefore, one of the preparation tasks is then to add hole center as point items onto a map. There are a few ways to add point items. One is to quickly add a single or a group of holes by clicking on Add Points button on Navogator dialog window. The other ways it to add many point items by Draw Grid Point.

However, it might not be as easy as one hopes to make the point to the center of the holes VERY accurately. There are a couple reasons. The map may be at a relative low mag, so to click right in the middle of each hole can be quite some effort. And if the map is composed by a montage where there is stage position offset between montage pieces, the Draw Grid Point method can cause points being systematically off at different pieces. In those two cases, one might need to use a hole as template to refine the final hole position after realigning to the point item close to the hole.

The idea is simple. Take a centered hole using sub-area of a camera and save it to a buffer as reference. After realign procedure, align the center area at current stage location to the reference and move stage to the hole center.


2 Macro AlignToP

Lets take a look at an example macro.

Example 1. AlignToP.txt


MacroName AlignToP
#  
# a macro to align to an image in buffer P
# 
# 2014-10-05 01:54:26

## get unbinned camera size
CameraProperties
SIZE_X = $reportedValue1
SIZE_Y = $reportedValue2

## get image parameters in buffer P
ImageProperties P

X = $reportedValue1
Y = $reportedValue2
bin = $reportedValue3
E = $reportedValue4
PixelSize = $reportedValue5
S = $reportedValue6

# figure out from which set the image was taken
#(0=view, 1=focus, 2=trial, 3=record, 4=preview)
If $S == 0 OR $S == 5
   shot = View
Elseif $S == 1
   shot = Focus
Elseif $S == 2
   shot = Trial
Elseif $S == 3
   shot = Record
Elseif $S == 4
   shot = Preview
Endif

# unbinned image sizes
# need to special treat for super-res mode

If $bin == 0.5
   x_unbin = $X 
   y_unbin = $Y 
# the actual camera sizes are doubled of physical
# camera size reported for Super-Res mode of K2
   SIZE_X = $SIZE_X / $bin
   SIZE_Y = $SIZE_Y / $bin
Else
   x_unbin = $X * $bin
   y_unbin = $Y * $bin
Endif

l = $SIZE_X - $x_unbin
L = $l / 2
R = $L + $x_unbin
t = $SIZE_Y - $y_unbin
T = $t / 2
B = $T + $y_unbin

SetExposure $S $E
SetBinning $S $bin
SetCameraArea $S $L $R $T $B

## align
Loop 2
$shot
AlignTo P
ResetImageShift 
EndLoop 

# reset camera
RestoreCameraSet
      

This macro is to obtain all the camera parameters of the images in buffer P and temporarily uses these parameters to take the shot and align it to buffer P which is a centered hole as template. You don't have to worry about adjusting the camera parameters back and forth. This macro can be run as standalone.


3 Integrate macro AlignToP into main macro

To use the macro AlignToP, simply call it in the main macro after RealignToNavItem, as illustrated in the example below. In this case, an image of single hole is copied to buffer P.

Example 2. Call macro AlignToP

RealignToNavItem 1
Call AlignToP
  

You have probably realized, AlignToP can also used in more general way, it doesn't have to use a hole in buffer P. As long as buffer P contain a reference image, it will work. The following example shows it works very much like ZeroIS: dragging an image to a location and followed by running macro AlignToP will also bring stage to there.

You can regard this AlignToP as an advanced version of ZeroIS which is discussed in SerialEM-howto:positioningXY.

Example 3. Drag to a new position

Copy A P
Call AlignToP