10 CycleTargetDefocus

Example 10. CycleTargetDefocus


MacroName CycleTargetDefocus
#
# by Chen Xu, update @ 2014-10-21 12:12:55
#
# change Target Defocus on the fly
#
###########################################
# Note: need 3.5 beta 
###########################################

# define defocus up and down thresholds, and changing step
# set here or by calling Parameters
#TD_low = -1.2
#TD_high = -2.0
Call Parameters

step = 0.1

Echo ===> Running CycleTargetDefocus ...
Echo >>>> defined Range and Step (um)  => [ $TD_low, $TD_high ], [ $step ].

######### no editing below ###############
delta = -1 * $step

# if the current TargetDefocus is outside of range, make it as TD_low.
# Otherwise, increase a step of $delta

SuppressReports
ReportTargetDefocus 
If $reportedValue1 > $TD_low OR $reportedValue1 < $TD_high
   SetTargetDefocus $TD_low
Else 
   IncTargetDefocus $delta
Endif

ReportTargetDefocus 
Echo TargetDefocus = $reportedValue1 um

When we take many images for single particle application, we usually take them in slightly different defocus value, but within certain range. This macro is to be used right before Autofocus command in a macro. It checks current TargetDefocus value, if it is still inside the range, increases limit value. It cycles TargetDefocus on the fly.

I also took care of the case that current TargetDefocus as starting is not inside the range. In this case, I let it to be the middle of the range. Therefore, we don't need to care about what TargetDefocus set in the interface.