Focus/Tune menu commands

The Focus/Tune menu offers the following commands for controlling Autofocus and Autotuning:

Measure Defocus Measure current defocus.
Autofocus Autofocus to the defined target value.
Move Focus Center Shift center of focus from display point to center of field.
Check Autofocus Assess ability to autofocus by measuring defocus at 3 levels.
Report Shift & Drift Does focus detection and reports shift and drift.
Report On Existing Report shift and drift from pictures already present in buffers A-C.
Show Existing Corr Show the cross-correlation from pictures already present in A-C.
Show Image Stretch For existing images, show the image that is stretched to compensate for specimen tilt.
Set Target Enter target defocus to change to after autofocus.
Set Beam Tilt Set amount of beam tilt for detecting defocus.
Set Offset Set focus offset to apply before measuring defocus.
Set Threshold Set threshold focus change for reiterating the autofocus.
Set Tilt Direction Set the direction of beam tilt for autofocusing.
Set Min Binning Set minimum total binning for correlating autofocus images from a direct detector.
Test Filter Cutoffs Set trial parameters for filters in autofocus correlations.
Drift Protection Use three autofocus pictures to protect against drift.
Set Absolute Limits Set lower and upper absolute limits for autofocusing around eucentric focus.
Use Absolute Limits Apply the lower and upper absolute limits when autofocusing
Limit Offset Defocus Keep the offset defocus used to find focus within limits also.
Correct Astigmatism by CTF Measure and correct for objective astigmatism by CTF fitting
Coma-free alignment by CTF Measure and correct for beam-tilt misalignment by CTF fitting
Set CTF Acquire Params Set parameters for acquiring images for CTF fitting
Set CTF Coma-free Params Set parameters for the coma-free alignment by CTF fitting
Beam-Tilted FFT Array Make Zemlin tableau: FFTs of images with beam tilted in 8 different directions.
Correct Astigmatism by BTID Measure and correct for objective astigmatism by beam-tilt induced displacements.
Set BTID Astig Beam Tilt Set beam tilt to use for astigmatism calibration and/or correction by BTID.
Old Coma-free Alignment  Operations for coma-free alignment by beam-tilt-induced displacements
     BTID Coma-free Alignment Measure and correct for beam-tilt misalignment by BTID.
     Set Coma Beam Tilt Set the maximum beam tilt for coma-free alignment by BTID.
     Set Coma Iterations Set number of coma measurements to average over.
     Run Another Iteration Measure coma one more time and average with previous iterations.
Reset Defocus Set the defocus shown in the microscope panel to zero.
Verbose Output defocus shift and drift information to Log Window.

Measure Defocus command (Focus menu)

This command is used to run the autofocus routine for measuring defocus, without changing to the target defocus. Upon completion, the program will inform you of the measured defocus and ask if you want to set the target defocus to this value. This procedure is typically used if one adjusts focus manually to give the desired image appearance, then measures defocus and uses the measured value to set the target.

Autofocus command (Focus menu)

This command will run the autofocus routine to measure defocus and then change focus to achieve the target defocus. If the indicated change in focus is greater than a preset threshold, then the program will change focus by at most twice the threshold amount, and repeat the autofocus routine. This threshold is set with the Set Threshold command described below.

In STEM mode a completely different procedure is used, as described in the section on Autofocus in STEM Mode, and the target for defocus is always 0.

Shortcut Key:CTRL+G

Move Center command (Focus menu)

This command can be used at high tilt to change the focus so as to move the visible center of focus by a desired amount. First click the left mouse button to set a display point at a place in the image with the desired focus. Then select this command. The center of the field in the next acquired image should be at the desired focus level.

Check Autofocus command (Focus menu)

This command can be used to assess how well autofocus will work. The program will measure defocus using the current parameters at the current defocus, and at +5 and -5 microns away from that defocus. It will then inform you of the measured defocus change as a fraction of the actual change in defocus in each direction. If these numbers are greater than 0.9, autofocusing will be fairly accurate even for relatively large changes. If the numbers are sufficiently large, autofocusing should work adequately during a tilt series; otherwise it will be unreliable.

Report Shift & Drift command (Focus menu)

