2 Macro Drift

Lets take a look at an example macro. The macro below was originally taken from SerialEM's helpfile. We modified it a little to suits our needs for single particle data collection.

Example 1. Drift.txt


MacroName Drift
####################################################################
# Drift.txt
# by Chen Xu at 10/11/2011
# Modified from the original code by David M
####################################################################
#
# A macro to measure drift rate, if good, skip to the end of loop. 
# Otherwise, exit execution -- i.e. skip the point.
# 

#=============
# parameters 
#=============
crit = 2
shot = F
interval = 15
times = 10

period = $interval + 1
#SuppressReports
ResetClock 

$shot
Delay $interval
Loop $times index
	$shot
	AlignTo B
	ReportAlignShift
	ClearAlignment
	dx = $reportedValue3
	dy = $reportedValue4
	dist = sqrt $dx * $dx + $dy * $dy
	rate = $dist / $period * 10	
	ReportClock
	echo Rate = $rate A/sec
	echo ----------------
  
if $rate < $crit
	echo Drift is low enough after shot $index      
	break
elseif  $index < $times
      	Delay $interval
else
      	echo Drift never got below $crit: Skipping ...
      	exit   
endif
EndLoop
      

In the above macro, we set threshold drifting rate as 2Å and measuring interval is 15 seconds.