-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGrpDoseSymTomo.txt
294 lines (243 loc) · 6.57 KB
/
GrpDoseSymTomo.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
MacroName GrpDoseSymTomo
# Less conservative dose-symmetric tilt scheme for tomography
# Tilt, track-before, drift, autofocus, image, track-after.
# EMBL Heidelberg 2016, Wim J. H.Hagen
# Modified by Dustin Morado, 2018
# Modified by Grigory Sharov, Nov 2018
#
# Images:
# Track plus in buffer K
# Track min in buffer L
# Record plus in buffer M
# Record min in buffer N
# SerialEM settings:
# Roll buffers A -> H
########## SETTINGS ##########
step = 3 # tilt step
maxtilt = 60 # maximum +/- tilt angle
group = 2 # number of tilt steps per group
Tiltbacklash = -3 # negative tilts can be backlashed by this
TD_low = -2 # low defocus microns
TD_high = -4 # high defocus microns
delta = 0.25 # defocus step microns
driftcrit = 7 # max drift in Angstroms/s
drifttimes = 5 # N times to repeat drift measurement
debug = 0 # debug mode, do not suppress reports
########## END SETTINGS ##########
ProgramTimeStamps
echo Started macro GrpDoseSymTomo!
echo >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
if $debug == 0
SuppressReports
ErrorsToLog
NoMessageBoxOnError
endif
# Set limits on the absolute focus reached during autofocus runs.
AbsoluteFocusLimits -15 15
# Set limits on the focus change during autofocus.
#FocusChangeLimits -5 5
ReportMinuteTime
macrostarttime = $RepVal1
MoveToNavItem
# Creates a log for this tilt-series
ReportCurrentFilename 1
SaveLogOpenNew $ReportedValue1
ReportNavItem
echo Moved to: $navLabel X=$RepVal2, Y=$RepVal3, Z=$RepVal4
echo Check if dark reference needs updating...
UpdateHWDarkRef 3 #every three hours seems ok
# Get eucentric
echo Doing Eucentricity fine...
Eucentricity 2
UpdateItemZ
# realign to item
Callfunction CheckAutoFill
echo Doing RealignToItem
RealignToNavItem 0
CallFunction CycleDefocus
ReportTargetDefocus
echo Target defocus [from $TD_low to $TD_high] : $RepVal1 um
branchesteps = $maxtilt / $group / $step
plustilt = 0
mintilt = 0
# zero tilt image
CallFunction TiltZero
# loop back and forth in groups
loop $branchesteps
loop $group
plustilt = $plustilt + $step
CallFunction TiltPlus
endloop
loop $group
mintilt = $mintilt - $step
CallFunction TiltMinus
endloop
endLoop
# finish
TiltTo 0
SetDefocus 0
ResetImageShift
CloseFile
ReportMinuteTime
totaltime = $RepVal1 - $macrostarttime
echo Tomogram for item $NavLabel acquired in $totaltime minutes!
echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
function TiltZero
echo Doing untilted image...
ReportStageXYZ
StageX = $ReportedValue1
StageY = $ReportedValue2
# track
CallFunction CheckAutoFill
GoToLowDoseArea T
ResetClock
# Measure focus and drift
ReportTargetDefocus
echo Measuring focus (target $RepVal1 um) and drift ($driftcrit A/s max)...
CallFunction DriftAndFocus $driftcrit $drifttimes
ReportDefocus
focusplus = $RepVal1
focusmin = $RepVal1
echo Copying Focus image for tracking...
Copy A K
Copy A L
# Record
CallFunction CheckAutoFill
echo Taking Record...
#EarlyReturnNextShot -1
R
S
Copy A M
Copy A N
ReportImageShift
ISxplus = $RepVal1
ISyplus = $RepVal2
ISxminus = $RepVal1
ISyminus = $RepVal2
# Tracking after
CallFunction CheckAutoFill
echo Tracking after: item $navLabel, tilt 0, img shifts: $ISxplus $ISyplus, defocus $focusplus
T
Copy A K
Copy A L
endfunction
function TiltPlus
echo Tilting to $plustilt...
TiltTo $plustilt
MoveStageTo $StageX $StageY
CallFunction CheckTiltAngle $plustilt
# set to previous used shift/focus
GoToLowDoseArea R
SetDefocus $focusplus
SetImageShift $ISxplus $ISyplus
# Track
CallFunction CheckAutoFill
ResetClock
echo Taking Trial image for tracking...
T
AlignTo K
# Measure focus and drift
ReportTargetDefocus
echo Measuring focus (target $RepVal1 um) and drift ($driftcrit A/s max)...
CallFunction DriftAndFocus $driftcrit $drifttimes
ReportDefocus
focusplus = $RepVal1
# Record
CallFunction CheckAutoFill
echo Taking Record...
#EarlyReturnNextShot -1
R
S
AlignTo M
Copy A M
ReportImageShift
ISxplus = $RepVal1
ISyplus = $RepVal2
# Tracking after
CallFunction CheckAutoFill
echo Tracking after: item $navLabel, tilt $plustilt, img shifts: $ISxplus $ISyplus, defocus $focusplus
T
Copy A K
endfunction
Function TiltMinus
echo Tilting to $mintilt...
TiltTo $mintilt
TiltBy $Tiltbacklash
TiltTo $mintilt
MoveStageTo $StageX $StageY
# set to previous used shift/focus
GoToLowDoseArea R
SetDefocus $focusmin
SetImageShift $ISxminus $ISyminus
# Track
CallFunction CheckAutoFill
ResetClock
echo Taking Trial image for tracking...
T
AlignTo L
# Measure focus and drift
ReportTargetDefocus
echo Measuring focus (target $RepVal1 um) and drift ($driftcrit A/s max)...
CallFunction DriftAndFocus $driftcrit $drifttimes
ReportDefocus
focusmin = $RepVal1
# Record
CallFunction CheckAutoFill
echo Taking Record...
#EarlyReturnNextShot -1
R
S
AlignTo N
Copy A N
ReportImageShift
ISxminus = $RepVal1
ISyminus = $RepVal2
# Tracking after
CallFunction CheckAutoFill
echo Tracking after: item $navLabel, tilt $mintilt, img shifts: $ISxplus $ISyplus, defocus $focusmin
T
Copy A L
endfunction
Function CheckAutoFill
loop 10
AreDewarsFilling
if $RepVal1 == 0
break
elseif $RepVal1 == 1
echo Dewars are filling! Delay for 60 sec...
delay 60 sec
endif
endloop
endfunction
Function CycleDefocus
bigstep = $TD_low - $TD_high
ReportTargetDefocus
TD = $reportedValue1
if $TD > $TD_low
diff = $TD - $TD_low
IncTargetDefocus -$diff
elseif $TD > $TD_high
IncTargetDefocus -$delta
else
IncTargetDefocus $bigstep
endif
endfunction
Function DriftAndFocus 2 0 drift_tol n_drift
GoToLowDoseArea F
Loop $n_drift
CallFunction CheckAutoFill
AutoFocus
ReportFocusDrift dx dy
drift = 10 * SQRT ( ( $dx * $dx ) + ( $dy * $dy ) )
If $drift <= $drift_tol
Break
EndIf
EndLoop
EndFunction
Function CheckTiltAngle 1 0 tiltangle
ReportTiltAngle
mTilt = NEARINT $RepVal1
if $tiltangle != $mTilt
echo Target tilt = $tiltangle, real tilt = $mTilt. NOT ok!
TiltTo $tiltangle
endif