Use this command to run the routine for measuring defocus and receive a report of the beam tilt-induced image shift plus the shift due to drift, all in pixels (unbinned pixels are reported if the images were binned). Drift protection must be selected to get a meaningful estimate of drift.

Report on Existing command (Focus menu)

Use this command to measure the beam tilt-induced image shift and the shift due to drift from pictures that are already in buffers A-C from a previous autofocusing operation. If drift protection is off, only the shift between pictures in buffers A and B will be reported.

Show Existing Corr command (Focus menu)

Use this command to display the autofocus cross-correlation from pictures that are already in buffers A-C from a previous autofocusing operation. The correlation will be placed in buffer A and existing images will be rolled up one buffer.

In STEM mode, this command will probably fail to work right unless the property STEMFocusShowBestAtEnd is added to the Properties file and set to 0.

Show Image Stretch command (Focus menu)

Use this command to see the stretch that is used to compensate for specimen tilt above 5 degrees, for pictures that are already in buffers A-C from a previous autofocus operation.  The second image of the autofocus series will be replaced with the stretched version and the original will be copied down two buffers if rolling is allowed into that buffer.  If binning is being applied to direct detector images, the stretching occurs after binning, so the replaced image will be binned.  The program also reports the matrix applied to do the stretch in the log.

Set Target command (Focus menu)

This command is used to enter a specific target defocus for autofocusing. After the autofocus routine measures a defocus, it will change the focus setting so as to achieve this target level. Selecting this command brings up a dialog box for entering the number; the default value shown is the current target. Enter a defocus in microns.

Set Beam Tilt command (Focus menu)

This command is used to set the beam tilt that is used for autofocusing. Selecting this command brings up a dialog box with a default value equal to the current beam tilt value. The units are milliradians (mrad).

Set Offset command (Focus menu)

Use this command to set a focus offset that will be applied before any of the autofocusing operations invoked in the Focus menu. For example, if the offset is set to +5 µm, then when you choose to measure defocus, the program will change defocus by +5 µm, take pictures for measuring defocus, restore the defocus by -5 µm, and subtract 5 µm from the measured value to determine the current defocus. This option provides a way to autofocus to a target far from zero when the program is having difficulty autofocusing.

Set Threshold command (Focus menu)

Use this command to set the thresholds for repeating the autofocus procedure after a large change in defocus, and for applying the logic that can abort autofocus when iterations give inconsistent results. The current value of the threshold for repeating autofocus is the default value shown in the first dialog box. Whenever autofocusing changes the focus level by more than this amount, the program will repeat the autofocus operation.  After entering this threshold, a second dialog box appears asking for the threshold for testing whether successive results are inconsistent.  You can enter 0 to disable the tests for inconsistent autofocus.  The testing will always be done for any non-zero value less than the threshold for repeating autofocus; values higher than the threshold for repeating will make the testing be skipped when changes are between the two threshold levels.  The latter may be desirable when using very small thresholds for repeating.

Set Tilt Direction command (Focus menu)

Use this command to set the direction that the beam will be tilted during all autofocusing operations.  Enter a number between 0 and 3, where 0 corresponds to tilting with the X coil only, 1 tilts with equal deflections on the X and Y coils, 2 tilts with the Y coil only, and 3 tilts with a negative deflection on X for a positive one on Y.  Using a number different than 0, which was the only direction available before SerialEM 3.4, will cause the image to shift in different directions, at 45 degree increments from the shift at direction 0.  Focus calibrations are specific to the current direction, so the calibration must be done at each direction to be used for autofocusing.

Set Min Binning command (Focus menu)

Use this command to set a minimum total binning to apply when correlating autofocus images from a direct detector.  The autofocus routine does not apply any binning to the images that it correlates by default, but it is recommended that the Focus images themselves be taken with some binning to reduce the effects of fixed noise in the images.  It can be difficult to take images with the needed binning with direct detectors because their high gain values make binned images saturate easily.  Thus, this command allows one to process autofocus images obtained with lower binning as if they had been taken with higher binning.  Enter the desired total binning.  When autofocusing, the program either applies additional binning to reach the specified binning, or reduces the cutoff and rolloff of the high-frequency filter to achieve an equivalent effect, or a combination of the two.  For example, if the total minimum binning is set to 4, unbinned images will be binned by 4 for correlating, images with binning 2 will be binned by 2 again, and images with binning 3 will be correlated with the filter parameters multiplied by 0.75.  Although this feature currently is applied only for direct detectors, it could easily be provided for other cameras if the need arose.

Test Filter Cutoffs command (Focus menu)

Use this command to set the cutoff and rolloff parameters for the low and high ferquency filters applied when correlating autofocus images.  The 'Test' in the name of the command refers to the fact that values are not retained between program sessions.  If a filter change is needed, it should be set in the SerialEMproperties.txt file.  First enter the frequency at which the high-frequency filter starts to cut off, in reciprocal pixels.  Then enter the sigma value for the rolloff of the filter.  In both cases, smaller numbers filter more.  These parameters may need to be adjusted when there are severe problems with fixed noise in the correlation images.  To change them in the properties file, add lines starting with 'FocusFilterRadius2' and/or 'FocusFilterSigma2'.  The third property is the sigma for the low-frequency filter, an inverted Gaussian that is zero at zero frequency and rises to 1.  Its property entry is 'FocusFilterSigma1', but the current default should be effective.

Drift Protection command (Focus menu)

Use this command to toggle between having two or three pictures taken for autofocusing. With three pictures, the program can separate shift due to drift from the beam tilt-induced image shift used to determine defocus. The measured defocus will thus be accurate if the drift is constant.

Set Absolute Limits command (Focus menu)

Use this command to set limits for the absolute focus that can be accessed during autofocusing.  The main purpose of such limits would be to prevent failures in taking images due to the Falcon Dose Protector, but they might be useful in other situations.  The first step is to set the microscope to eucentric focus, which you could do by pressing a Eucentric Focus button or by making the stage eucentric and focusing a specimen.  After you confirm that the scope is at eucentric focus, the program asks you to enter the lower and upper limits for defocus relative to that point, in microns; these are assumed to be negative and positive, respectively.  The program changes focus to each level and records the absolute focus value.  The limits will not be applied unless you turn on the next option.

Use Absolute Limits command (Focus menu)

This command toggles whether the absolute focus limits entered with the previous command are applied during autofocusing.  Autofocus will abort whenever changing the defocus to the target value would make focus exceed the limits.

Limit Offset Defocus command (Focus menu)

This command toggles whether a defocus offset for autofocusing will be included when determining whether an absolute focus limit is being exceeded.  If it is included, the program will not attempt to measure defocus at a focus level exceeding the limits; if it is not included, the limits will apply only to a new focus needed to reach the target defocus.  This option should be turned on for Falcon cameras but should not be needed in other situations.

Correct Astigmatism by CTF command (Focus menu)

This command will measure and correct astigmatism by fitting the CTF to Thon rings in an image.  It is one of three operations run through the same routine, the others being the calibration of this correction and Coma-free alignment by CTF.  Here is a general introduction to the operation and use of this routine.

      Autotuning by CTF Fitting 

The CTF autotuning routines require images with Thon rings suitable for fitting with the Ctffind module.  To get the best signal-to-noise ratio and the most accurate fitting, images need to have a long enough exposure and use the full camera area.  They are taken with parameters generally derived from the Record parameters, but specific values, such as for exposure time and binning, can be set with the Set CTF Acquire Params.  For example, if your Record exposure time is set for a long acquisition for single-particle reconstruction, you should specify a shorter time for the CTF tuning images.

The first step in the CTF tuning routine is to measure the current defocus, both to make sure that defocus is an acceptable range and to set the defocus range for CTF fitting.  The routine will then run at the current defocus provided that it is within a range where the CTF fitting is expected to work.  Defocus will be changed if necessary to avoid defocus values that are too low in astigmatic images, and so that the expected number of CTF rings will not be too low or too high.

Defocus should be in the range of -1.0 to -2.5 microns, or more underfocused at lower magnifications (e.g., with a pixel size in the range of 1 nm or more).

You should verify that the CTF fitting is reasonably accurate with the acquisition parameters and defocus being used by turning on Do Ctffind On Click and checking that the fits work when clicking, and that the defocus varies by only about 3-10 nm between successive images (e.g., for focus near -2 microns).  Larger variations will occur at lower magnifications and higher defocus, situations where the lower accuracy of fitting may be acceptable. 

It is a good idea to open the side-by-side FFT display (see Side by Side) when you are first using these routines.  When this window is open, the program will show the CTF fit for each image, taking an FFT if it is not being done automatically (i.e., with Automatic Single FFTs turned on).

Fitting will be done with the slower 2D search, which is not the default when clicking in an image.  If you see bad fits when running these routines, you should enable the 2D search when clicking with the Set Ctffind Options command, and adjust parameters until fitting works when clicking in an image.

If there are few Thon rings and they do not extend out very far, the fitting may fail because the resolution range for fitting is set too high.  The solution for this currently is to bin the images so that the Thon rings extend to a higher frequency (in reciprocal pixels) in the image.

The CTF autotuning routines will zero out the image shift, giving a zero reading of IS or PLA in the Microscope Status panel.

     Correcting Astigmatism by CTF Fitting 

The astigmatism correction routine will measure defocus, take a single image, and correct the astigmatism.  If the change in stigmators is above a threshold, it will take another image and refine the correction.  You can check the result by taking an image and clicking near the first zero with Do Ctffind On Click enabled.

Technically, if you are going to correct coma as well, you should correct that first, then astigmatism. In practice, this matters only if the the beam tilt misalignment is substantial.  In that case, some of the astigmatism in the image may be due to beam tilt, and simply making the image have no astigmatism will leave the stigmators at the wrong setting. The coma-free alignment routine is insensitive to astigmatism, so it will fix the beam tilt and leave the astigmatism in the image that does need to be corrected with stigmators.

    Which Astigmatism Method to Use

The CTF-based method has several advantages: it is based on a direct measurement of astigmatism, it is insensitive to drift, it does not require beam tilt, and it uses on-axis images in Low Dose mode.  It is inherently more accurate at higher magnifications.  Both methods should be calibrated at higher magnification but can work at lower ones (e.g., ~1 nm pixel size).  The big disadvantage of the CTF-based method is that it requires images with Thon rings.  There is thus still a role for the BTID-base method at lower magnifications and when working with stained, embedded samples, which are usually imaged near focus and rarely give Thon rings.

Coma-free Alignment by CTF command (Focus menu)

Use this command to measure and correct for beam-tilt misalignment (coma) by fitting a CTF to the Thon rings in images.  The program will take 5 images, one with no beam tilt and the others with beam tilt in the plus and minus X and Y directions.  It is also possible to take a full array of images, 8 with beam tilt and 2 without.  The defocus changes at various angles will be analyzed to determine the existing beam tilt that needs to be corrected.  The procedure needs no calibration.

The operations and requirements described in Autotuning by CTF Fitting all apply here.  Aside from getting images with good Thon rings, the main challenge may be getting beam-tilted images without the objective aperture or beam edge intruding.

The maximum beam tilt should be in the range of 4 to 10 milliradians, preferably between 6 and 8.  The goal is to get defocus changes ranging up to 0.3-0.4 micron.  The defocus changes being measured are proportional to the square of the beam tilt, so the reliability of the estimated misalignment will increase accordingly.  Both the maximum beam tilt and whether to use a full array of images can be set with the Set CTF Coma-free Params command.

There are two reasons why you might want to use a full 3x3 array of images instead of the basic 5 images along the X and Y axes of beam tilt.  First, if the Thon rings are not very strong and the estimates of defocus vary much from one shot to the next (with no applied beam tilt), then you can use a full array to average over more of these noisy data.  Second, you may find that the full array gives a solution consistently different from the one using 5 images by an amount that you think matters.  To assess this, you can use the script command FixComaByCtf to measure the beam tilt repeatedly without changing it.  Run the two commands
   FixComaByCtf 1 0 0
   FixComaByCtf 1 0 1
repeatedly (in a loop) to measure the beam tilt with 5 and 10 images.  You can see more details about the solution by setting Debug Output (in the Calibrate menu or in the properties) to 1 or any letters.  In that case, the log will show the beam tilt from X and Y deflections as the "solution" values for axes 0 and 1, and the corresponding estimates from the diagonal deflections as the "rotated diagonal solution".  If they do differ by much, the average of the two is presumed to be a less biased estimate of the actual beam tilts.

The method used to derive the beam tilts is described in

Set CTF Acquire Params command (Focus menu)

Use this command to set the parameters for acquiring and analyzing images for the CTF-based astigmatism and coma routines.  You can set:

  1. Exposure time.  Enter a specific time 0 to use the current Record exposure time.  If you take long Record images during single particle acquisition, you will want to set this to a reasonable time.
  2. Binning.  Enter a specific binning or 0 to use the current Record binning.  The CTF analysis itself should be fairly insensitive to binning unless it is too high, but you may want to use a binning higher than 1 to make the Thon rings extend farther out in the display.
  3. Drift settling time.  Enter a specific settling time, or 0 to use the current Record settling.
  4. Field size.  Enter 1 to take full-field images, or 0 to use the current Record subarea if any.

Set CTF Coma-free Params command (Focus menu)

Use this command to set parameters for the coma-free alignment.  You can set:

  1. Maximum beam tilt.  On an FEI scope, enter this in milliradians.  Otherwise, you will be told the estimated scaling from percent of full-scale to milliradians and asked to enter a value in percent, the same units used for the autofocus beam tilt.  If you enter a negative value, it will use the program's default value, which can be set by the property 'ComaParams'.
  2. Whether to take a full array of images.  With a non-zero entry, it will take a 3x3 array of images and repeat the image at 0 beam tilt at the end.  The difference in beam tilt along diagonals will be the same as that along the axes.  See above for a discussion of when the full array is useful.
  3. Threshold for iterating.  The program will iterate the operation once when the initial correction of beam tilt exceeds this threshold.  Enter a value in milliradians.

Correct Astigmatism by BTID command (Focus menu)

Use this command to measure and correct for objective astigmatism with beam-tilt induced displacements.  The procedure first measures defocus and changes to the focus used for the astigmatism calibration that fits the current conditions. It then measures beam-tilt induced image shift for beam tilts in three directions and uses this information to solve for the astigmatism.  If the change in stigmator settings is large enough, it then repeats the procedure one or two times.

The beam tilt used is set with the Set Astig Beam Tilt command.  It does not need to be the same as the beam tilt used for the calibration, which is recommended to be done at twice the beam tilt normally used for autofocusing.  You may need to remove the objective aperture to run this operation with such a beam tilt, but it should be possible to get adequate results with the aperture in and a lower beam tilt, if necessary.  Before running this command for the first time, you should use the  List Calibrations command in the Calibration - Focus & Tuning menu to check what beam tilts and magnifications have been used for calibration.  The calibrations are also specific to probe mode on an FEI scope or alpha on a JEOL, so if the Correct Astigmatism command is disabled, it may be because there is no calibration for your current conditions.

The Focus parameters are used, just as for autofocusing, so be sure that autofocusing is working well before running this routine.

This procedure will be more accurate at higher magnifications, but should work at magnifications where the pixel size for data acquisition is around 1 nm.  The routine uses the calibration from the nearest calibrated magnification.

Set BTID Astig Beam Tilt command (Focus menu)

Use this command to set the beam tilt that will be used either to calibrate astigmatism with or to correct it with beam-tilt induced displacements.  On a non-FEI scope, the entry box will tell you the scaling from percent of full scale to milliradians, so that you can use a standardized value if desired.

BTID Coma-free Alignment command (Focus - Old Coma-free Alignment submenu)

This command will measure and correct for beam-tilt misalignment (coma) using beam-tilt-induced image displacements.  This routine is of limited accuracy and has been superceded by the CTF-based coma-free alignment, so it should probably not be used.  The procedure measures focus, changes to the focus at which a coma calibration was done, and measures beam-tilt induced image shift for positive and negative beam tilts in X and Y directions.  From the difference between displacements, it estimates the current beam tilt and adjusts for it.  To reduce the inaccuracy of the measurement, this procedure can be run for additional iterations (one more by default, adjustable with the Set Coma Iterations command).  On each iteration, the estimated coma-free beam tilt is averaged with that estimated on the previous iterations; at the end the final adjustment is reported.  After running this command, an additional iteration can be run and averaged in with the Run Another Iteration command.

The beam tilt used is determined by the value entered with the Set Coma Beam Tilt command, which must match the value for an existing coma-free calibration.  In fact, the beam tilt here is half of the maximum tilt used for the calibration.  Before running this command for the first time, you should use the List Calibrations command in the Calibration - Focus & Tuning menu to check what beam tilts have been used for calibration.  These calibrations are specific to probe mode on an FEI scope or alpha on a JEOL.  The Coma-free Alignment command is disabled unless there is a calibration at some magnification that matches the current conditions as well as the beam tilt setting.

The Focus parameters are used, just as for autofocusing, so be sure that autofocusing is working well before running this routine.  Accurate measurement of displacement differences requires a high magnification as well as large beam tilts, so you may need to run the routine at whatever magnification is calibrated.

This command cannot be run in Low Dose mode, because the beam-tilt alignment is different at the shifted location of the Focus area.

Use the Beam-Tilted FFT Array command to assess how good the coma-free alignment is.  The precision or reproducibility of the routine can be assessed by running the script command 'CorrectComa -1' several times in a row to find the misalignment without correcting it, which lets you see how much the reported misalignment varies. 

Set Beam Tilt command (Focus - Old Coma-free Alignment submenu)

Use this command to set the maximum beam tilt for coma-free calibrations by BTID.  That beam tilt will be used for doing a calibration, and the coma-free alignment can be done only with a beam tilt that matches what was used for a calibration.  The entry box will list the beam tilts for all calibrations that match the current probe mode (on an FEI scope) or alpha (on a JEOL).  If there are no such calibrations, for a non-FEI scope, the box will show the scaling from percent of full scale to milliradians, so that an appropriately large percentage value can be entered.

Set Coma Iterations command (Focus - Old Coma-free Alignment submenu)

Use this command to adjust the number of iterations, or misalignment measurements to be averaged, for an initial run of the BTID Coma-free Alignment command.

Run Another Iteration command (Focus - Old Coma-free Alignment submenu)

Use this command after the BTID Coma-free Alignment command to make one more measurement of misalignment and average it with the previous results.  This command can be used repeatedly if necessary.

Beam-Tilted FFT Array (Focus menu)

Use this command to create a Zemlin tableau, in which the FFTs of images taken with the beam tilted in 8 different directions are arranged around a central FFT taken with no beam tilt.  Images are currently taken with the Focus parameters, so these parameters as well as the defocus need to be set to give informative FFTs with good Thon rings if possible.  If a focus calibration is available, the direction of beam tilt is set so that the long axis of the Thon rings is approximately tangential.  However, this is just for a nice appearance: the direction of this axis is not an indicator of how well beam tilt is adjusted.  Rather, when there is no coma, the FFTs on opposite sides of the center should look the same, with the same direction and elongation to the rings.

The program will first ask what beam tilt to use, in milliradians on an FEI scope or percent of full scale on other scopes.

Image shift is set to zero before the images are taken.  The command can be run in Low Dose mode and currently, it will go to the focus area before setting image shift to zero so that it can take on-axis images with the Focus parameters.  At this point the IS/PLA readout in the Scope Status panel will show the underlying shift of the Focus area, not 0.

The full tableau will be 1020x1020 pixels, with each FFT reduced to 510x510 then cropped to 340x340.  A dialog may be added to set alternative imaging and size parameters, but for now parameters can be controlled with the 'ZemlinTableau' script command.  For example, the following script can be used to set the defocus to -1 micron, take full-field images with binning 1 and exposure 1 second, and make a larger tableau image with only half as much cropping outside each FFT.

focus = -1.
exposure = 1.
binning = 1
Autofocus -1
ReportAutoFocus curFocus
change = $focus - $curFocus
ChangeFocus $change
SetCameraArea F F
SetBinning F $binning
SetExposure F $exposure
ZemlinTableau 6 450 70

Reset Defocus command (Focus menu)

Use this command to reset the defocus readout in the Microscope Status panel to zero, without actually changing microscope focus. On an FEI scope, this simply does the same thing as the Reset Defocus command in the Microscope User Interface. On a JEOL, the defocus readout is set to zero when the program starts and this is the only way to change it.

Verbose command (Focus menu)

This command toggles more complete output from focusing operations. With the option selected, the shift and drift information are printed in the Log window on every autofocus, as well as the cross-correlation coefficient between unfiltered images. With the option not selected, the measured defocus value and the use of a secondary peak will still be reported to the Log window, but only if it is already open.