Setting Up SerialEM

Program Installation
     The Basic Packages and their Contents
     Additional Packages for GPU and Python Support, and for Displaying General and Ctfplotter Graphs
     Versions of the DigitalMicrograph Plugin and Compatibility with Leginon
     Running the Installer.
     Upgrading to a New Version.
     Permissions and Running as Administrator.
     Determining IP Addresses on a Shared Network
     Defining an Environment Variable.
     Shortcuts, Command Line Arguments, and Administrator mode.
A Minimal Setup Procedure
Starting with a Generic Properties File
Connecting with a Thermo/FEI Microscope through Plugin and Server
     Yes, You Need a Network Connection between the Computers
     Setting Up the Plugin and Server
     Moving an Existing Installation from a Thermo/FEI Computer to a 64-bit Computer
     Upgrading to the New Plugin and Server from SerialEM 3.4.
     Running 64-bit SerialEM on a 64-bit Thermo/FEI Computer
     Upgrading from a K2 to a K3 camera
Initial Camera Setup
     Camera Configuration for Image Orientation
     General camera related parameters
     For a Tietz camera
     To connect to DigitalMicrograph through a socket interface
     For a K2 camera in particular
     To set up a OneView or Rio camera to save frames
     For a Direct Electron direct detection camera
     For a Falcon 2 camera that can save intermediate frames, under original scripting interface
     For a Falcon 2 camera under the new advanced scripting interface
     For a Falcon 3 or 4 camera
     For a Ceta 2 camera (Ceta with speed enhancement option)
     To use a GPU for aligning Falcon or Ceta 2 frames in SerialEM
     For accessing a JEOL camera or STEM signals
     For accessing a Tietz camera remotely
Bad dialog sizes or bad program and font sizes
Initial Actions and Other Special Features for Hitachi HT7700/HT7800
Checking the Magnification Table and Calibrating Neutral IS Values
Measuring Relative Gain Factors for Eagle, Tietz CMOS, or other Cameras
Tuning Timing of Gatan Camera with Two Shutters
Measuring Timing of Non-Gatan Camera or Gatan Camera with One Shutter
Setting up Tietz or Eagle Camera Binning Offsets
Assessing Standard Focus for Low Mag Mode
Focus Calibration
Calibrating Image Shift and Pixel Size
     Other preliminaries
     A script for image shift and pixel size calibrations
     The procedure
     Assessing and setting image shift boundaries
     Measuring further relative rotations and pixel sizes by aligning images
     Absolute rotation angle
Other Microscope Calibrations
Extended Autofocus and Non-reciprocity Calibration for Using Eucentricity by Focus
Setting Up X Ray Removal from Dark References
Measuring Camera Gain
Stage and Imaging Stretch
Energy Filter Calibrations
Energy Filter Properties
Setting Up STEM
Final Tasks
Setting Up for a Separate Voltage
Setting Up to Use Nanoprobe TEM on Thermo/FEI Scopes  
Controlling Apertures on Thermo/FEI Scopes  
Alpha and Beam Shift Calibration Issues on JEOL scopes  
Setting Up to Use a GPU for Frame Alignment 
Adding an NVIDIA card to a K2/K3 Computer 
Using Film
Files in a SerialEM Install Package

Program Installation

The Basic Packages and their Contents.  The files needed to run SerialEM consist of executable programs and libraries, which are distributed in a package SerialEM_4-x-x.exe, and configuration and data files, some of which are obtained from a 'framework' package.  The program itself should be installed in a folder C:\Program Files\SerialEM; this is the location where the package unpacks by default. The configuration and data files are also placed in this folder under Windows 2000 and XP, but under Windows 7 and Server 2008 they need to be placed in a folder C:\ProgramData\SerialEM instead. For the latter systems, if you received a custom framework file, it should be set up to unpack in C:\ProgramData, but if not, you should change 'Program Files' to 'ProgramData' before unzipping.

The SerialEM_4-x-x.exe package will create a subfolder SerialEM_4-x-x under C:\Program Files\SerialEM.  See  Files in a SerialEM Install Package for a description of the package contents.

There are two distinct kinds of plugins in the package.  One is the plugin to DigitalMicrograph, which runs when DM loads it from one of its Plugins folders.  The other is the collection of microscope and camera plugins to SerialEM.  SerialEM tries to load any file whose name ends in 'Plugin.dll' from the same folder as the executable.

  • The files that come from a framework extract to either C:\Program Files\SerialEM (Windows XP) or C:\ProgramData\SerialEM (Windows 7 and later) and include:
    SerialEMproperties.txt - the Properties file, read by SerialEM, edited by hand
    SerialEMcalibrations.txt - an empty calibrations file, read and written by SerialEM
    SEMsystemSettings.txt - a default settings file for users that do not have settings yet
    SerialEM.lnk - a shortcut to start SerialEM with the right settings, once setup is complete
    UserSettings - a folder that can contain several subfolders, each providing a set of default settings for SerialEM for different users/applications
    UserSettings\Setup - a folder for SerialEM default settings for installation and calibration
    UserSettings\Setup\Setup SerialEM.lnk - a shortcut to start SerialEM with using the default settings for installation and calibration (can be copied anywhere)
    UserSettings\Setup\SerialEMsettings.txt - a settings file for installation and calibration

    If you did not get a 'framework' package already customized for your scope, the Properties file in the SerialEM folder is incomplete and should be edited to incorporate camera and magnification information, as indicated in Starting with a Generic Properties File.  See this section also for instructions on modifications needed under Windows 7/Server 2008 and with GMS 2.x.

    Additional Packages for Windows XP, GPU and Python Support, and for Displaying General and Ctfplotter Graphs.  Depending on your situation, you may need one or more other packages.

    Versions of the DigitalMicrograph Plugin and Compatibility with Leginon.  The version number on the SEMCCD plugin does not need to match the GMS version exactly; the versions provided in the package are compatible with the full range of GMS versions.  Specifically, the 32-bit version built with GMS 2.30 works with GMS 2.31 and 2.32; the 64-bit version built with GMS 2.31 works with GMS 2.32 and GMS 3.0 - 3.2

    Leginon uses the SerialEM plugin for communicating with K2/K3 cameras.  However, it is generally compatible with any plugins distributed in SerialEM 3.7 or 3.8, because it does not rely on the newest features in these plugins.  New versions of the plugin are always backwards compatible; i.e., they will work with older versions of connecting software (SerialEM or Leginon) that are unaware of new features.  SerialEM, however, does use all the new features in newer plugins, so it will expect to find the plugin version that it is distributed with.  Thus, if both SerialEM and Leginon are on the system, there should only be one version of the plugin, and it should be the version distributed with SerialEM.  The SerialEM installer will remove any existing plugins from

    Running the Installer.  For initial installation or upgrading to a new version, simply click on 'INSTALL.bat' in the SerialEM_4-x-x subfolder.  In Windows 7/10/Server 2008/2012 you will need to right click and select 'Run as Administrator'.  If you have a Gatan camera, make sure that DigitalMicrograph is not running.  The installer does the following:

    1. It will clean up DLL's and help files from previous versions then copy an appropriate subset of the files into the upper folder (SerialEM).  In Windows 2000, the individual Microsoft DLL's will be copied instead of their folders. 

    2. On a Thermo/FEI scope, you will be asked if you want to install the module for doing dynamic focus in STEM.  If so, it will copy FocusRamper.exe up and register it.

    3. The installer will try to deduce what kind of microscope it is running on, and copy the appropriate plugin file to the upper folder.  If there is no evidence of what kind of scope is being run, you will be asked if you want to install a plugin for a Thermo/FEI scope or a Hitachi scope.  If there is no apparent microscope installation, but a plugin file is already present in the upper folder, then it will copy the new version of that plugin up.

    4. The Tietz plugin is copied up if the SerialEM properties file contains an entry for a Tietz camera or if the properties are not found; the DE camera plugin and interface DLL are handled similarly; and a plugin for running JEOL cameras is copied if it is already present.

    5. The module for frame alignment in the GPU, FrameGPU.dll, is updated if it is present in either the SerialEM directory or C:\ProgramData\Gatan\Plugins

    6. If you have a Gatan camera, the installer will detect whether you have GMS 1.x or a 32-bit or 64-bit version of GMS 2.x or 3.x, and copy just the needed DLL's and register-GMSx.bat file.  It will tell you which version it found and remind you that DigitalMicrograph should not be running. Make sure it detected the right version. 

    7. After you hit a key, it will copy the DM plugin to the Gatan Plugins folder (C:\Program Files\Gatan\DigitalMicrograph\Plugins in GMS 1.x, C:\Program Files\Gatan\Plugins for GMS 2 32-bit, and C:\ProgramData\Gatan\Plugins for GMS 2-3 64-bit) and register the DLL's; this should result in 2 or 3 message boxes saying that registration succeeded.  For 64-bit versions, it will also copy or update components needed for alignment of K2/K3 frames through the CPU or GPU.

    8. At the end, if it thinks you are accessing a Thermo/FEI or Hitachi scope remotely, it will tell you to copy FEI-SEMserver.exe or ShMemSEMserver.exe to the scope computer.  The first time that you install, you will definitely need to do this. 

    Backing up your SerialEM installation.  To backup your SerialEM installation on Windows 7 and later, copy C:\ProgramData\SerialEM to a safe location, a backup of C:\Program Files\SerialEM is not required if the installation was performed as described here. On Windows XP, copy the files SerialEMcalibrations.txt, SerialEMproperties.txt, SEMflybackTimes.txt (on systems with STEM), SEMsystemSettings.txt, SEMshortTermCal.txt from C:\Program Files\SerialEM, also include all user settings.

    Upgrading to a New Version.  What the installer will NOT do is update the plugin to DigitalMicrograph on a remote computer, or the server on a remote Thermo/FEI microscope, so you may need to do this manually.  SerialEM will determine the versions of these components and inform you if they need to be updated.  Thus, the most convenient approach is simply to start SerialEM after installing a new version and copy whatever file it tells you needs upgrading.  When running DM remotely, this entails copying the appropriate plugin to the remote computer and renaming it as needed, as described below in the section on To connect to DigitalMicrograph through a socket interfaceWhen running a Thermo/FEI scope remotely, a new version of FEI-SEMserver.exe or FEI-SEMserver-Win2K.exe would be copied to the scope computer.

    Existing properties, calibrations, and settings files are always compatible when upgrading; there is no need to recalibrate the program.

    Permissions and Running as Administrator.  Make sure that all files in the program folder (C:\Program Files\SerialEM) are readable by users.  Make sure that users can write to the configuration and data file folder, which is the default location for the gain references to be placed. In Windows 7/Server 2008, be sure to do this before starting the program.  Right click on C:\ProgramData\SerialEM, select Properties, then select the Security tab if it exists.  Select the appropriate user group, press 'Edit', and turn on 'Full Control'.  If there is no Security tab, select the Sharing tab, press Advanced Sharing, turn on 'Share this folder', press 'Permissions', then 'Add' the appropriate user group (or select 'Everyone') and turn on 'Full Control'.

    In Windows 7/Server 2008/Server 2012 with GMS 2.x or 3.x, it may be necessary to run SerialEM as Administrator.  One reason this can happen is that the COM connection between SerialEM and DigitalMicrograph works only if both are run as non-administrator or both as administrator. If there is an initial error connecting to the SerialEMCCD plugin, try right-clicking on the SerialEM shortcut and selecting "Run as Administrator".  If this is successful, you can set up any shortcut to run the program this way; right-click the shortcut, select Properties, select the "Compatibility" tab, and check "Run as Administrator".  However, running this way may make it hard to open files written by SerialEM, and is generally inadvisable from a security standpoint.  A better alternative to this requirement is to connect with a socket interface (see below) instead of the security-laden COM interface (or to not run DigitalMicrograph as administrator, if that is the issue.)

    When connecting with a JEOL scope on Windows 7, running as Administrator was always needed until recently.  When SerialEM has to be run as Administrator, if DigitalMicrograph is not also run as Administrator, SerialEM will probably fail to connect to it.  The alternatives here are to run DM as Administrator or, preferably, to connect with the socket interface.

    Determining IP addresses on a shared network.  When the SerialEM setup requires communication between two computers, it may not be straightforward to find out the IP address that is needed.  A general procedure is to open a Command Prompt window on each computer and run 'ipconfig'.  Look at the first three numbers in each IP address.  There should be one pair of addresses where those three numbers match between the computers (often 192.168.0 or 192.168.1).  You can then test the communication in each direction with the command 'ping' followed by the IP address of the other computer.

    Defining an Environment Variable.  In several situations, you may have to define a system environment variable to provide information for one of the components that SerialEM connects to.  The procedure is:

    Shortcuts, Command Line Arguments, and Administrator mode.  When users log in to their own accounts, users should start SerialEM by means of a shortcut on their desktops. After creating the shortcut, always edit its properties to start in a folder belonging to the particular user. That way, each user will have their own settings file, separate from the one that inevitably ends up in the SerialEM folder because someone starts SerialEM by clicking on the program itself. 

    When users all share one account, they can have separate settings if there is a shortcut for each user, which can be placed either on the desktop or in a folder on the desktop.  The framework files that we distribute provide a structure for holding settings files and shortcuts for each user in a folder 'UserSettings' under C:\Program Files\SerialEM (Windows XP) or C:\ProgramData\SerialEM (Windows 7).  To make files and shortcuts for a new user:

    1. Create a folder with the user's name under 'UserSettings'.
    2. Copy the contents of another user's folder into the new folder.
    3. Right click on the SerialEM shortcut in the new folder, select Properties, and change the 'Start in' entry from the previous user's name to the new one.
    4. For more convenient access, right click and drag the shortcut to the desktop or a common folder to copy it there, and rename the shortcut so it is distinguishable.

    Another option is to make settings files with different names, and set up a different shortcut for each user using the '/Settings=' command line argument described below.  However, since users may want to save multiple settings files, it is probably better to have a folder for each user.

    Do not run the SerialEM.exe in the package subfolder, or make a shortcut to that copy of the program.  If you do, the program will load all the plugins in that folder. Then it will complain about multiple microscope plugins and refuse to run.

    If you set up separate properties and calibrations for running at a different voltage, those files can be accessed by running with a separate shortcut.  As of SerialEM 3.3.1, this is done by having the shortcut include an argument specifying the subfolder where the files are located (see Setting Up for a Separate Voltage).

    Five other entries besides a subfolder are allowed as command line arguments on the target line of a shortcut.  They can be in any order, as long as they appear before a final subfolder for the location of system files, if any.  They are: 

    Note that a user's settings file contains an entry for the system path. A user can change this to point to a different location where the program will seek the Properties and Calibration files. This provides two possibilities: that the configuration files can be installed in a folder other than the default one; and that a different set of properties and calibrations can be set up for some circumstances, such as running a beta version of SerialEM. It also provides for the arrangement described next.

    As the program administrator, you should start SerialEM with the shortcut in the UserSettings/Setup subfolder (copy this shortcut to the desktop if you want.) When you start SerialEM with this shortcut, you will access the settings in this folder that might differ significantly from what people use for production use.

    Whenever you start the program to do some calibrations, turn on 'Administrator mode' (in the Calibration menu). In this mode (which has nothing to do with running as Administrator in Windows 7), you will get extra output from some calibration procedures, and you will also be protected from exiting without saving calibrations.  You can add a property 'StartAsAdministrator 1' to do this automatically during initial program setup, then remove it when you are done.

    The procedures below refer to a number of entries to be made or modified in the properties file. Each entry has a mixed case keyword followed by one or more values. See Property File Entries for more details.


    A Minimal Setup Procedure

    Do you find the full setup procedures daunting? Do you want to do just enough to get the program usable and try taking a tilt series? If so, for a Thermo/FEI microscope, you can do the setup in two stages, first going through all of the items indicated as Priority 1 below, then going back later and doing Priority 2 items. (It is strongly recommended that you not stop with Priority 1 items) When you read the explanation of some of the Priority 2 items, you may find that they are not relevant to your needs and can be skipped. In addition, there are some procedures documented below 'for the sake of completeness' which you can almost certainly skip.

    The initial minimal procedure would be:

    1. If you started with a generic Properties file, insert appropriate camera and magnification table entries (Starting with a Generic Properties File).
    2. Adjust the camera settings in the Properties file (see Initial Camera Setup ), paying particular attention to 'GainNormalizeInSerialEM', the first 3 items in the general camera parameter section, and the parameters for each camera.
    3. If you did not get an initial Properties file appropriate for your voltage and configuration, you need to check and set up the magnification table (Checking the Magnification Table ).
    4. Run a DigitalMicrograph script and a procedure in SerialEM to set the camera timing (Tuning Gatan Camera Timing )
    5. Calibrate image shift from the lowest M-mode magnification to the highest mag at which you want to try the program, following the procedures in Calibrating Image Shift and Pixel Size indicated by 'if you just want to get the program running'.
    6. Calibrate autofocus (Focus Calibration ).
    7. If you have an energy filter, calibrate magnification-dependent energy shifts ( Energy Filter Calibrations ).
    8. Perform the tasks in Final Tasks .

    After doing these items, you can work with the program and try doing a tilt series, but you will not be able to control the intensity during a tilt series unless you calibrate beam intensity for at least one spot size (see Beam Intensity ). Other specialized features will not work until the rest of the calibrations have been done.


    Starting with a Generic Properties File (Priority 1)

    If your properties file has not been configured for your scope yet, you can start with a generic file, but only on a Thermo/FEI scope.  The generic file does not contain many essential entries for JEOL or Hitachi microscopes.  If you download and unpack the GenericFramework.exe file, you should also download GenericProperties.txt from the Tools folder on the SerialEM download site (, rename it to SerialEMproperties.txt, and replace the file from the framework. Then download and incorporate camera properties and magnification table files from the Tools folder.

    1. At the place in the file that says 'INSERT CAMERA PROPERTIES', insert text from the most appropriate camera properties file in the Tools folder. Do this for each camera, increasing the number on the first line ('CameraProperties') by 1 for each camera.
    2. At the place in the file that says 'INSERT MAGNIFICATION TABLE', insert text from the most relevant magnification table file in the Tools folder. If none is relevant, then follow the procedure in Checking the Magnification Table when you get to that point in the procedures.
    3. For a Tecnai or Polara, search for the text 'SET TO' and change the values as appropriate for the KV or other features of your scope, as indicated in the comments. The values for 200 KV can be used for 120 KV.

    If the program is running under Windows XP or Windows 2000, you need to make the following modifications.

    1. In the Properties file, change 'ProgramData' to 'Program Files' in the entries for GainReferencePath and LogBookPathName.
    2. In SEMsystemSettings.txt and UserSettings/Setup/SerialEMsettings.txt, change 'ProgramData' to 'Program Files' in the entry for SystemPath.
    3. In the SerialEM and the UserSettings/Setup folder, right click on the SerialEM shortcut and select properties.  Change 'ProgramData' to 'Program Files' in the entry for the folder to 'Start in'.
    4. If there are any other settings files on your system with a SystemPath entry of C:\ProgramData\SerialEM, they should be changed similarly.  Also, any other shortcuts that start in C:\ProgramData\SerialEM should be changed.

    If you have a Gatan camera with GMS 2.x or GMS 3.x, you need these modifications to the Properties file:

    1. Fix the entry for the DigitalMicrographReferencePath.  It should be either 'C:\ProgramData\Gatan\Reference Images' under Windows 7/8/10 and Server 2008/2012, or 'C:\Documents and Settings\All Users\Application Data\Gatan\Reference Images' under Windows XP and 2000.
    2. Check the entries for DMGainReferenceName in the CameraProperties sections and make sure they end in '.dm4' instead of '.dm3'.


    Connecting with a Thermo/FEI Microscope through Plugin and Server (Priority 1)

    Ordinarily SerialEM's Thermo/FEI scope plugin interacts with a Thermo/FEI microscope using a COM connection to the Thermo/FEI scripting adapter, but this is not possible when running SerialEM on a separate 64-bit computer, such as a Gatan K2/K3 or Direct Electron camera computer, or on older 64-bit Thermo/FEI systems.  A connection is possible in these cases by using a network socket connection to a small server (FEI-SEMserver.exe or FEI-SEMserver-Win2k.exe) on the Thermo/FEI computer.  This server makes a COM connection to the scripting adapter.  The server needs to be started every time that a user logs in.  This server supports all interactions with the Thermo/FEI microscope, including acquisition from Thermo/FEI cameras (Eagle, Falcon, Ceta) and from STEM detectors.  It uses three or four consecutive ports for communications.  The server can also be used to run a 64-bit version of SerialEM on 64-bit microscope computers with older versions of Thermo/FEI software where a direct connection did not work. 

    Yes, You Need a Network Connection between the Computers.  SerialEM does not use DigitalMicrograph's serial-port based communication with the scope; it requires a network connection between the computers.   These points may be helpful if you do not have a connection.

    Setting Up the Plugin and Server.  These steps need to occur:

    When the server is started, a DOS window will appear with messages about connections as they occur.  When SerialEM starts, there will be a message in its log about whether the plugin loaded successfully.  If the connection fails, some debugging output is available in SerialEM by adding the property 'DebugOutput K'.  Debugging output is available in the server window by defining the environment variable FEISEMSERVER_DEBUG to 1 (for some output) or 2 (for very verbose output).  If 4 is added to the value, the server will attempt to put output in a log file at C:\Program Files\SerialEM\FEIServerDebug.txt if that folder exists.

    Moving an Existing Installation from a Thermo/FEI Computer to a 64-bit Computer.  If already have SerialEM running on a Thermo/FEI computer and want to run it on a 64-bit computer instead, some steps are needed in addition to the ones listed above:

    Upgrading to the New Plugin and Server from SerialEM 3.4.  As SerialEM will inform you when you upgrade, you need to update the FEI-SEMserver.exe on the microscope computer.   If you had to make a firewall opening for the one port before, open the additional three ports.

    Running 64-bit SerialEM on a 64-bit Thermo/FEI Computer.  This is more straightforward.  With a new system, first try to run the 64-bit version of SerialEM without the server.  If you get a message about the 'dark field element', use the server with these steps:

    Upgrading from a K2 to a K3 camera. This requires a few modifications of the SerialEMproperties.txt file and recalibrating SerialEM.  There are three cases to consider:

    1. To move SerialEM from a K2 computer to the K3 computer, copy C:\ProgramData\SerialEM from the K2 to the K3 computer, as well as any settings files elsewhere that you wish to keep.  Be sure to acquire these files before the K2 disappears!
    2. To move SerialEM from a microscope computer to the K3, first follow the instructions in Moving an Existing Installation from a Thermo/FEI Computer to a 64-bit Computer
    3. To keep SerialEM on the microscope computer, just modify properties as described next

    In any case, install a new version of SerialEM, one that is up to date with K3 support.

     When changing to a very different camera, it is usually a good idea to give the new camera a different number.  This is probably not necessary for a K2 to K3 change, but all the camera parameter sets in settings files will have under-sized images and exposure times too long and will need to be adjusted appropriately.

    Change the properties file as follows:

    The section Measuring Camera Gain describes procedures for determining LinearToCountingRatio and K3CDSLinearRatio (relevant with GMS 3.31.2336 or higher, which support correlated double sampling).

    If there is a rotation by 90 or 270 and a flip in the camera configuration, check if your version of DM still has the rotation bug described in Remaining Problems with the K3 by taking an image without and with dose fractionation to see if they have the same orientation.  (The bug is gone in 3.31.2336.)

    The required recalibrations are:


    Initial Camera Setup (Priority 1 and 2))

    You should set the basic properties of your camera(s) in the properties file before starting SerialEM. If you received a file configured for your scope, most of this should be set up already, but you should go through these lists of items to find the ones you do need to change and to become more familiar with the intricacies of camera setup. If you are going to set GainNormalizeInSerialEM to 0, you do not need to specify UsableArea, BadColumns,or DMGainReferenceName. However, gain normalizing in SerialEM has several advantages for CCD cameras, including faster image acquisition, the ability to retain many dark references, and the ability to remove X rays from dark references. (DigitalMicrograph maintains only one dark reference per binning, which may force a lot of unneeded dark reference acquisitions when switching between parameter sets, unless dark references are coming from a file.)  Newer Gatan cameras (K2/K3 and OneView/Rio) will always normalize in DigitalMicrograph.

    Camera Configuration for Image Orientation.  Before you start any calibrations, make sure that your camera is configured so that images acquired on the camera have the same orientation as images on the viewing screen. If you have a Gatan 4-port readout camera with First Light controller, the camera configuration should generally be set in DigitalMicrograph to flip images around the Y axis. If for some reason the image orientation cannot be made to match that on the viewing screen (e.g., the orientation cannot be changed, or other software or other users require the odd orientation), then you may need to set properties to compensate. If there is a rotation, you would need an ExtraRotation entry for that camera. If the image is flipped, you would need an entry for InvertStageXAxis, which is a global setting, and possible an ExtraRotation entry too.  In any event, after you have settled on a camera configuration for a Gatan camera, add a 'DMRotationAndFlip' property for each camera to get a warning if the configuration is changed from this setting.  Having this entry can save a lot of time figuring out what is wrong when the configuration gets changed.  The number to enter with the property is the rotation in DM divided by 90, plus 4 if there is flipping around the Y axis (e.g., typically 4 for an UltraScan).  Here are all the possibilities:

    Setting in DM Configure Camera DMRotationAndFlip RotationAndFlip  for K2/K3
    No rotation, no flip



    90 degree rotation, no flip



    180 degree rotation, no flip



    270 degree rotation, no flip



    No rotation, Flip around Y



    90 degree rotation, Flip around Y



    180 degree rotation, Flip around Y



    270 degree rotation, Flip around Y



    General camera related parameters (and a few other things that could be dealt with later, but you might as well attend to them now or be aware of them.) (First 3 are Priority 1):

    Parameters for each camera (many relevant only to Gatan cameras, all Priority 1):

    For a Tietz camera, attend to the following settings:

    To connect to DigitalMicrograph through a socket interface on the same or a different computer, such as for a K2/K3 camera with SerialEM running on a Thermo/FEI microscope, you need to do the following:

    For a K2/K3 camera in particular, there is more to do:

    To set up a OneView or Rio camera to save frames, two camera property entries are needed and one or two others may be as well.  Frame handling is done through the SEMCCD plugin to DigitalMicrograph, exactly as it is done for K2 and K3 cameras, so many of the same options are available.  Specifically, the frame alignment is done with the same framealign module used for all direct detectors in SerialEM, which is designed for very low dose frames and can run on a GPU.  For such frames, is likely to be better than the intrinsic drift correction in DigitalMicrograph, provided that the frames provided to the plugin are of similar quality to those used internally.  However, for higher-dose images, this frame alignment will be slower and no better than drift correction.  If you have no plans to try the alignment for low-dose work, it is probably best not to enable the interface, to avoid confusing users with two alignment methods.

    For a Direct Electron direct detection camera, particularly if you are upgrading from a version before SerialEM 3.4, note these points:

    For a Falcon 2 camera that can save intermediate frames, under original scripting interface:

    For a Falcon 2 camera under the new advanced scripting interface:

    For a Falcon 3 or 4 camera with the advanced scripting interface:

    For a Falcon 3 camera with the standard scripting interface: You will be able to take images in linear mode only, with no possibility of frame saving or alignment.  SerialEM will scale images by their exposure times and adjust this scaling so that binning is done by averaging.  The scaling can be adjusted by factors of 2 with the property 'Falcon3ScalingPower'.  The property 'RelativeGainFactors 1 0.25 0.0625' is needed.

    For a Ceta 2 camera (Ceta with speed enhancement option):

    You can save and/or align frames from a Ceta camera with the speed enhancement option if you have microscope server version 7.8 or higher with Advanced Scripting installed.  These property settings are relevant:

    To use a GPU for aligning frames in SerialEM with any of these Falcon configurations or the Ceta 2:

    For accessing a JEOL camera or STEM signals, copy the file JeolCamPlugin.dll from the package directory to the main SerialEM directory.  (The file could be placed in a 'Plugins' folder inside C:\Program Files\SerialEM instead, but this is no longer necessary and could fail on some computers.  If there is already a copy of this file there, remove it.)  If SerialEM is running on the JEOL PC, this is all that is needed, in addition to an appropriate set of camera properties.  In this situation, the first time that you start SerialEM on Windows 7 or above, you need to run it as Administrator to guarantee that various JEOL DLLs can be copied to the SerialEM directory.
    If SerialEM is running on a separate PC, it can still access these cameras by connecting to a server running on the JEOL PC.  Copy either JEOL-SEMCamServer32.exe or JEOL-SEMCamServer64.exe to the JEOL PC, depending on whether it is running 32-bit or 64-bit JEOL software.  Put it in some logical place (C:\Program Files\SerialEM could be created just for this purpose) and make a shortcut to it on the desktop so that it can be run easily.  By default, this connection uses port 48896, although a different port can be used by defining the environment variable JEOL_SEM_SERVER_PORT with the port number on the JEOL PC. You also need to add the properties (with the appropriate port number)
        SocketServerIP 4 ip_address_of_JEOL_PC
        SocketServerPort 4 48896

    On Windows 7 or above, the first time that you start this server, you need to run it as Administrator to guarantee that various JEOL DLLs can be copied to the folder where the server is located.

    For accessing a Tietz camera remotely, copy the file Tietz-SEMServer.exe to the Tietz camera computer.  Put it in some logical place and make a shortcut to it on the desktop so that it can be run easily. By default, this connection uses port 48897, although a different port can be used by defining the environment variable TIETZ_SEM_SERVER_PORT with the port number on the Tietz PC. You also need to add the properties (with the appropriate port number)
        SocketServerIP 5 ip_address_of_Tietz_PC
        SocketServerPort 5 48897

    After you have checked out these settings, you are finally ready to run SerialEM and try taking some pictures. Experiment with the different camera parameter sets, varying the binning, the area being acquired, and the shuttering selection if appropriate. You may have to take a gain reference in SerialEM before you can get a gain normalized image. If you run into problems, try taking unprocessed and/or dark subtracted images as well as varying the binning and image area to see under which conditions the problem occurs.


    Bad dialog sizes or bad program and font sizes

    As of SerialEM 3.8, the program fully supports scaling for the DPI of the monitor, and it should work properly without any property settings related to DPI.  When you start SerialEM, you may discover that the control panels on the left are not all the same width, and that some text appears truncated in the control panels or dialogs.  This happens when there is a mismatch between the actual DPI setting of the display and what the program thinks it is.  You may also find the the whole program window and its fonts are too large or too small.  If there is a sizing problem, check the properties file for the entry 'DisplayIsNot120DPI' and try removing it if it is there; the property 'AssumeDPI' can also be used to scale the program for a different DPI than the one that the system reports.  See the description of these two properties in Property File - General Properties.  Set the property 'DebugOutput' to 1 to get a report on the detected DPI during program startup. 


    Initial Actions and Other Special Features for Hitachi HT7700/HT7800 (Priority 1)

    The Hitachi HT7700 has some design features that require special calibrations and particular care when first setting up SerialEM for it.  A number of deflector setttings are remembered when you leave a particular state and reimposed when you return to it.  This is a good thing if it maintains an alignment of some kind, such as to keep images aligned when changing magnification.  However, it becomes a problem if the same deflector is used by SerialEM to control a feature like image shift.  In such a case, it is necessary to record the values that the scope wants to reimpose, so that it is possible to make an appropriate change after the scope has reset the parameter.

    1.  With SerialEM not running, check the alignment of the mags in LM mode and HR mode following the procedure described in full detail in Neutral IS Values.  In brief, step through LM mode and make sure that the mags are fairly well aligned, adjusting the IA deflector as needed.  Either IA or PA can be designated as the image shift deflector to be used by SerialEM.  Step through HR mode and either adjust the deflector in question, if it is the one being used to align the mags, or make sure it is zero if the other deflector is being used for alignment.
    2. Return to HC mode before starting SerialEM.  Run the Neutral IS Values calibration to record the deflector settings in LM and HR modes.
    3. Run the Base Focus Values calibration to record the objective lens values that the scope imposes for each mag.  Once this is run, the Defocus readout in SerialEM should not change with mag.

    Another consequence of the microscope's behavior is that operations using image shift in LM and HR modes will leave the mags misaligned after SerialEM exits, because SerialEM does not clear out the image shift before leaving a mag.  If this is a problem, users can be told to run the Restore Neutral IS routine before leaving SerialEM; this will put the deflectors back to their stored values.

    Calibrating beam shift between spots.  When changing to a spot size, the microscope reimposes the last beam shift seen at that spot size. This interferes with SerialEM's shifting of the beam for various reasons.  Thus it is necessary to calibrate the actual beam shifts needed to align the spots, which allows SerialEM to maintain a desired beam shift when changing spots.  This should be done with Spot Beam Shifts in the 'Calibration-Beam & Spot' menu before aligning spot intensities.

    Image shift, pixel sizes, relative rotations, and shift boundaries.  The effect of the image shift deflectors is nearly constant over some mag ranges in HC mode, but varies progressively at lower mags and has at least one jump in higher mags.  Similarly, the effect of the IA deflectors in LM is nearly constant until the lowest mags.  This makes the behavior unlike a Thermo/FEI scope, where image shift is invariant at the specimen, and much like a JEOL for those mag ranges.  In consequence, the full calibration of image shift, pixel size, and relative rotations at all relevant mags is advised for the most reliable performance, although in principle the image shift calibration could be relied on for pixel size and rotation information in the portions of mag ranges where image shift is nearly invariant.  Once calibrations are done for HC and LM modes and inserted into properties, the List IS Vectors command should be run to identify image shift boundaries, which should be specified in the OtherShiftBoundaries property.

    HR mode.  Image shift in HR mode can be done with either the IA or PA deflectors, boh of which provide projector-like image shift, but neither provides the invariant image shift on the camera seen with projector shift on a JEOL.  The program automatically identifies every mag in HR as an image shift boundary.  It should be possible to do the usual spatial calibrations in HR mode, but there may be some other problems.  It is not known whether beam crossover is consistently different in HR mode and would need to be stored separately.  It is also possible that, even with a difference in crossover taken into account, beam intensity calibrations would need to be stored separately for HR mode.

    Stage calibrations with waffle grating.  The stage on the HT7700 appears to have rather long-range backlash effects, so the default backlash correction for stage montages and calibrations is set rather high.  However, cyclical variation in stage movement appears not to occur, and thus it is safe to do stage calibrations over an extent of only 40 microns.  This means that the waffle grating can be used, provided that one starts in the very middle of a grid square.   Such an extent is now the default for non-Thermo/FEI scopes.


    Checking the Magnification Table and Calibrating Neutral IS Values (Priority 2 on Thermo/FEI scope, Priority 1 on JEOL)

    You should start with a properties file that has a magnification table but does not have any 'RotationAndPixel' lines in it.  The procedure is to start SerialEM and run the 'List Mags' command from the 'Calibration' menu. Compare this listing with the magnification table in the properties file. If it matches, you are ready to go on. If not, you need to cut and paste the output of 'List Mags' into the properties file. On a Thermo/FEI scope, step through the mags with the screen down and type in the mag that the microscope user interface shows. On a JEOL, the third field can be left blank or filled with 0's.

    On a Thermo/FEI scope, now that you know the relation between mag index and mag, find out which is the lowest mag in M mode and verify that LowestMModeMagIndex is correct. On the JEOL, the routine will provide this value.

    On the JEOL, following this magnification table will be a table of camera lengths for using diffraction mode. This table should be inserted in the properties file if it is not already there. The first line added to the properties file should be 'CameraLengthTable nn', where 'nn' is the number of lines of camera lengths that follow.

    If you have a post-column energy filter, repeat these steps with EFTEM mode on.

    For a JEOL, it is very important to calibrate the neutral values of image or projector shift (whichever is being used in your setup), so that the program can maintain the actual image shift correctly between magnifications.  Simply run Neutral IS Values in the Calibration menu.  This calibration needs to be redone whenever there is a service alignment of the magnifications.


    Measuring Relative Gain Factors for Thermo/FEI, Tietz CMOS, and other Cameras (Priority 1)

    The gain of some cameras varies with binning, and it is necessary to have a property indicating the change in gain in order for dose calculations and intensity-related operations to work properly, including the acquisition of a gain reference.   For some newer cameras, the factors are predicable; for others, like the Thermo/FEI Eagle camera, OneView, Rio, and perhaps some EMSIS cameras, the factors must be assessed. To do this, set the 'Trial' parameters for a full-field image at the maximum binning.  Use a dark-subtracted image if normalizing in SerialEM and there is no gain reference yet.  Set the exposure time to 0.2 second and adjust the beam intensity so that 'Trial' gives an image with counts between 1/2 and 3/4 of the saturation level. Take an image and use 'Ctrl-I' to get the mean counts in the image. Repeat at each binning down to 1, without changing the exposure time.

    For each binning 'n', compute the gain factor as

    (counts at binning n) / ((counts at binning 1) * n * n).

    Add a single line to the CameraProperties section of the properties file,

    RelativeGainFactors 1.0 f2 f4 f8

    Where f2, f4, and f8 would be the factors measured for binnings 2, 4, and 8.  For the Eagle, these factors should be about 0.35, 0.16, and 0.13. 

    Relative gain factors are also needed for the Tietz CMOS cameras: F816, F416, F216, and XF416 with their default setup, but here the factors are known and there should be no need to measure them.  Simply take an image with binning 4, then with binning 2 and 1 with the same exposure time.  With the default setup, the images should have the same counts, and the camera properties would need the line

    RelativeGainFactors 1 0.25 0.0625

    It is possible to set the configuration for DE cameras to bin by averaging instead of summation, in which case the gain factors are needed there as well.  If there are binnings of 1, 2, and 4, the line just above will work; if there is a binning 8, the line needs 0.015625 at the end.

    The Falcon 3 and Ceta 2 cameras also have relative gain factors to keep the number of counts constant with binning; the line above will work for Falcon 3, and for Ceta2 it needs 0.015625 at the end.  With the new Thermo/FEI camera scripting interface, the same behavior can be imposed for Falcon 2 and Ceta 1 camera by adding the camera property 'AutoGainFactors 1'.

    Gain factors may also be needed for a Gatan OneView or Rio camera, so the relative gains should be measured as described above.  Be sure to turn off 'Correct drift' in the Camera Setup dialog before taking images without alignable features, since intensities will be wrong if some frames cannot be aligned.  If a factor is not 1, it will be exactly the inverse of a power of 2.  On some OneView cameras these factors have been '1 0.25 0.125 0.0625'; on others, no factors were needed.


    Tuning Timing of Gatan Camera with Two Shutters (Priority 1)

    Camera timing settings are important for proper function of SerialEM's 'Dual shuttering - minimum exposure' option, which is needed to minimize specimen exposure using the standard shutter and to provide a flexible range of drift settling times with older Gatan CCD cameras. Measuring them involves two steps: using a DigitalMicrograph script to estimate the BuiltInSettling, or clear time of the CCD chip; and using a procedure within SerialEM to determine the average delay for an exposure to start after SerialEM issues a request for one, and the variability in this delay.

    If the camera controls only one shutter, skip the DigitalMicrograph script and just follow the procedure described in the next section. It is not so important but it will to provide a check on the timing for performing tasks after an exposure.

    To estimate BuiltInSettling for a CCD camera, open the 'cleartime.s' script available from the Tools folder on the SerialEM download site. You can do this with the File - Open menu entry in DM, or just by clicking on the file. Run the script by pressing Ctrl-Enter. It will time a series of exposures and report the mean time. It will then recommend values for BuiltInSettling based on subtracting 0.155 second for large format one-port readout cameras (Megascan 795 and Ultrascan 890, 2Kx2K 30-micron pixel or 4Kx4K 15-micron pixel) or 0.065 second for the four-port readout Ultrascan 895. These correction factors are based on the 4 cameras that I have been able to run the script with.  The script is of no use with CMOS cameras like the K2/K3 and OneView.

    If you have more than one camera, change the 'cameraNumber' value at the top of the script and rerun it.

    Once you have entered a correct value for BuiltInSettling in the properties file, restart SerialEM. Change the 'Trial' camera parameters so that the exposure time is 0.4 seconds and set the binning to get a 1024x1024 pixel image. Take a 'Trial' picture without a specimen and adjust the beam to give an image with moderately high counts (between 1/3 and 3/4 of camera saturation). Then select Camera Timing in the Calibration menu and accept the default entries. This routine will take 100 exposures with timing parameters that will allow it to estimate the delay time for the exposure to start from the image intensity. It will recommend values for StartupDelay, MinimumDriftSettling, and ExtraBeamTime, and it may also recommend a change in BuiltInSettling to keep StartupDelay from being negative. Insert these in the properties file entries for the particular camera. There will probably also be a recommended value for MinimumBlankingTime which you should insert along with other general camera-related properties near the top of the properties file. If you have more than one camera, repeat the procedure with the other camera.

    You should rerun the camera timing procedure and adjust your properties entries if there is a computer upgrade, a major software upgrade, or the addition of an energy filter. The timing may also depend on whether images are gain-normalized in DM or in SerialEM, so rerun the procedure if you change the GainNormalizeInSerialEM property.


    Measuring Camera Timing for Non-Gatan Camera or Gatan Camera with One Shutter (Priority 2)

    Calibration of the timing of other kinds of cameras, or a Gatan camera with only one shutter, is needed for two reasons: 1) in general, an approximately correct value of stratup delay is needed for delays after image shift and other drift-producing actions to be imposed correctly; 2) for some cameras, it will allow the program to takes actions (e.g., tilt and image shift) during image readout or frame-saving. For Thermo/FEI or DE cameras, these actions are not allowed because the timing is inherently more unpredictable. Change the 'Trial' camera parameters so that the exposure time is 0.4 seconds and set the binning to get a 1024x1024 pixel image. Take a 'Trial' picture without a specimen and adjust the beam to give an image with moderately high counts (between 1/3 and 3/4 of camera saturation), except on a K2 or K3.  The timing routine will use super-resolution mode for a K2, and does not need very high counts. Then select Camera Timing in the Calibration menu and accept the default entries. This routine will take 100 exposures with timing parameters that will allow it to estimate the delay time for the exposure to start from the image intensity. It will recommend values for StartupDelay and ExtraBeamTime. Insert these in the properties file. If the procedure measures a delay successfully, then you can set DefaultActAfterExposures to 1.  For a K2, you will probably see output that suggests just using the default minimum startup delay.  See Camera Timing for details on this and on the signs that the startup delay is too short.


    Setting Tietz and Eagle Camera Binning Offsets (Priority 1 for Eagle and some Tietz)

    Some Tietz F224 cameras have had a problem with gain-normalization of binned images, although F415 cameras have not shown this problem. The same problem has appeared on 4K and 2K Eagle cameras. Although the problem can be solved by making separate gain references for the different binnings, a more convenient solution (for the user) is to use 'BinningOffset' entries in the camera properties section. Here is a procedure that uses cross-correlation and does not require a trained eye to see the offsets:

    1. Set camera parameters and the beam to take a dark-subtracted, unbinned 2Kx2K image of a blank field with a medium number of counts. For a 4K camera, take a center half image. For a 1K camera, take a full image and divide the sizes below by 2.
    2. Take the unbinned image and save it as; close the file.
    3. Change to binning 2, reduce the exposure time appropriately, take an image, and save to
    4. Repeat this procedure for each binning, taking the same area of the camera and saving to a separate file.
    5. On an IMOD-capable machine, run:
      newstack -siz 2048,2048 -exp 2
      newstack -siz 2048,2048 -exp M (for each higher binning M)
      newstack -siz 1024,1024 -exp 2
      newstack -siz 1024,1024 -exp M/2 binMxM/ (for each higher even binning M, where M/2 is a single digit, m divided by 2)
    6. You can now correlate each fully expanded binned image against the unbinned image with:
      clip corr -2d corr.tmp
      clip corr -2d corr.tmp (for each higher binning m)
    7. Each correlation will end with a line like: 'Maximum at ( -0.00, 0.99), transformation ( 0.00, -0.99)'. The binning offsets are the values of the maximum coordinate, rounded to integers. For example, if this result was obtained for binning 4, you would need an entry 'BinningOffset 4 1 0 1' in the Properties file. The '4' refers to the binning of the image, the first '1' refers to the binning of the gain reference, and the next two numbers are the offsets in X and Y.  However, for a 2K Eagle camera, it is possible to end up with an offset that is not close to an integer because the unbinned image is actually binned by 2 on the chip; for all comparisons with the Eagle 2K, follow the instructions in points 9 and 10 instead.
    8. At least one Eagle camera has been seen where two halves of the image had different alignment between different binnings; e.g., the top shifted up and the bottom shifted down between binning 1 and 2.  Thus, even when the correlation gives an integer offset, you should look at the pair of images that you correlated in 3dmod (e.g., '3dmod').  Zoom up to at least 1 so that you will see subpixel shifts and toggle between the images to make sure they line up the same in all four quadrants.  You could instead open them in midas (e.g., 'midas -r'), use Ctrl-middle mouse button to set the center for correlation, and use 'Cross-Correlate' to measure the shift in each quadrant.
    9. You can now correlate each higher even binning against the binned by 2 image:
      clip corr -2d corr.tmp
      clip corr -2d binMxM/ corr.tmp (for each higher even binning M)
    10. Again, the offsets are the values of the maximum coordinate, but only if they are close to integer values. If they are, then you would add an entry like 'BinningOffset 4 2 0 1', where again the first number is the binning of the image and the second is the binning of the gain reference.  Again, for an Eagle camera, make sure the offsets are uniform by opening in 3dmod or correlating in midas.
    11. If an offset is close to halfway between two integers, then it is not possible to synthesize a good gain reference for the given binning from a binned by 2 reference. In this case, you need an entry like 'BinningOffset 4 2 999 0'. The '999' tells the program not to make a reference for binning 4 from the binned by 2 reference.

    Binning offsets are also needed for Gatan 4-port readout cameras but these offsets are predictable and the program will set them up automatically.


    Assessing Standard Focus for Low Mag Mode (Priority 2)

    This assessment should be done before the low magnification image shift and pixel size calibrations needed to use the Navigator. The ill-defined nature of focus in Low Mag mode means that it would be easy for a user to set a focus that creates two problems: 1) image scale might be significantly different from the scale at the focus at which calibrations were done; 2) the image position might depend on beam position to an extent that makes localization of positions problematic when using the Navigator. The solution is to use a standard focus for the calibrations and for mapping in Low Mag mode. This standard focus should be one that minimizes beam-position dependent image movements. The procedure is this:

    1. With a specimen in place, go to a mag near the top of the Low Mag range and set the focus to Eucentric focus (on a Thermo/FEI scope) or to the standard focus (on the JEOL).
    2. Move the beam and watch how much the image moves. Change the focus until you see substantial image movement; vary the focus until you can tell whether the standard focus is near the point where image movement is minimized. If so, on a Thermo/FEI scope, you are done; on the JEOL, return to standard focus and skip to step 4.
    3. If image movement seems excessive at the standard/eucentric focus, adjust the focus to minimize the beam-dependent image movement.
    4. Select Standard Focus in the Calibration menu to record this focus as the standard one for this magnification. It will be used at all low magnifications if it is the only such calibration.
    5. If different focus levels are needed at different magnifications, repeat this procedure at multiple magnifications. Or, on the JEOL, go to the standard focus at the various magnifications and record the calibration.


    Focus Calibration (Priority 1)

    In principle, focus only needs to be calibrated at one magnification as long as there are image shift and/or other calibrations available to transfer the focus calibration accurately to other mags. Typically, this calibration should be at a mag in the range where data will be acquired.  However, when using the procedures below for calibrating image shift and pixel size, it may also be helpful to have a focus calibration at the mag where these calibrations will be started. In addition, to use the  Eucentricity by Focus routine over a wide range of conditions, you may need to have an 'extended' focus calibration instead of the regular one at the highest magnification, or an extended calibration at a lower magnification to be used when focusing with the View area in Low Dose mode.  See Extended Autofocus and Non-reciprocity Calibration for Using Eucentricity by Focus below for details.

    Set up the Focus parameter set to give moderately good, quick pictures with a binning of at least 2. For a camera where smaller images come out significantly faster, wide quarter and center half are two possibilities; if you have a smaller format camera, use a center half area.

    Before calibrating focus, you should adjust the beam tilt so that the beam-tilt induced image shift is roughly 30 nm when defocused by 10 microns.  Here is a procedure for this adjustment:

    Change to your chosen magnification and start the focus calibration procedure (see Autofocus for more details.) Accept the defaults to calibrate a nice big range of defocus.  The image shift calibrations will be started at a mag where the field of view is about 3 microns.  If this mag is far from the one where you calibrated focus (say, a factor of 2 or more), calibrate focus there as well.


    Calibrating Image Shift and Pixel Size (Priority 1 and 2)

    The procedure described next involves calibrating the image shift at a series of magnifications and saving that information in the calibrations file, as well as taking a series of images and measuring the magnification and change in image rotation directly from them and entering this information into the properties file. How much of this you need to do depends largely on the type of microscope and on whether you intend to use the Navigator, as detailed in the table below. The goal here is to calibrate not just the image shift at each magnification but also the relationship between specimen and camera coordinates, specifically the pixel size on the specimen and orientation of the specimen axes on the camera. The basic principles underlying the calibration requirements are:

    1. If image shift is calibrated at two magnifications and pixel size or axis rotation are known at one, the pixel size or rotation can be derived at the other, provided that the relationship between image shift and position on the specimen is the same at both magnifications.
    2. Image shift calibrations are intrinsically somewhat more accurate and convenient than direct measurements of pixel size and axis rotation as described below, although both pixel size and relative rotations can be obtained easily by automatic analysis of the cross-line grating.
    3. It is thus preferable to calibrate image shift thoroughly and derive pixel size and rotation where appropriate, rather than the converse.

    The minimal requirement is to measure one pixel size in each magnification range where the relationship between image shift and movement on the specimen is constant, and to measure an absolute rotation angle somewhere plus the rotation of images between those magnification ranges. On Thermo/FEI scopes, there are typically just two such ranges, LM mode and regular mag mode. However, some Talos microscopes have show variations in the strength of image shift at the lowest few nonLM magnifications, where additional measurements of pixel size and rotation angle are required  It is possible that Glacios would have the same problem.  On JEOL and Hitachi scopes, there are often multiple ranges together with progressive changes in image shift strength within a range. In practice, it is recommended that redundant measurements be made, and the procedures have been refined to ease this task.


    Setup for Work at Regular Mags Only

    Thermo/FEI scope   JEOL and Hitachi
    Image shift from lowest nonLM-mode to highest mag needed   Image shift from lowest non LM-mode to highest mag needed
    Minimal requirement: one pixel size, one absolute rotation angle in regular mag range if no image shift boundaries   Minimal requirement: one pixel size in each image shift range, relative rotation across each boundary, one absolute rotation angle
    Recommended: Pixel size for all mags where data is likely to be taken and at image shift boundaries (rotations optional except across image shift boundaries)   Recommended: Pixel size and relative rotations between all mags from lowest non LM-mode to highest mag needed

    Setup for Navigator Use in LM Mode

    Thermo/FEI scope   JEOL and Hitachi
    Check that eucentric focus in LM mode gives minimal image shift with beam movement, set a StandardLowMagFocus property if not   Check that standard focus in LM mode gives minimal image shift with beam movement, set StandardLowMagFocus property
    Image shift for all LM mags down to lowest needed   Image shift for all LM mags down to lowest needed
    Pixel size at highest LM mag   Pixel size for all LM mags down to lowest needed
    Relative rotation from highest LM to lowest nonLM mag   Relative rotations between all mags, from lowest LM needed to lowest non LM mag
    Stage calibration: lowest nonLM-mode mag, 2 or 3 mags in LM   Stage calibration: lowest good non LM-mode mag, 2 or 3 mags in LM
    Image shift offsets from ~10-20K down to lowest LM mag may be needed   Image shift offsets from ~10-20K down to lowest LM mag may be needed


    Thermo/FEI: For work at regular magnifications, calibrate image shift from the lowest nonLM-mode mag up to the highest mag where tilt series might be taken. It is recommended that you calibrate pixel size over the range of magnifications where users would typically expect an accurate pixel size, using the procedures described below, which will also yield relative rotations. For Talos and Glacios, run that procedure down to the lowest nonLM magnification in case image shift is not invariant at the lowest few maginfications.  You should definitely enter a calibrated rotation angle for one mag at which tilt series are typically run, or a rotation angle from a stage calibration at a lower nonLM magnification.

    To enable Navigator use, measure the pixel size with the calibration grating at the highest LM-mode mag. Switch to a non-periodic specimen suitable for lower mag work and calibrate image shift at all LM mags down to the lowest mag that might be needed for grid mapping. Do the other steps listed in the table, described in other sections.  Use the stage calibration to obtain an absolute rotation angle in LM.

    JEOL: Image shift shows discontinuities at a number of lower mags in the regular mag range and is not as constant as one might wish even within the ranges. Thus, it is necessary to calibrate image shift as well as measure pixel size and rotation between mags up to the highest mag at which tilt series might be run. A calibrated rotation angle is also needed for one mag at which tilt series are typically run.

    To enable Navigator use, image shift calibrations as well as pixel sizes and relative rotations are needed throughout LM mode, down to the lowest mag needed for mapping. Before following the procedure below for regular mags, start at the lowest LM mode mag needed, go to standard focus, and take and save pictures of the calibration grating at each mag. You may be successful at calibrating image shift with this grating, but it is more reliable to use a specimen suitable for low mag work instead.

    On a JEOL or Hitachi, the beam is not moved along with the image, so SerialEM needs to apply beam shift whenever it does an image shift. This will not happen until you do a beam shift calibration, which needs to be done after at least one image shift calibration. Thus, you need to spread the beam to at least twice the size of the CCD camera to get through the image shift calibrations successfully.

    Other preliminaries: The image and stage shift calibrations are the ones that give the most trouble for inexperienced users (and sometimes for experienced ones too).  There are several things you can do to minimize problems:

    A script for image shift and pixel size calibrations: Open a script editor for an unused script.  For example, select 'Edit 10' in the Script menu and then click the right arrow if necessary until there is no text in the window.  Select, copy, and paste the following:

    MacroName IS-Pixel
    IncMagIfFoundPixel 1
    SetupWaffleMontage 5 wafflemont-$repVal1.mrc
    If $repVal1 == 1
      Copy B A

    The script will change magnification only if pixel size has not been found yet (so it can be stopped and run again after changing conditions, for example).  With the 1 after 'IncMagIfFoundPixel', it will increase mag; with a -1, it will decrease it.  Then the script will take a Trial picture so that you can see right away if conditions are suitable.  It will autofocus, then calibrate the image shift.  It then obtains an image for measuring the pixel size that has at least 5 grating blocks in each direction.  This will be a single image if possible; otherwise the program will open a file for a montage of the correct size and take a montage.  Finally, it will find the pixel size.

    The script will open a montage file in the current directory, whatever that happens to be.  To have the files opened in a defined location, add a complete path in front of the filename 'wafflemont...'.

    The procedure: This section describes the operations on the microscope for calibrating pixel sizes and image shifts.  The commands are all in the Calibration - Pixel Size submenu.

    To get set up for the procedure, do the following:

    1. Place a standard cross-line grating with latex speeres in the scope (2160 lines per mm).
    2. Pick an area with a fairly high density of spheres (but not a large continuous clump that would obscure the grating lines).
    3. Make sure your chosen field of view is eucentric.
    4. Use a moderate objective aperture like 40 microns for contrast.
    5. For convenience, turn on whatever microscope feature keeps beam brightness constant across mag changes (intensity zoom on Thermo/FEI).
    6. Turn off 'Align on Save' in the Buffer control panel (in the options section). Also set the 'Roll Buffers' selector to M or N.
    7. Go to a magnification where the field of view is about 3 microns (at least 6 grating squares visible).
    8. Set up the Trial parameter set to take full-field 512 x 512 images, or 1Kx1K images on a direct detector, and set the exposure time as well as the beam strength to get a nice clean picture.
    9. Set up the Record parameter set to take full-field 1K x 1K images with up to 4 times the exposure time as the Trial images.
    10. Turn on Administrator mode and open the Log Window.
    11. Run 'Autofocus'.
    12. Run IS from Scratch. If this succeeds, the program should report that the result is 'good'.
    13. Run Find Pixel Size. At the end, you will see an autocorrelation of the grid image with the brightest spot in the middle and a square lattice of bright spots. Make sure that the green cross is on a bright spot adjacent to the center spot along a lattice axis and not along a diagonal from the center point; see the help for this command for details.  If the cross is not in the right place, mark the proper peak position and run Try Again with Marker.
    14. Run List Relative Rotations to get a RotationAndPixel line in the log.
    15. Copy and paste this line into the CameraProperties section for this camera in the properties file, and save that file.
    16. Save the calibrations with the entry in the Calibration menu.
    17. Exit and restart the program; turn on Administrator mode.

    Now that this pixel size is in place, the script can be used, because the program will be able to estimate correctly whether a montage is needed.

    Run the script repeatedly, going to progressively higher mags.  Aside from watching for problems and adjusting the beam as needed, watch out for any large (90 to 180 degree) rotations from one mag to the next. 

    The program is accumulating information about the relative rotation between successive mags, using the angles of the grid axes when finding pixel size.  However, these angles, and thus the relative rotations, are only known to the nearest 90 degrees, and it is up to you to make sure that they correspond to the actual rotation between mags.  You can do this all at once at the end, as long as you keep track of which mags could be wrong, or you can fix each large rotation as it occurs.  The procedure for fixing rotations is to run List Relative Rotations to see what the program thinks the relative rotation is (the second number on each line, after the mag index). Fix a value with the  Add 90*n to a Rotation command and rerun List Relative Rotations to make sure it now shows an appropriate relative rotation.

    If you reach a mag where the montages seem impractical, but you want image shift calibrations and pixel sizes above that point, then you can start changing mag manually, autofocusing, and running Image Shift Calibration from the menu.  On a Thermo/FEI scope, fairly accurate pixel sizes will be derived from the image shift calibrations.  On a JEOL or Hitachi, where image shift may not be invariant, you would have to take and save single frame images at each mag, starting with the last one where pixel size was measured, and follow the procedure below in Measuring further relative rotations and pixel sizes by aligning images. Alternatively, you can use catalase crystals; see the  Catalase Crystal command.

    When you have reached the highest feasible or needed mag, return to the starting mag, change the 'IncMagIfFoundPixel 1' to -1 in the script, and close any open montage files.  Start running the script to go to lower mags.

    On a Thermo/FEI scope, you can stop running this procedure at the highest LM mode mag (or even the lowest non-LM mode mag, if you have no need for calibrations in LM mode.)  To continue calibrating image shift throughout LM mode, it is best to switch to a non-periodic specimen, and preferably one with larger grid spacing suitable for calibrating stage shift.  However, you can try to finish the image shift calibrations with the replica grating if that is more convenient.  If you do, follow the procedures in the next section, On a JEOL or Hitachi.

    There is one potential problem to watch out for on Titan microscopes, mostly at the top of LM mode.  A very long settling time after lens normalization has been required on some microscopes.  The need for this will be revealed by a poor result on the first image shift calibration at the top of LM mode.  If this happens, first try running Remove IS Cal to make the program forget the bad calibration, then run the script again.  The 'ShiftCalSkipLensNorm' command in the script will keep the calibration routine from normalizing lenses again and causing the problem.  To continue calibrating image shift below this point, there are two options:

    1.  Save your calibrations, exit the program, and add a general property
      LowMagNormalizationDelay  12000
      (put this after the one for LensNormalizationDelay).  A value of 10000-12000 seems to be needed (10-12 seconds).  Restart the program and proceed with the calibrations.
    2. Set up a script
         Delay 9
      Change mag manually then run the script.

    On a JEOL or Hitachi, try to run the procedure in the script down to the lowest mag that might be used for mapping.  There are several things to watch out for and changes that may be needed:

    Assessing and setting image shift boundaries: This step is routinely needed on JEOL and Hitachi scopes, and should be done for Talos and possibly Glacios. After image shifts are calibrated, run List IS Vectors and examine both the lengths and angles of the vectors.  (If you have IMOD or a recent 3dmod package for Windows installed, you can use ListISVectorsToGraph and GraphPreStoredValues script commands to make graphs that are much easier to interpret.)  Places where there is a consistent change of more than ~2% should have an image shift boundary specified.  For example, here is a vector listing from a Talos Arctica using calibrated pixel sizes and rotations:

       17    1250        1.001          1.016      -28.6        60.2
      18    1600        0.991          1.008      -28.7        60.3
      19    2000        0.991          1.008      -28.8        60.4
      20    2600        1.086          1.096      -30.8        59.1
      21    3400        1.084          1.096      -30.8        59.2
      22    4300        1.084          1.098      -30.8        59.2

    There is a significant discontinuity between indexes 19 and 20.   The index to specify is the one above the discontinuity; thus 20 instead of 19 here.    The line needed in the properties file would be:
        OtherShiftBoundaries 20
    If there is one magnification out of line with the ones above and below, two indexes would be required.  Such a case should be treated as a boundary only after seeing if the magnification is still off in a vector listing based on the nominal magnifications and carefully checking both the image shift calibration and the pixel size for the aberrant magnification.

    Measuring further relative rotations and pixel sizes by aligning images: This procedure is needed only under the two circumstance described above.  Open a copy of the mag calibration spreadsheet. Set the binning and the size of the pixels on the CCD to the correct values. If necessary, adjust the magnifications listed in the first column. Take any unbinned pixel sizes printed in the log after running the Find Pixel Size routine and copy them into the 'Unbinned cal pixel' column (overwriting the formula that computes the pixel size from modeling measurements).

    Further processing is done in IMOD as follows. First use Midas to get a rough prealignment of the images:

    midas -b 0 filename.inixf

    For each image pair, change the magnification (Shift-right mouse button) so that they are close to matching, and shift and rotate as necessary to get into rough alignment. As long as they are aligned in the center, xfalign should be able to complete the job. If you can't match up a pair of images because the microscope is not well enough aligned, just skip the pair. Also, if you have good relative rotations from the pixel size routine, you could skip most of the images with pixel sizes: namely, from the second lowest mag up to the highest mag with a pixel size, you would not need to align the image with the one at eth lower mag.

    Save the transforms and run:

    xfalign -red 1 -bi -ini filename.inixf filename.xf

    (If for some reason you have 512x512 images instead of 1Kx1K, use '-red 0' instead of '-red 1'.) When it is done, restart Midas with:

    midas -b 0 filename.xf

    Look at each pair to make sure it is well aligned. Save the transforms. If you only have two images, you can skip the spreadsheet entries and proceed to putting two lines in the properties for this camera, e.g.:

    RotationAndPixel 16 999 999 10.5
    RotationAndPixel 17 158.17 999 9.90

    Where 10.5 and 9.90 are the pixel sizes measured for the two mags, 158.17 is the NEGATIVE of the rotation angle shown in Midas, and the 999's indicate unmeasured values. Skip to the section below to see how to enter the absolute tilt axis rotation.

    If you took a full set of images, copy the Midas rotation, magnification, and stretch values into the appropriate lines of the spreadsheet (the first image pair provides data for the second mag). The rotation is just there to keep a record of it, but the Midas mag and stretch are resolved into a single number, in the 'Midas delta mag' column. You may find it easier to run:

    xf2rotmagstr filename.xf

    This will list the rotation, magnification, and stretch values for each transformation in the file, as well as net magnification value on the right that you can put directly into the 'Midas delta mag' column. Unfortunately, xf2rotmagstr was broken and gave rotations with the wrong sign from IMOD 3.12.23 through IMOD 4.2.25. so be sure to use an IMOD version where it was not broken or invert the sign.  For the lower mags, you can compare the 'delta mag' values with the 'Delta pixel' values to see how accurate these two methods are. The real use of the delta mag's is to derive pixel sizes above the last mag where you could measure it directly.

    Suppose the last mag where you measured the pixel (or the last one where you trust the measurement) is on line 11.

    1. Put a 1 on that line in the 'Cumulative delta mag' column (cell J11).
    2. Put a formula in the cell on next line to multiply the cell above by the 'Midas Delta mag' on that line (J11 * E12 in J12), or just copy this formula up from the cells below. Either way, fill the cells below with this formula.
    3. In the 'Derived pixel' column, put a formula to multiply the last measured pixel value by the cumulative delta mag on that line (H$11 * J11 in K11). Copy this formula down to the cells below.
    4. The 'Unbinned pixel' column takes its values from the 'Unbinned cal pixel' column for low mags and from the 'Derived pixel' column for high mags. Copy formulas down from the top or up from the bottom so that all of the values in this column are based on the correct pixel size.
    5. The film magnification and unbinned and binned pixel sizes are copied to a table below the main one. Adjust the formatting of the cells in this lower table to show the desired number of significant digits. Print this portion of the spreadsheet and post it for users.
    6. The last column, 'Ratio', shows the magnification from film to camera. Average these numbers, or leave a few out if they appear out of line, to obtain 'FilmToCameraMagnification'.

    Enter the appropriate numbers from the spreadsheet in a series of 'RotationAndPixel' lines in the properties file. Each line should have:

    RotationAndPixel <Magnification index> <the NEGATIVE of the Midas rotation> 999 <Pixel size>

    Absolute rotation angle: The last number missing from the RotationAndPixel entries is an absolute calibration of the rotation of the tilt axis.  The angles from stage calibration should be used at lower magnifications, where the stage calibration routine is robust.  For medium to high magnifications, the angle is most reliably obtained from a fiducial alignment of a tilt series.  However, the angle from fiducial alignment can be off by 180 whereas the angle from an accurate stage calibration will always be in the correct quadrant, so you should always consult the results from stage calibration when setting this angle from a tilt series alignment. In IMOD, the angle by which the tilt axis is rotated from the vertical is shown in the 'Rot' column of the alignment solution log. If the value varies through the series, use the value from near zero tilt, which is summarized at the top of the solution. Once this value is available, replace the 999 on the RotationAndPixel line for the relevant mag with this value plus or minus 90 degrees (depending on which direction makes the angle match that from stage calibration). If you only measured one or two pixel sizes, this angle will most likely be measured at a different mag, in which case you would add a line such as:

    RotationAndPixel 23 999 77.5 999

    Where 77.5 is the measured absolute rotation.

    In general, it is good to add to the RotationAndPixel lines the angles from stage calibrations done at the lowest non-LM mode mag and the highest LM mode mag.  This is especially important if you do not enter an angle from a tilt series.

    You can also use the rotation angle from a stage calibration or tilt series alignment to adjust the entry for 'GlobalExtraRotation'. Both this entry and the 'ExtraRotation' for a particular camera are used as fallback values when there is no other source of an absolute rotation angle, but they both become irrelevant for a given camera once that camera has an absolute rotation value.  However, it could be useful to refine the value of 'GlobalExtraRotation' for use with other cameras. The basic principle is that the sum of the rotation angle in the magnification table for this mag (which could be wrong for a JEOL or Hitachi scope), plus the GlobalExtraRotation, plus the camera's ExtraRotation value, should equal the absolute angle on the RotationAndPixel line.


    Other Microscope Calibrations (Priority 2)

    Assessing Cycle Length of Compustage Movement Errors: In the SerialEM Tools is a file named cycleMacro.txt containing a script for assessing the error in stage movement over distances large enough to reveal the periodicity of these errors (this is described in more detail in Stage Shift Calibration). You will need the specimen suitable for stage calibrations described there and in the next paragraph. Open a script editing window with an Edit command in the Script menu, and press the Load button to load this script into the window. It will move the stage 132 microns in X and Y. Position the specimen in the middle of an area large enough in extent for this movement, and run the script. The output in the log window will show the difference between the measured and requested movement as a percentage; the cumulative sum of these differences in microns, and the total sum of measured shifts in microns. If the error is more than a few percent, the periodicity should be apparent in either the percentage or the cumulative difference. If there is a repeatable pattern, determine the distance between the extreme points in the pattern over one or preferably two cycles, and divide by the number of cycles to get the cycle length. If these differ from the default values of 62 microns for X or 41 microns for Y, add lines for 'StageCycleLengthX' and 'StageCycleLengthY' to the property file. Do not bother if the percent error is only a few percent.

    This step is optional since the values reported by Pulokas et al. and also found on the Boulder Tecnais may be universal constants for the Compustage.  Moreover, the problem appears to be minimal on later Tecnai stages and on stages in newer Thermo/FEI scopes.  The JEOL and Hitachi stages do not have cyclical errors but require much greater backlash correction.

    Low Magnification and Stage Calibrations: These calibrations are needed to do montaging with stage movement and to use the Navigator to acquire low and medium-mag maps. To calibrate stage shift, or image shift in Low Mag mode, you should have a specimen that is moderately rich in detail and that is either on a slot grid or on a grid with a very large mesh.  It is tempting to use the same cross-line grating used for the pixel size calibrations.  It can give reliable results, but only if these conditions are satisfied: 1) you do not have an older compustage with large cyclical errors that require traversing more than 40 microns; 2) the grid has a good supply of latex spheres; 3) the calibrations are not being done on an energy filter with substantial distortions; and 4) you are familiar enough with the procedure so that you can tell when it is giving bad results.  It is particularly challenging and quite likely a waste of time to do the procedure with a calibration grid lacking latex spheres. The option to use Whole-Image Correlations, which is important for finding the correct rotation angle, is also prone to create problems with the cross-line grating.  The recommended procedure for using a grating would be:

    1. Leave this option on for the first stage calibration, making sure that it is giving accurate correlations.
    2. Insert the rotation angle from the procedure as the absolute calibrated rotation in the appropriate 'RotationAndPixel' line in the camera properties.
    3. Save calibrations and restart the program..
    4. Turn off Whole-Image Corr for further stage calibrations.

    Start at the lowest usable magnification in regular mag mode and find an area with good features. Run the Stage Shift command from the Calibration menu (read that entry for details). Drop to the highest mag in Low Mag mode. Repeat the stage calibration here, and also run an image shift calibration. The program will automatically do the latter from scratch if it is the first calibration in LM-mode. The calibrations in LM-mode will be done at the eucentric focus, or at the standard focus setting if it has been calibrated. Continue going down in mag, doing the image shift calibration at each mag. Do 2 more stage calibrations, one at an intermediate mag and one near the lowest mag that might be used for mapping.

    In LM-mode, at least on the Tecnai with slot grids and coarse mesh grids, strange image effects sometimes occur at the higher magnifications. These can be eliminated by inserting the smallest objective aperture that does not occlude the image on the camera.

    Illuminated area limits and aperture sizes on Titan: Before you do any of the following three beam-related calibrations on a Titan, you should run the Illuminated Area Limits command in the Calibration - Beam & Spot submenu to determine the limits of the illuminated area readout at different spot sizes in the two probe modes.  Insert the largest condenser aperture before running the calibration.  Once this calibration is in place, the program can adapt if those limits change because of a scope re-alignment.  Without such a calibration, changes in either the property 'UseIlluminatedAreaForC2' or the scaling of internal lens values that determines the illuminated area readout from the scope will invalidate crossover, beam and spot intensity calibrations and some other intensity-related items.  See Illuminated Area Limits for details.

    The following five calibrations will ask you to enter the C2 aperture size.  You should first add a property 'C2ApertureSizes' with the available sizes in microns (.e.g., 'C2ApertureSizes 50 70 100 150').

    Beam crossover calibration: This calibration should be done before the beam or spot intensity calibrations. Go to a high magnification like 100K, select Beam Crossover in the Calibration menu, and adjust the beam to crossover at each spot size.

    Beam intensity calibration: This calibration is best done with no specimen. It must be done outside Low Dose mode.  The procedure must be done for each spot size that will be used for tilt series; if low dose is going to be used, this might mean spots up to 6 or 8. In the latter case, try to calibrate up to whatever spot size gives 0.3 nanoamp of current. Start the procedure one or two steps above the highest mag that might be used (~200K for low spot size numbers, lower mags for the spots that will only be used for low dose?). An intensity calibration will work on only one side of crossover. You can calibrate one side of crossover based upon the users' most common practice. Alternatively, you can calibrate both sides of crossover provided that you have done the beam crossover calibration. See Beam Intensity for more details.

    Spot intensity calibration: This calibration measures the relative intensity of the spots and is needed to allow an electron dose calibration at one spot to be transferred to other spot sizes. It should be done at an intensity setting that is within the calibrated range for all spots of interest. It is best done with no specimen. As with the beam intensity calibrations, you can do it on one side of crossover, or on both. See Spot Intensity for more details.

    Beam shift calibration (Priority 1 on JEOL): This calibration allows the user to shift the beam by a controlled amount by placing a point on an image. It is essential on the JEOL for getting the beam moved correctly when image shift is used. Separate calibrations can be done in regular and low magnification modes.  On the JEOL, separate calibrations are also stored for GIF mode and for different magnification ranges defined by the 'OtherShiftBoundaries' property. Beam shift calibrations are also alpha-specific for microscopes that have an alpha setting, so you will need a calibration for each alpha value that is used.  (Older calibrations will still work at any alpha.) Follow the procedure in Beam Shift.

    High-defocus magnification calibration: This calibration is fairly essential for making and using Navigator maps (especially montages) with Low Dose View or Search images having a substantial defocus offset.  See High-Defocus Mag for details. 

    High-defocus image shift calibration: This calibration is not as essential as the last one but makes many things work more smoothly and accurately with substantially defocused View or Search images, especially in conjunction with the high-defocus mag calibration. See High-Defocus IS for details. 

    Small screen factor: This is needed to get the same current readout with the small screen in and out. Fill the main screen with a moderately bright, uniform beam (5-10 na). Note the current reported in SerialEM. Insert the small screen. Compute the ratio of the current now to the current on the main screen. Go to the properties file and multiply the existing SmallScreenFactor by this ratio. Restart SerialEM and check that the current corresponds adequately now.

    There is also a ScreenCurrentFactor that requires a Faraday cup measurement to calibrate. The screen current calibrations on Tecnais can be off by over 30%, so this is worth doing. If you determine the ratio between the current measured with a Faraday cup and the current reported by SerialEM, then multiply the existing ScreenCurrentFactor by this ratio.

    C2 factors: This calibration is needed to make the C2 lens percentage for a Thermo/FEI scope reported in SerialEM correspond to the values shown in Microscope User Interface. To do this calibration, first add the C2 lens readout to your MUI workspace. Then select Set C2 Factor in the Calibration menu and enter the C2 value at each spot size.  Skip this for a Titan.

    Tilt axis offset: This calibration is needed to shift the microscope image shifts so that they are centered on the tilt axis of the goniometer. Service engineers should be able to adjust the tilt axis to within about 1 micron of the optic axis, but if this has not been done, this setting will help to minimize movements in Y and Z when tilting. You need a specimen suitable for running the eucentricity routines with. Go to the center of the grid, run Eucentric - Both in the Tasks menu, then run Eucentric - Fine in the Tasks menu 2-4 more times. If the numbers reported for the lateral displacement are consistent, enter their average as the TiltAxisOffset in the properties file. This value has an effect only if individual users turn on 'Center image shift on tilt axis' in the Image Alignment and Focus control panel. If you do calibrate this setting, check it after the stage is worked on, as it can easily change. Note that if you have this option selected and you measure the offset with the eucentricity routine, you need to ADD the measured offset to whatever value is already present.


    Extended Autofocus and Non-reciprocity Calibration for Using Eucentricity by Focus (Priority 2)

    The need for an extended autofocus calibration: If the Eucentricity by Focus routine is going to be used to find eucentricity from a large distance away in Z, or with very large defocus offsets, an autofocus calibration over a wide range will be needed at least for efficient operation of the routine and possibly even for the routine to work at all, because the autofocus calibration becomes quite nonlinear over large focus ranges.  Such a calibration can be prepared with the Extended Autofocus command in the Calibration - Focus & Tuning menu after setting the limits with the Set Extended Range command.  The needed range depends on both the range of Z changes to be handled and the range of defocus offsets when measuring defocus.  Here are some recommendations for the different possibilities:

    Calibrating non-reciprocity for better predictability and convergence:  This calibration may be helpful if the routine does not converge well when using a large defocus offset.  Near the eucentric height and for small defocuses, a change in Z height is equivalent to the same change in defocus; this relationship is called reciprocity.  Reciprocity breaks down badly at high defocus offsets. On a Thermo/FEI Tecnai, the factor relating defocus to Z change was found to be approximately the same as the ratio of the slope of the autofocus curve at a given defocus offset to its slope at zero defocus. The Eucentricity by Focus routine will thus try to determine this slope ratio and use it to scale the Z change that is needed to compensate for a measured defocus.  Doing so requires an extended autofocus calibration.  It is not known whether this approximation holds generally or is specific to this kind of microscope.  If you find that the eucentricity routine requires more than about 4 iterations and does not get within ~10 microns on the first iteration, then you may need to calibrate the non-reciprocity directly.  You can do so with the following script and then insert the final line of output with "ZbyGFocusScalings" into the properties file:

    # Measures non-reciprocity between defocus measurements
    # and Z changes at a series of View offsets
    # Adjust Z offset list to stay within range of the extended focus
    # calibration
    # Make sure the beam and specimen will give good focus
    # measurements at the highest offset
    offsetArr = { 0 -50 -100 -150 -200 -250 -300 }
    zRange = 50
    backlash = 3
    SetLowDoseMode 1
    ReportUserSetting LowDoseViewDefocus offsetOrig
    startZ = -1 * ( $zRange / 2. + $backlash)
    MoveStage 0 0 $startZ
    MoveStage 0 0 $backlash
    loop $#offsetArr ind
       SetUserSetting LowDoseViewDefocus $offsetArr[$ind]
       Autofocus -1 1
       if $ind == 1
          lowerArr = $repVal1
          lowerArr = { $lowerArr $repVal1 }
    MoveStage 0 0 $zRange
    Loop $#offsetArr ind
       SetUserSetting LowDoseViewDefocus $offsetArr[$ind]
       Autofocus -1 1
       factor = ROUND (  $zRange / ( $repVal1 - $lowerArr[$ind] )  3)
       if $ind == 1
          calArr = { $offsetArr[$ind] $factor }
          calArr = { $calArr $offsetArr[$ind] $factor }
    echo Add property:
    echo ZbyGFocusScalings  $calArr
    MoveStage 0 0 -$zRange / 2.

    Setting Up X Ray Removal from Dark References (Priority 2)

    The main task here is to determine the hot pixels and hot columns in the CCD so that these are not erroneously treated as X rays in a dark reference.

    1. If you have a 16-bit camera, turn off division by 2 if it is on, or remember to double the absolute criterion that you determine when you enter it in the properties file.
    2. Set up a parameter set to take full-field unbinned 3 second exposures, and select the option to take a new dark reference every time.
    3. Open column values and spread the beam a lot (or select a high spot size) so that the beam will not saturate the camera.
    4. Take an exposure, then select 'Show Dark Ref' from the Camera menu. Save the dark reference to a file.
    5. Do this 3 times, saving all 3 images to one file.
    6. Remember to turn off the option for a new dark reference every time.

    Transfer this stack and to a machine with IMOD 3.9 or higher. Edit to provide the name of the image stack, the name of a model file to place points in, a threshold for hot pixel strength, and a list of any hot columns that appear in the images, numbered from 0. Number the hot columns from zero. With a Gatan US 4000 camera you will need to exclude a large number of columns near the edges, 20 or more. Enter subm findhotpixels.

    You will get a list of the hot pixels and their mean values in the log file. You can also look at the model on top of the images to verify that the program has found hot pixels. The log file ends with a series of lines of the form:

    HotPixels X Y X Y X Y ...

    Add these lines to your properties file. If you entered any hot columns, you will also see one or more lines listing them as:

    HotColumns Y Y Y ...

    Add these to the property file too. Uncomment all of the lines about DarkXRay... Set the DarkXRayAbsoluteCriterion to the threshold you set for Findhotpixels (but double it if images from a 16-bit camera were divided by 2). The MaximumXRayDiameter can be set to 6 for 15 micron pixels or 4 for 30 micron pixels, unless you want to analyze the situation further.

    You can assess the performance of the X-ray removal with different criteria by reading your dark reference images back into SerialEM. After reading one, copy it to Buffer A, then select 'Fix Dark X Rays' in the Process menu. You can then compare the images in A and B. Turn on Administrator mode and select 'Set Criteria' in the Process menu to change the criteria. Copy the image back to A and run the removal again.


    Measuring Camera Gain (Priority 2)

    A camera property, CountsPerElectron, must be measured in order to calibrate dose to the specimen.  One method of doing this is to add up the counts in an image that includes the whole beam and relate the counts to the screen current.  It is only as accurate as the screen current reading itself, so ideally that should be checked with a Faraday cup.  The following procedure applies to cameras generally; see the sections below for the procedures for a K2 Summit or K3 camera and for a Falcon 3 camera.

    1. Turn off 'Divide by 2' in the Camera menu before starting this procedure.
    2. To do this, you need to have a beam that falls entirely in the camera field of field and that is bright enough so that the screen current measurement is relatively accurate.  Specifically, set the spot size so that the screen current is about 1 na (switch to a smaller condenser aperture if necessary).  
    3. Then center the beam and adjust the beam size so that its diameter is at most 80% of the camera field of view. 
    4. Set the camera parameters for a full-field unbinned image and with an exposure time high enough so that it is accurate (say, at least 0.2 seconds) but not so high that the camera is near saturating.  Once you are able to take an image, you can use Center Beam and Set intensity in the Tasks menu to center the beam and adjust its size by small amounts.
    5.  Lower the screen, record the screen current, take an image, and lower the screen again to check that the current is the same.
    6. Measure the mean counts in the image with Min/Max/Mean in the Process menu (hot key Ctrl I)
    7. Compute countsPerElectron = meanCounts x imageSizeInX x imageSizeInY / (exposureTime * current * 6.242 x 109)
      where exposureTime is in seconds and current is in nanoamps.

    For a K2 Summit camera, the situation is complicated because counting mode gives a nonlinear response, and because counting mode only detects a fraction of the electrons (see Direct Electron Detectors, Especially the Gatan K2 and K3).  In SerialEM, dose rate estimates based on electron counting images are all 'linearized' and should closely match the dose rate outputs in DigitalMicrograph. The program contains tables of image counts versus dose rate output observed in DM, for 200 and 300 KV, and for GMS 3.31 and higher the program will use a dose rate estimate directly from DM. As a result, counting mode images from a wide range of exposure levels give good dose rate estimates at the camera and can be used for calibrating electron dose at the sample, even if the counts per electron is not calibrated.  Neverthless, it is recommended to measure the two gain-related properties as described here:

    1.  The camera property CountsPerElectron is used to determine dose rate from linear mode images and when calibrating dose with a linear mode image.  It does not apply to counting mode counts and should never be set to a value near 1
    2. The general property ScalingForK2Counts sets the scaling of counting mode images to make them comparable to linear mode ones, although the CountsPerElectron value would be used if this scaling is not entered.  Again, it should never be set to a value near 1, or there will be a terrible loss of dynamic range in electron counting images.  A proper setting of this value is important if linear mode images are being used in conjunction with counting images, particularly when doing tilt series where the program monitors the image intensity for sufficient counts.

    Here is a procedure for determining the counts per electron and for setting the ScalingForK2Counts so that linear and counting mode counts match at 7.5 electrons/physical pixel/sec, the middle of the useful range for counting mode.

    1. Add the general property ScalingForK2Counts and temporarily set it to 40.  Restart SerialEM.
    2. Select the K2 and set up for a 1 second counting mode exposure.
    3. Adjust the beam to get a dose rate readout of 7.5 electrons/physical pixel/sec.
    4. Take 3-5 images and measure their means with 'Crtl-I'.
    5. Switch to linear mode, take 3-5 images, and measure their means.
    6. Set ScalingForK2Counts to 40 * (average of linear mode means) / (average of counting mode means).
    7. Set CountsPerElectron in the K2 CameraProperties section to this value times 0.950 for 200 KV or times 0.813 for 300 KV.  These values were obtained by interpolating from the dose rate scaling factors measured in DM and incorporated into the tables in SerialEM; specifically between 0.8264 at 6.388 e/physpix/sec and 0.8104 at 7.699 e/physpix/sec for 300 KV, or between 0.9654 at 6.583 e/physpix/sec and 0.9465 at 7.682 e/physpix/sec for 200 KV.

    This is at least the third version of these instructions.  If you have values obtained with a previous version and you care to correct them, it is best just to redo the procedure.  Again, your dose measurements with counting images will match those in DM even if you leave the values as they are.

    For a K3 camera: Here the situation for counting mode images is simple.  These yield 32 counts per detected electron by design, and recorded counts are linearized with a table, so the CountsPerElectron property is 32 by default and should not need to be changed.  However, it is necessary to determine the scaling factor needed to make linear and counting mode images have the same counts in SerialEM.  The procedure for this is:

    1. Add the property LinearToCountingRatio to the K3 properties section if it is not already there, and temporarily set it to 300.  Restart SerialEM.
    2. Select the K3 and set up for a 1 second counting mode exposure.
    3. Adjust the beam to get a dose rate readout of about 30 electrons/physical pixel/sec.
    4. Take an image and get the statistics and dose rate output with 'Crtl-I'.
    5. Switch to linear mode, take an image, and get the statistics.
    6. Set LinearToCountingRatio to 300 * (linear mode dose rate) / (counting mode dose rate).

    If you have GMS 3.31.2336 or higher, which supports correlated double sampling (CDS), then there is an additional scaling factor needed, the ratio between linear mode counts with CDS on and CDS off.  The default in the program is 1.5.  The procedure is:

    1. Check if the property K3CDSLinearRatio is present in the K3 properties section; if so set it to 1.5 and restart SerialEM.
    2. Adjust the beam to get a dose rate readout of about 30 electrons/physical pixel/sec.
    3. With CDS off, set exposure to 0.04 sec and take an image, then get the image mean with 'Ctrl-I'.
    4. Set exposure to 0.16 sec, take an image, and get the mean.
    5. Turn on CDS mode and get image means at the same two exposure times.
    6. The ratio is 1.5 * (CDSmean.16 - CDSmean.04) / (nonCDSmean.16 - nonCDSmean.04).  If the ratio differs from 1.5 by more than 1-2%, add the property K3CDSLinearRatio or adjust it with the new ratio.

    For a Falcon 3 or 4 camera: The procedure for setting CountsPerElectron is simple.  Take an image in counting mode with frame-saving turned on and open the .xml file.  Take the inverse of the value for CountsToElectrons and use that for the CountsPerElectron (it is typically ~105 for Falcon 3 and ~300 for Falcon 4).  It is not known whether there is loss in detecting electrons even at the lowest - dose rates such as there is - for the K2/K3; if this becomes established or you have measurements indicating that - it occurs, multiply the value by the efficiency factor (1 minus the fraction - lost).  Note that this value for counts received from the Thermo/FEI software is not the same as what applies to the images you see and the value placed in '.mdoc' files, because it is adjusted for the scaling controlled by the property 'Falcon3ScalingPower'.

    For Falcon 4, a different property is needed for scaling raw electron counts when aligning frames being saved as EER, or aligning without permanently saving (in this case frames are saved into an EER file).  This scaling factor is needed to make the counts in aligned images match those in unaligned images (ones scaled by the Thermo/FEI software). To estimate this factor, set Record parameters for unbinned, 2 second exposure, no frame saving, and counting mode.  Take an image without aligning, and an image with aligning in SerialEM.  Use Ctrl-I to get the mean counts of each.  Set the property FalconEventScaling to CountsPerElectron * (mean without aligning) / (mean with aligning).

    It is also important for some purposes to make linear mode and counting mode give the same number of counts; this is achieved with the camera property 'LinearToCountingRatio'.  A procedure for estimating this for is:

    1. Add the property 'LinearToCountingRatio 8' if it is not already present.
    2. For Falcon 3, turn on Divide By 2 in the Camera menu so that linear mode measurements will not be biased by truncation at 0.
    3. Set Record parameters for unbinned, 2 second exposure, no frame saving.
    4. Set the beam intensity to give ~0.5 or ~3.5 electrons/physical pixel/sec for Falcon 3 or 4, respectively.  It is not necessary to set this to a very low value, where loss of counting efficiency is minimal, because the mean counts for counting mode will be linearized to account for this loss by a table built into SerialEM.
    5. Copy and paste this into a script window:
      sumc = 0.
      suml = 0.
      num = 30
      SetK2ReadMode R 1
      loop 3
        ReportMeanCounts A
        sumc = $sumc + $repVal1
      cmean = $sumc / 3
      SetK2ReadMode R 0
      loop $num
        ReportMeanCounts A
        suml = $suml + $repVal1
      lmean = $suml / $num
      adjust = round ( $lmean / $cmean 3 )
      echo linear mean $lmean   counting mean  $cmean
      echo Adjust by $adjust
    6. Multiply the value of LinearToCountingRatio by the adjustment factor.


    Stage and Imaging Stretch (Priority 2)))

    These calibrations are important if the Navigator is going to be used to find marked locations after rotating the grid. Since the two stage axes do not behave identically, a calibration of the stretch in the stage coordinate system is needed to maintain accuracy when rotating the stage coordinates of marked locations. Having this calibration allows positions to be transformed accurately in the Navigator using only 2 or 3 registration points, and allows more accurate transformations when using the Align with Rotation dialog. The procedure for this calibration is described in Stage Stretch.

    When using the Align with Rotation dialog, a stretch in the image projection makes it harder to align images. This stretch can be corrected by entering a property 'RotationStretchXform' for one or more magnifications. The program will use the property for the nearest magnification in the same mode if one is available; thus you would need property entries for one magnification in low-mag and one in regular mag mode if you want to have corrections in both modes. The procedure for obtaining this entry is as follows:

    1. Select a location with recognizable image features over a sufficient area to do alignment correlations with.
    2. Pre-expose this area for a few minutes to stabilize it. Further shrinkage will not affect the calibration as long as it is isotropic.
    3. Take and save an image at one or more magnifications and make each one be a Navigator map (e.g., one near the bottom of regular mag mode, and one in low mag mode).
    4. Rotate the grid by about 90° (rotations between 70 and 110° should be useful).
    5. Center on the same region, take an image at each selected magnification, and save each as a map. You may wish to use the Align with Rotation dialog to center on the position of each previous map.
    6. Note the section numbers (numbered from 0) of each pair of images at the same magnification.
    7. Take the map file to a machine with IMOD. For one magnification, run
         newstack -sec before,after mapfile
      where 'before' and 'after' are the section numbers before and after rotation, and 'mapfile' is the image file
    8. Run
         midas -b 0 temp1.inixf
      Rotate the image with the middle mouse button and shift with the left mouse button until they are approproximately align. Save the transform and exit
    9. Run
         xfalign -bi -ini temp1.inixf temp1.xf
    10. Check the alignment with
         midas -b 0 temp1.xf
    11. Extract the transform with
         tail -n 1 temp1.xf
    12. Add a line to the properties file in the CameraProperties section for the camera used with
         RotationStretchXform   mag_index   # # # #
      Where mag_index is the magnification index (look this up the mag table in the properties file) and '# # # #' are the first four numbers of the transform
    13. Repeat steps 7 to 12 with each other pair of images, changing the numbering of the temp files if you wish to preserve those results.

    Energy Filter Calibrations (Priority 1)

    Before even trying to calibrate mags for your energy filter camera, you may need to improve the EFTEM alignments that were supplied by Thermo/FEI so that the field of view does not shift too much when you change mags. This is a tedious and difficult procedure but is worth figuring out how to do it well.

    Once you have done that, you should do a separate calibration of image shifts and pixel sizes from the calibration on the upper camera (or at least do the image shifts and one pixel size.) SerialEM has some fancy logic for transferring calibrations from one camera to another, but I wouldn't rely on it except for test purposes. Do a calibration of autofocus at one mag first, because then you will be able to use autofocus to focus when you switch between mags. Then follow the procedure above for getting the image shift calibrations and grating pictures.

    In addition, you may need to calibrate the magnification-dependent energy shifts; i.e., this calibration may be needed so that various procedures can switch to lower mag when the slit is in and not lose the zero loss peak. Follow the procedures described in Mag Energy Shifts.


    Energy Filter Properties (For the Sake of Completeness)

    There are several properties for energy filters (see Energy Filter properties.) For a GIF, the most important to check is the BiggestGIFApertureNumber, which is used to make sure that there is no aperture in the way when images are taken. In addition, there are properties to specify delays when inserting or retracting the slit or changing energy offsets. These timings may be OK, but here are some notes on how they were obtained for a GIF. All of the relevant properties can be set with the script command 'SetProperty'.

    For testing the adequacy of the delay on removing the slit:

    1. You need to have a situation where the ZLP is misaligned by at least 10 ev. Perhaps align the ZLP at one mag, then turn off 'Mag-dependent energy shifts' in the Filter Control panel and switch to another mag where the ZLP is shifted by at least 10 ev. (This was easier before SerialEM detected ZLP alignment automatically.) The point is that you want to be able to take a picture at zero loss with a 5 ev slit and get very little beam through.
    2. Enter low dose mode. Set up View and Record/Preview to take pictures at this mag with the same intensity, and set the intensity and exposure time of view and preview to give thousands of counts. Make sure the shuttering being used gives consistent exposures.
    3. Set up Record with 5 ev slit in, 0 loss
    4. Setup up View with slit out
    5. Hit Preview to condition, then View to test, then Ctrl I for image mean.
    6. With the right delay, View will always come out right. If the delay is too short, the image mean will occasionally fall short.

    For testing the delay upon energy shift:

    1. Set up Record/Preview and View in Low dose so that both are at the same mag and have the slit in.
    2. Get the ZLP aligned and set up Record/Preview and View for 10 ev slit, slit in.
    3. Make sure View gives good consistent pictures, and set the loss in Preview to the desired differential.
    4. Hit Preview to condition, then View to test and Ctrl I for image mean.
    5. Test this for energy shifts like 10, 20, 40, 80, 120, 160, 200.
    6. If there are problems, you may need to test more, or just increase the delays. Filter offset delay is specified by two linear equations, each having a base delay and an additional delay per ev of offset. The units for the relevant properties are 60th of a second for a GIF and 1 msec for other filters.


    Setting Up STEM

    All of the property file entries used to configure STEM usage are described in either the STEM Camera Properties section of Properties for one camera or in STEM properties.  See those sections for full details on the properties that are mentioned below.  The exception to this is for JEOL STEM: 'CameraPluginIndex' is described in the Plugin Camera Properties section and must be set to 1 in the camera properties.

    Detector Property Entries. The CameraProperties section for the STEM camera should list all of the detectors whose access can be controlled by the program.  There should be a ChannelName entry for each detector; this is the name that will appear in the Camera Setup dialog.

     For Thermo/FEI STEM, there may also be DetectorName entries with the official names of the detectors, if you do not want those names to appear in the dialogs.  For example, in some cases the official name of the HAADF detector is 'HAADF Detector' and properties 'ChannelName HAADF' and 'DetectorName 0 HAADF Detector' would be used to have the name appear just as 'HAADF'.  In one case, an external switch was used to select between bright and dark field detectors, and whichever one was selected fed into the Thermo/FEI bright field channel.  These detectors were listed together as the second channel with 'ChannelName BF/DF' and the entry 'DetectorName 1 Bright Field' was needed to access the signal correctly.

    For Thermo/FEI STEM, there is no direct control over the insertion of detectors; the only way to get the HAADF detector inserted after coming into STEM mode is to take an image that uses that detector.  The program will take an initial dummy picture to insert the detector if there is a 'NeedShotToInsert' property that lists this detector; 'ShotTimeToInsertDetector' controls the delay between this dummy picture and the real acquisition.

    For DigiScan in JEOL, unless DM itself manages the insertion and selection of detectors, the detectors must be managed through the JEOL interface.  The ChannelName entries for such managed detectors must be placed before the entries for any unmanaged detectors.  Their JEOL IDs must be listed with the ImageDetectorIDs property (in the same order as their ChannelName's appear).  Needed delays are set with InsertJeolDetectorDelay and SelectJeolDetectorDelay.  If one channel in DigiScan receives signals from more than one detector, depending on which one is selected, then this mapping should be described with a MappedToDSchannel property that gives the channel number in DigiScan followed by the detector numbers that feed into that channel. Also, if the detector number (in the ChannelName list) of any remaining detector does not match its channel number in DigiScan, then there needs to be a MappedToDSchannel entry with this detector number and DigiScan channel number.  Even if each detector has its own channel, this could happen if the detectors managed by the JEOL appear after unmanaged ones in DigiScan.

    For either type of STEM, one can also declare that certain detectors cannot be used together by listing their numbers on a MutuallyExcludeDetectors entry.  Detectors already listed in a MappedToChannel entry are automatically considered mutually exclusive so there is no need for another entry about them. Together, these two kinds of entries determine the number of detectors that can be used simultaneously and thus the number of channel combo boxes that appear in the Camera Setup dialog.

    For DigiScan in JEOL, the DetectorBlocks entry should be used if a detector managed by the JEOL physically blocks other detectors; it will cause the blocking detector (listed first) to be retracted when any one of the other detectors is selected.  Retraction is not done automatically just because some detectors are mutually exclusive, because this might not be needed.

    For JEOL STEM, there should be a 'ChannelName' entry for each detector, with whatever name is desired.  If there is a multichannel interface, the entries must be in the same order that they are listed by the plugin or server upon initialization with JEOL camera debugging turned on (have DebugOutput set to 'j').  If there is a single channel interface with multiple detectors, i.e., if only one detector can be recorded at a time (as in JEOL 2100plus), there should be a property 'MappedtoDSChannel 0 0 1' to ensure that the plugin or server is initialized with a single-channel interface (add '2', etc if there are more than two detectors.)  'ImageDetectorID' properties are also required with multiple detectors.

    Screen and Camera Management Properties. Because of the diversity of STEM setups, there are a host of confusing properties to control the behavior of the screen and CCD cameras, which may be selected by preference or by necessity.  These consist of LowerScreenForSTEM (which may be used either to lower or to raise the screen, depending on the sign), MustUnblankWithScreen, RetractCameraOnEnteringSTEM, and the Order settings in the CameraProperties sections.  Here are some examples:

    Magnification Table. You should run List Mags in the Calibration menu even if you are starting with a property file containing a STEM magnification table.  If you are inserting a table into the property file from scratch, precede is with line with 'STEMMagTable' and the number of magnifications listed.  If you are substituting one, be sure to change, be sure to adjust the number on the 'STEMMagTable' line.   For a Thermo/FEI scope, see the advice in List Mags about whether to turn on the 'Enable LMscan' option in the microscope STEM interface and include all of the LMscan magnifications.  If you change your mind about this after doing calibrations and decide to change the magnification table, you would have to edit all of the relevant magnification indexes in the calibration and property files.  On a JEOL, if you do not see a correct magnification readout in SerialEM after ensuring that the magnification table is correct, you may need the JeolSTEMmagUnitsAreX property.

    Binnings for DigiScan. The DigiScan can take square, full-field images with almost any chosen number of pixels up to the maximum (8K by 8K).  SerialEM uses the 'binning' selection to set the number of pixels.  The binnings are obviously constrained to be integers, but otherwise they can be arbitrarily chosen to provide whatever selection of image sizes you find convenient.  For example, if you have no use for 8K images, you could leave out binning 1, or you could set the camera size properties to 4096 instead of 8192.

    Sizes and binnings in multichannel JEOL STEM.  The JEOL multichannel interface (on the F200 at least) can acquire 4096x4096 images from one detector, 3072x3072 from two, and 1024x1024 from 3 or 4 detectors simultaneously.  The 'MinMultiChannelBinning' property informs the program of these restrictions and the camera setup dialog can limit binning selections accordingly.  If you are satisfied with taking no more than 2048x2048 from two detectors, you can make the following entries:

         CameraSizeX 4096
        CameraSizeY 4096
        MinMultiChannelBinning 2 4 4
        Binnings 1 2 4 8 16 32

    However, it is possible to access the full 3072x3072 capability by defining the camera as 3 times larger with a minimum binning of 3:

         CameraSizeX 12288
        CameraSizeY 12288
        MinMultiChannelBinning 4 12 12
        Binnings 3 4 6  8 12 16 24 32 48

    where you might not want all of those binning values.

    Using the Tietz scan generator.  This STEM interface is identified with a 'TietzCameraType' of -1 (the property 'STEMcamera' is set automatically).  The scan generator uses an internal coordinate system with a range of 65535.  SerialEM scales the STEM coordinates that the user sees into a subset of this range, determined by the property 'TietzScanRange'.  The default is a range of 18500, which will produce full-field scans about the same size as those produced by the native scan generators on Thermo/FEI scopes and some JEOL scopes.  General image distortions (i.e., ones other than a distortion at the left size of the scan lines) may be caused by using too large a value.  The best way to assess such distortion is to take two images overlapping by half, align them, and toggle between them.  If this distortion is a concern, assess it for different ranges and settle on a new value before starting any calibrations.

    Because of this coordinate scaling, the number of pixels specified in properties is somewhat arbitrary, although it must be the same in X and Y.  A size of 8192x8192 with binnings up to 32 would provide much flexibility, but you can set it to 4096x4096 to avoid using such high binnings, or you could even set it much higher, like 16384x16384, to have access to fine detail in very small subareas.  This is another item that must be settled before doing any calibrations.

    Finally, take an image with recognizable features and compare it with the image on the flu-cam, screen, or another camera.  If it is flipped relative to these projections (i.e., cannot be brought to the same orientation with rotation alone), add the property 'InvertTietzScan'.

    This is the only STEM interface that provides access to the scan before it is complete and allows it to be aborted.  For frame times longer than 0.5 sec (or whatever minimum the property 'PartialScanThreshold' specifies), SerialEM will display the scan as it becomes available.  If you are acquiring multiple channels, it will let you toggle between them during the scan.  The STOP button will stop the acquisition. 

    Camera Timing. Run the Camera Timing command in the Calibration menu, accepting the default parameters for exposure, binning, and number of test images.  At the end, it will indicate values to be entered for the properties AddedFlybackTime and StartupDelay in the CameraProperties section for the STEM camera.  For Thermo/FEI STEM, the added flyback should be substantial, but applies only to these acquisition conditions.  For Digiscan, the added flyback should be small but is important for keeping DM from crashing.

    For Digiscan, as of SerialEM 3.3.1, it should not be necessary to adjust DigiScanExtraShotDelay to prevent crashes in DM, and it can be left at its default of 100 ms.

    Rotation angle properties for DigiScan and JEOL.  One or two properties should be set to ensure that future sessions are run under the same conditions as when calibrations were done.  With a DigiScan, open the DigiScan Setup Dialog, and press Advanced to open the DigiScan Configuration dialog.  There needs to be a general property entry
       DigiScanFlipAndRotation n d
    where 'n' is 1 or 0 depending on whether 'Flip Horizontal Scan' is checked or not, and 'd' is the value in the 'Rotation Offset' text box.  SerialEM cannot affect these setting in DigiScan but will warn on startup if they do not match the values in this property setting.  On JEOL, there need to be a general property
       JeolSTEMrotation d
    where 'd' is the setting for rotation angle in the JEOL STEM user interface.  SerialEM will restore the rotation angle to this value when it starts.

    Initial Rotation Angle Setup.  SerialEM will assume that all images are taken with the scan parallel to the tilt axis, so that dynamic focus can be used effectively.  One goal of the steps followed here is not just to measure the rotation angle of STEM images, but also to adjust it so that this assumption is satisfied.  The RotationAndPixel and ExtraRotation camera properties are used to determine how to rotate the scan to make it parallel to the tilt axis.

    Rotating to the tilt axis, part 1. If the direction of the scan is not somewhere near parallel to the tilt axis, it should be rotated first so that you can do the following steps correctly. 

    1. Before you start, make sure that the camera properties contain 0 on the ExtraRotation line and on the ImageRotation and RotationAndFlip lines, if any, and do not have RotationAndPixel lines with non-zero rotations (at least at the magnifications you will use). 
    2. Take a STEM image of an area with recognizable features at a low enough magnification so that you can move the stage by a few microns and see how the image moves. 
    3. Move the stage in positive Y (use a script with MoveStage). 
    4. Take another image and note the direction of movement of image features relative to the positive Y axis of the image. 
    5. Place the the angle from the axis of movement to the Y axis (counterclockwise positive) into the 'Added rotation' box of the STEM Control panel. 
    6. Take another image, move the stage again, take another image, and verify that the movement is in the direction of the positive Y axis and along the Y axis within about 10 degrees.  (Using the X axes instead for this measurement will produce the wrong result on a JEOL with omega filter).
    7. Place the negative of the final value of 'Added rotation' into the ExtraRotation line of the STEM camera properties and restart the program.

    Option 1: Refining tilt axis rotation with a stage calibration. To use this method, you need to be at a magnification suitable for doing an accurate stage calibration in a few stage moves, have an image area with enough unique features, and give the program some idea of what the pixel size is.

    1. The easiest way to set the pixel size is to take an image of the cross-line grating and run Find Pixel Size in the Process menu at the chosen magnification. 
    2. Run List Relative Rotations, copy and paste the RotationAndPixel line into the camera properties, replace the second 999 with a 0, and restart the program. 
    3. Then turn off 'Whole image correlations' to minimize correlation problems, run the stage calibration, and make sure it aligns images correctly. The rotation angle that it reports should be within ~10 degrees of 0. 
    4. Place the negative of this angle in the 'Added rotation' box and do another stage calibration to check that it produces an angle of essentially 0.  You can refine the angle in the 'Added rotation' box if necessary by subtracting a new reported angle from calibration. 
    5.  Subtract the final angle in the 'Added rotation' box from the value in the ExtraRotation line and restart the program.

    Option 2: Refining tilt axis rotation by comparison with another camera. To use this method, you need another camera at a magnification where you know the tilt axis angle, either from the angle in a file header or mdoc file, or from the RotationAndPixel relative and absolute angle entries for the camera.  To get the angle from an absolute calibrated angle at a lower mag, add to the absolute angle the relative angles from the mag above the calibrated one through the one at the current mag.  To get the angle from a calibrated one at a higher mag, subtract from the absolute value the relative angles from the calibrated mag down to the mag above the current one. 

    1. Put the tilt axis angle into the 'Added rotation' box. 
    2. Take an image on the other camera and copy it to the Align buffer so that it can be compared easily with images in buffer A. 
    3.  Take a STEM image of the same area at a comparable scale (if you are using a cross-line grating, it is not necessary to find the same area). 
    4. You can find the additional rotation that makes the STEM image match the other camera image in two different ways.  You can estimate the amount that the STEM image needs to be rotated, add that into the 'Added rotation' box, take another image and use it to adjust the estimate, repeating until the images match adequately.  Or, you can find two features to draw a line between in both images and get an angle for each image (press Shift, click and drag with the left mouse button; the angle will be reported in the status bar and in the log window). 
    5. The angle to rotate (add to the 'Added rotation' value) is the angle in the other camera image minus the angle in the STEM image.
    6.  After you find the rotation that makes the images match, subtract the tilt axis angle of the other camera from the 'Added rotation' value.  The value should be within ~10 degrees of 0. 
    7.  Take another image to verify that it brings the tilt axis to horizontal.
    8.  Adjust the ExtraRotation camera property by subtracting this 'Added rotation' angle and restart SerialEM.

    Whichever option you choose, you can test the result by moving the stage a few microns in Y: the move should produce a strict upwards movement in the image.

    Choosing whether to rotate..  You need to make an initial decision about whether to have STEM images rotated in SerialEM so that their orientation is approximately the same as that of images on the viewing screen or CCD camera.  Such a rotation needs to be imposed before calibrations are done, because the calibrations are valid only if images are at the same orientation as when calibrations were done.  If there are multiple users with different preferences in this regard, they would have to access different property and calibration files when running the program.

    If you choose to rotate images, then first take a CCD camera image at a magnification where the rotation is typical for your data acquisition.  Next, take a STEM picture of the same area so that you can determine how much the STEM image needs to be rotated to match the orientation of the CCD image, rounded to the nearest 90 degrees.  Then add a camera property:
       RotationAndFlip n
    where 'n' is 1 for 90 degrees counterclockwise, 2 for 180 degrees, and 3 for 270 degrees (90 degrees clockwise).  Also add the camera property:
       ImageRotation d
    where 'd' is the number of degrees of counterclockwise rotation imposed by this operation.  (You can enter -90 instead of 270.)  This entry is needed to set the tilt axis angle in image file headers correctly.  That header angle is the sum of ImageRotation, the value in the 'Added rotation' box (which should be zero after this initial setup), and +/-180 if the property 'RotateHeaderAxisBy180' is set (which it should be for a JEOL with omega filter requiring 'InvertStageXAxis' to be set).

    Pixel Sizes and Rotations.  Now you are ready to calibrate image shift, pixel size, and rotations for whatever range of magnifications you will need for taking tilt series and running relating tasks.  Because image magnification and angle varies with binning, you should set up the Record parameters for whatever binning is going to be most typical for data acquisition (presumably this will be 1K or 2K images).  Go to a magnification where the field of view is about 9 microns (20 blocks of the grid).  Set the exposure time long enough to avoid significant image stretching due to a scan rate too high.  Do this by taking an image with a long exposure (e.g. 8 seconds), putting it in the Align buffer for easy comparison, and then taking images with shorter exposure times to find the point at which stretching becomes obvious.  On a Thermo/FEI the scan rate may need to be under 0.5 micron/msec; on a JEOL with DigiScan it can be higher.  Then set up the Trial parameters for 512x512 pixel images and set the exposure time to give a similar or lower scan rate.  An alternative to this procedure is to set the property UseTrialBinningSTEMshiftCal to 1 and set up the Trial parameters for a 1Kx1K image, if it seems like a shift calibration from 1K images will be more representative.

    Use the cross-line grating and focus it.  Start at the lowest magnification you want a pixel size for; it can be lower than the one used to set the exposure time. Do these steps at each magnification:

    1. If you are above the magnification where you first set the exposure time, you can reduce the exposure time for both Record and Trial to give a scan rate similar to the one used at that magnification.
    2. Calibrate image shift.  The first time, it should do it 'from scratch'..
    3. Take a Record image.
    4. If you plan to analyze for pixel sizes smaller than can be determined with the Find Pixel Size routine, save the Record image once it gets down to about 3 blocks in the field of view.
    5. Run Find Pixel Size in the Process menu.  Correct the result with Try Again from Marker if necessary.  Above a certain magnification, the peaks may become dim and you may need to use Set Binned Size and set the target size for the pixel size analysis to 512.

    At the end, run List Relative Rotations.  This will put the relative rotation angles and pixel sizes into RotationAndPixel lines that can be inserted into the properties file, just as with a CCD camera.  If you saved images for analyzing higher magnifications, then determine pixel sizes and relative rotations from them and complete the RotationAndPixel entries.

    Set the ExtraRotation to 0 and insert the value that was present there as an absolute calibrated angle on one of the RotationAndPixel lines (preferably the one for the magnification where you first determined that angle).

    In principle, you can refine these rotation angles later by analyzing a tilt series in IMOD.  The rotation angle solved for by Tiltalign indicates the tilt axis angle in the images. (Alternatively, a stage calibration at the right magnification could yield an accurate enough value).  Either insert this angle into the ExtraRotation line or add it to one absolute calibrated angle on a RotationAndPixel line. (On a Thermo/FEI scope, the latter should be done if you intend to calibrate microprobe mode too.)  Run SerialEM in Administrator mode and recalibrate one image shift as carefully as was done above.   Accept the offer to change all other image shift calibrations.

    In practice, this detailed calibration of angles is probably worth doing with Thermo/FEI STEM but is of questionable value on a JEOL with DigiScan.  The problem is that the actual scan rotation changes in discrete steps of 1-2.5 degrees, not continuously.  The calibrations above may correct some of the larger rotations between magnification steps but probably not the small ones.

    Focus-Related Calibrations.  The autofocus routine needs some idea of how fast the beam spreads as focus is changed. The relation between Z height and focus must also be calibrated for various purposes, particularly for dynamic focusing.

    On a JEOL, you must first determine and set the property JeolSTEMdefocusFactor.  In STEM mode, note the focus readout in the JEOL interface and press Reset to reset the defocus in SerialEM.  Change the focus by about 20 microns.  The needed factor is the change in readout in the JEOL interface divided by the focus readout in SerialEM.  Insert this factor into the Properties file and restart SerialEM.

    Make sure the specimen is focused and the Focus parameter set takes good pictures.  Then run the Autofocus command in the Calibration menu. Accept the defaults for the two queries; if the routine reports a problem, check the help for that command.  After this calibration is run, the autofocus routine should work.  Verify this by changing focus by a few microns and autofocusing.

    Next, run the STEM Focus Vs. Z command in the Calibration menu, using default parameters unless some trouble arises.  The program will step through Z and focus at each Z level.  At the end it will indicate the slope of the relationship between Z and defocus over several portions of the range.  Use this slope to set the property STEMdefocusToDeltaZ.  On a JEOL, use either the value from the fit to the middle of the range, or the value over the whole range if the first and second halves give similar values (within a few percent).  On a Thermo/FEI scope, use the value from the fit to the middle of the curve; note that the whole curve is saved as a calibration as well. This curve is specific to the current spot size.  In order to have the correct slope and curve applied when using dynamic focus with Thermo/FEI STEM, you need to run this procedure at every spot size where dynamic focus might be used.

    Flyback Times for Thermo/FEI STEM.  To use dynamic focusing with Thermo/FEI STEM, you will need to calibrate the flyback time a number of times, because it depends on exposure time, binning, subarea size, and magnification.  The flyback time is obtained from the camera timing routine, but it is run in a special mode with the Quick Flyback Time command in the Calibration menu.  In this mode, the number of pictures is kept to a minimum, and resulting flyback time is stored automatically in a file.  See Quick Flyback Time for more information, advice, and instructions on running this command with a script for a series of exposure times.

    Microprobe mode on Thermo/FEI.  The magnifications, pixel sizes, image shift, and focus-related calibrations are all stored separately for microprobe mode and nanoprobe mode.  If you are going to use microprobe mode, you need to repeat steps above starting with Rotating to the tilt axis and continuing with Pixel Sizes and Rotations and Focus-Related Calibrations.  Note that the magnification indexes for microprobe mode are all higher than the ones for nanoprobe mode.  The slope of the relationship between defocus and Z in microprobe mode is entered as a second number on the STEMdefocusToDeltaZ property.  If you refine the rotation angle calibration with an angle from tilt series alignment or an accurate stage calibration, be sure to add the refinement to an absolute calibrated angle on a RotationAndPixel line instead of modifying the ExtraRotation entry.

    MaximumScanRate entries.  If you add a property defining a maximum scan rate (see STEM Camera Properties for details), there are two effects. 1) A button becomes available in the Camera Setup dialog to increase the exposure time to achieve this scan rate and thus obtain images with a predictably limited amount of distortion; 2) Exposure time will be increased if necessary in lower magnification tracking tasks in order to limit the scan rate to this maximum. It is not known whether the latter feature is important for accurate performance of tasks, or whether they will perform adequately with distorted images, so it is difficult to say whether this entry is needed.  However, you should keep this in mind as a possible solution if tracking problems do occur with distorted images.  You can assess the kind of scan rate needed by experimenting with, say, 1Kx1K images of different exposure times to see what scan rates give signification shifts and distortions.  Usually such features begin to appear with rates in the range of 0.5-1 micron/msec.


    Final Tasks (Priority 1)

    When you are finished setting things up, check the settings in the system (default) settings file. Run 'Open' in the Settings menu and load the file SEMsystemSettings.txt from the C:\ProgramData\SerialEM or C:\Program Files\SerialEM folder. Check each of the camera parameter sets. If the capture areas are wrong (too big, too small, not centered), or the binnings are not appropriate for the camera, correct them. You can change any other settings that you think appropriate. Exit SerialEM, or just select Save in the Settings menu.

    If you only want to use one set of SerialEM settings, just use the shortcut provided in C:\ProgramData\SerialEM\ or C:\Program Files\SerialEM and copy it to the Desktop or whatever location works best for you.

    If you prefer to have different settings per user/application loaded automatically at SerialEM startup, create a subfolder for each set of settings (preferrably in C:\ProgramData\SerialEM\UserSettings\ or C:\Program Files\SerialEM\UserSettings\) and create shortcuts on the Desktop using these folders as described in Shortcuts, Command Line Arguments, and Administrator mode.


    Setting Up for a Separate Voltage

    Here is a procedure for setting up the program to be used extensively at a different voltage. It assumes you have a 300 kV scope and want to use it at 200 kV.  Note that this procedure was changed in version 3.3.1 so that multiple settings files are no longer needed.

    1. Make a subdirectory "200KV" in the SerialEM folder and copy SerialEMproperties.txt and SerialEMcalibrations.txt there - they will both need modification but they will provide a starting point.
    2. Make a copy of your shortcut for starting SerialEM, and rename it, e.g., 'SerialEM-200KV'
    3. Right-click on the new shortcut and select 'Properties'.  In the 'Target' box, after the program path in quotes, add a space and '/200KV' without any quotes.  The forward slash is necessary to keep the system from thinking it is a filename and trying to act on it.  
    4. Be sure to have an entry 'SeparateGainReferenceKVs 200' in both the new property file and the standard one.
    5. Also add an entry 'GainReferencePath C:\Program Files\SerialEM' to both property files so that all references will be kept in the upper directory. This will allow users who switch to another voltage temporarily to access the appropriate gain reference and prevent duplicate references from being created in both directories.
    6. You can also place 'WarnIfKVnotAt 300' in the main property file and 'WarnIfKVnotAt 200' in the 200 kV property file, to keep people from running with the wrong properties.

    Now when you click on the new shortcut, the program will add the argument on the 'Target' line to the system path entry in the settings file and access the properties and calibrations in the 200KV folder. Be sure to make an unbinned gain reference at the lower voltage before trying any calibrations. Then, you can calibrate image shift, stage shift, autofocus, etc. You will also need to adjust the pixel sizes and rotations in the property file.

    Each user who wants to use the program at that voltage will need to have the same separate shortcut, with '/200KV' added to the 'Target' line.

    Be aware that the 'SeparateGainReferenceKVs' entry causes the kV to be added to the gain reference filename, so when you first add this entry any previous references will be unavailable (unless you rename them), and if you ever comment out the entry the kV-specific references will be unavailable (unless you rename them).


    Setting Up to Use Nanoprobe TEM on a Thermo/FEI Scope

    The program can be used in nanoprobe as well as microprobe mode on a Thermo/FEI scope.  The probe mode is recorded along with other illumination settings as part of the Low Dose parameters, in states saved in the Imaging State dialog, and as part of the acquisition state for Navigator maps.  There are also script commands to set and report the probe mode. However, because illumination conditions are so different between the two modes, numerous SerialEM calibrations are kept track of separately for nanoprobe and microprobe mode.  Some or all of these calibrations will need to be done in nanoprobe mode to use it effectively, depending on the application.  The calibrations include:

    When the microscope returns to one of the probe modes, it reimposes a number of settings that were present when it was last in that mode.  This includes not just the illumination conditions (spot size and intensity) but also image shift, defocus and beam shift.  Each of these is handled differently.

    Additional beam shifts can be set for low dose areas.  These are handled by removing the beam shift for the current area before a probe mode change, then applying the shift for the new area after the change.  (When there is no probe mode change, the change in additional shifts between the two areas is applied after all other changes, as usual.)

    To center the beam independently in the two modes, set up Trial parameters for a condensed beam that can be centered, turn on 'Continuous update of Mag and Beam', and change between the modes with a script or in the microscope interface. 

    If you already have different Low Dose modes set up to use different probe modes, you can also adjust beam position in each probe mode by the following procedure: 1) Zero out the addition beam shift in each Low Dose mode.  2) Center the beam on one Low Dose mode.  3) Change to the other probe mode with a script or in the microscope interface.  4) Go to the other Low Dose mode (by taking an image or by dropping the screen) and center the beam there.  5) Switch back to the other probe mode.  6) Go back to the other Low Dose mode.  After establishing the basic beam position in each mode with this procedure, you can then apply additional beam shifts as necessary.


    Controlling Apertures on Thermo/FEI Scopes  

    SerialEM can control apertures on Thermo/FEI scopes using Microsoft 'UI Automation' instead of with Thermo/FEI scripting commands. For this to work, the microscope software must be running on Windows 7 or above, the TEM user interface must not be minimized, and the Apertures panel must be included on some tab in the Workset area of the TEM user interface.  The tab will be switched to if that panel is not currently visible.  The UI Automation alone cannot change an aperture size in Windows 7, and in some Windows 10 systems.  In these cases, cppy the compiled AutoIT program SEM-AutoIT.exe from the SerialEM program package to either the directory with the SerialEM executable (when running directly on the scope) or to the same location as FEI-SEMserver.exe, when running through that.  If desired, you can place this file elsewhere and define the environment variable SEM_AUTOIT_DIR with the full path to that location.

    When changing size fails on these systems, the TEM interface will show the desired change.  To assess whether this is happening on a Windows 10 system, go to a lower magnification where you can see the objective aperture in an image, and use a script command 'SetApertureSize 2 X' to change the size to 'X'.  Aperture control has been found not to work on more than one Glacios and at least one Krios running WIndows 10.

    The aperture operations, and 'ReportSlotStatus', will hang FEI-SEMserver.exe on some Windows 7 systems, even though they work when SerialEM is running directly on the scope computer.   If this occurs, set the environment variable FEISEMSERVER_AUTOMATION to 0 to prevent any automation-based operations from being attempted. 

    For some Thermo/FEI server version, possibly available in April 2024, the new UTAPI scripting can be used to control the apertures.  Access to this scripting is activated with a property 'UseUtapiScripting 1'.


    Alpha and Beam Shift Calibration Issues on JEOL scopes  

    Beam shift calibration is problematic on higher-end JEOL scopes because of two factors: the effectiveness of beam shift can be very different at different alpha values; and the effectiveness of beam shift can change abruptly between two magnifications, as well as change gradually within a magnification range.

    The initial movement of the beam in the beam shift calibration should be at least 10 pixels to get an accurate enough estimate of the scaling for the second round of movements.  Overall this movement is controlled by the property JEOLBeamShiftToMicrons, but this property actually sets the universal scaling of beam shift deflector values to the units used in the program, so it must not be changed after doing a successful calibration.  Instead, the property BeamShiftCalAlphaFactors can be used to adjust the scaling for the initial movement independently for each alpha.  (See the section on JEOL beam shift properties for more details). 

    The problem of the beam shift calibration changing can be handled by defining one or more beam shift boundaries and calibrating beam shift separately in the magnification ranges defined by the boundaries.  Ideally, you should calibrate beam shift in the middle of the magnification range where such a calibration applies and is to be used.  Once you have a calibration, you can check how well it applies at other (typically lower) magnifications by the following procedure:

    1. Adjust beam size and position so that an edge of the beam is in the periphery of a camera image.
    2. Click with the left mouse button to set the marker on the edge of the beam
    3. Run Move Beam in the Tasks menu (hot key Shift-M).
    4. Take an image.  The beam edge should be near the center of the image.  Its distance from the center indicates the degree of inaccuracy in the calibration when used at that magnification.

    Errors up to about 10% are to be expected; at a beam shift boundary the error will typically be 20% or more.  When you find a boundary, add a general property 'BeamShiftBoundaries' with the index of the magnification above the boundary and restart the program.  You will now be able to calibrate beam shift around the middle of the magnification range where it applies (to minimize the inaccuracy at the ends of that range), and the appropriate magnification will be used for all magnifications in each range.

    When using image shift deflectors for image shift, you might be able to accomplish the same thing with an image shift boundary (defined with OtherShiftBoundaries), but these boundaries are not the same in general and are not treated as beam shift boundaries in the program.  Using a beam shift boundary guarantees that the right beam shift calibration is used regardless of where the image shift boundaries are.  When using PLA for image shift, you can actually store a calibration at each magnification, but defining a beam shift boundary is the only way to make sure the program uses the calibration appropriate for a given magnification.

    If you refine the beam shift calibration, the calibration will be stored without removing another calibration in the same magnification range, and will not be replaced when the either the initial or refining calibration is done for a different magnification in that range.  Thus, there can be refined calibrations for multiple magnifications in a range.


    Setting Up to Use a GPU for Frame Alignment

    Frame alignment can happen in two places: in the SerialEMCCD plugin to DigitalMicrograph for K2/K3 and OneView/Rio cameras, and in SerialEM itself for Falcon, DE, and Tietz cameras.  The GPU of an NVIDIA card can be used if the module FrameGPU.dll and the matching CUDA libraries are found in the right place: in the same folder as the SerialEMCCD plugin or the SerialEM executable, respectively.  To enable GPU use:

    1. Get FrameGPU-CUDA8.exe from the SerialEM download site.  If this does not work, next try the CUDA 6 version.  The CUDA 4 version is still available in FrameGPU-CUDA4.exe, but can no longer be built after changes to make the framealign code compatible with CUDA 12, so this package will become either out-of-date or unusable when there is a substantive change in the module.  Use it only if the CUDA 6 and CUDA 8 packages do not work, and let us know if that is the case.
    2. Run the package.  Extract the files to C:\ProgramData\Gatan\Plugins\Shrmemframe for use with a Gatan camera, or to C:\Program Files\SerialEM or other SerialEM install location for DE, Falcon, and Tietz.
    3. Restart DigitalMicrograph for a Gatan camera.
    4. Restart SerialEM.  There should be a message in the log that the GPU IS available for frame alignment for the relevant camera.  For GMS 3.42 and above, there may be a message in the DM Output window about failure to access the GPU directly; if so, this should be followed by a message that the GPU is accessible through the Shrmemframe program.  This is slightly suboptimal because frames have to be passed through shared memory, but at least the GPU is then working.  The GPU files are now placed in the Shrmemframe folder instead of the Plugins folder; that arrangement also allows direct GPU access by the plugin if that still works.  In one site with GMS 3.53, the CUDA 8 version was directly accessible while the CUDA 6 version was not, hence the advice to try CUDA 8 first.
    5. To see debug output from frame alignment, get diagnostic information about a failure to connect to the GPU, or just to determine what CUDA version the Nvidia driver supports:

    The SerialEM install package comes with files named FrameGPU4.dll and FramGPU8.dll for the two CUDA versions.  When you update SerialEM, the installer will update FrameGPU.dll as long as it can tell which CUDA version you have libraries for.  This module MUST be named FrameGPU.dll to be loaded by the framealign module.


    Adding an NVIDIA card to a K2/K3 Computer

    If you are using the frame alignment module in the SerialEMCCD plugin to DigitalMicrograph for aligning K2 frames, you can speed up this processing by using the GPU of an NVIDIA card added to the computer.  The K3 computer by default comes with a low-end K2200 card, but much better performance will be obtained with a more powerful card. Alignment with the GPU was considerably improved in SerialEM 3.7 by moving the initial processing from CPU to GPU, so the speedup from more powerful cards is more apparent. Because most of the processing is done as frames become available from DM, the speed gains from the GPU are somewhat limited with a K2 (where frames become available slowly). 

    For example, with a  Quadro P2000 in GMS 3.2, acquiring and aligning 14 super-resolution 0.1 sec frames takes 10.0 sec with CPU and 6.8 sec with GPU; 14 counting mode frames take 5.5 sec with CPU and 5.0 sec with GPU.  The optimized design of the K3 makes the gains from having a GPU be a larger fraction of the overall acquire time.  With the GP100 included when the K3 comes with the MotionCor2 option, acquiring and aligning 14 frames of 0.05 sec takes 10 sec on CPU and only 2.9 sec on GPU. Most of these gains can be achieved by mid-high range cards and it is not necessary to have one of the most powerful cards.  Specifically, there is no need to have a dedicated GPU card, so in the K2 the NVIDIA card can serve as the graphics card and substitute for the ATI card that comes with the computer.

    With a K3, the situation is easy. There should be two open spots for a double-height graphics card, plus space for a double-height card where the K2200 is. It is probably better to add a card and leave the K2200 to run the display. The frame alignment module will automatically pick the more powerful card. A GTX 1080 Ti would be a good choice, or a mid-range GeForce card down to a 1060 if cost is an issue.

    With a K2, you have to choose between substituting a single-height card for the existing graphics card, and moving cards around to create space for a more powerful double-height card. A typical arrangement of cards in the K2 computer is:


    Slot 7: PCI-E 3.0 x8

    Processor 2

    SATA to eSATA Bracket

    Slot 6: PCI-E 3.0 x8

    Processor 2


    Slot 5: PCI-E 3.0 x8

    Processor 2


    Slot 4: PCI-E 3.0 x16

    Processor 2

    Graphics card

    Slot 3: PCI-E 3.0 x8

    Processor 1


    Slot 2: PCI-E 3.0 x8

    Processor 1


    Slot 1: PCI-E 3.0 x8

    Processor 1


    Slots are numbered from the bottom as in this table. There are two basic options: 1) get a single-height card, which can be substituted in slot 4 without any other rearrangements; 2) get a more powerful or cost-effective double-height card, which must occupy slots 3 and 4 and requires having one free slot and rearranging other cards.  If you have no free slots, you may find that one of the cards is a Firewire card with nothing connected, which you can remove to free up a slot.  Slot 7 is too short to fit anything else useful.

    The constraints when installing an NVIDIA card are these:

    1) If you get a single-height card and your graphics card is already in slot 4, the process is simple; just substitute the card.  Unfortunately single-height cards have limited capability.  The best ones available as of Jan. 2019 are all Quadro cards, which all have worse price/performance ratios than GeForce cards (typically around a factor of two worse). The choices are:

    Card Price Cores Memory Mem. bandwidth Power
    P1000 $300 640 4 GB 82 GB/s 47 w
    P2000 $450 1024 5 GB 140 GB/s 75 w
    P4000 $750 1792 8 GB 243 GB/s 105 w
    RTX4000 $950 2304 8 GB ? 160 w

    Most likely these choices will evolve into a set of RTX cards.

    2) If you want to get more performance for the money with a double-height GeForce card, you must move a card out of slot 3, which will typically be a NIC.  This NIC must stay on processor 1, not be moved to slot 6 if it is empty.  Some possibilities are

    In any case, you must reconfigure the NIC after moving it.  Access the configuration with Control Panel - Device Manager - Network adapters, click on Myricom Myri-10G Ethernet Adapter and switch to the Advanced tab.  Check the settings for each of the 4 adapters against this reference before moving the card.  Afterwards, you will need to restore two of them:

    IP Addresses:
    - LOWER NIC: (set name to 'K2 Base') (set name to 'K2 Lower')
    - UPPER NIC: (set name to 'K2 Upper')
    Device Settings:
       Adaptive Interrupt Moderation (AIM):		Disabled
       AIM Max Idle Time:				10
       AIM Max Period:				0
    * Custom RSS Hash:				IPv4
       Degraded PCI-E Link:				Denied
       Flow Control:					Off
    * Interrupt Coalescing Delay:			500
       IPv4 Checksum Offload:			Rx Enabled
       Large Send Offload v2 (IPv4):			Enabled
       Large Send Offload v2 (IPv6):			Enabled
       Locally Administered Address:		Not Present
       Log Link State Event:				Enabled
    * MTU:						9000
    * Receive Buffers:				16384
       RSS:						Enabled
    * RSS Queues:				      8
       Strip VLAN Tags:				On
       TCP Checksum Offload (IPv4):		Rx & Tx Enabled
       TCP Checksum Offload (IPv6):		Rx & Tx Enabled
       UDP Checksum Offload (IPv4):		Rx & Tx Enabled
       UDP Checksum Offload (IPv6):		Rx & Tx Enabled
       VLAN ID:					0
    * Denotes a parameter modified from default value.

    You also need to install NVIDIA drivers downloaded from the NVIDIA web site.  You can do this either just before or just after the card swap.

    Unplug the computer after turning it off.  You should use a grounding strap or other anti-static precautions while transferring the video card from its protective packaging to the computer.

    Follow the instructions in Setting Up to Use a GPU for Frame Alignment to install the FrameGPU.dll module and CUDA runtime libraries.


    Using Film

    There are several script commands that allow taking pictures on film. One problem encountered on Tecnais is that the display may not recover from the automatic screen dimming unless you move the mouse. You can solve this by editing the registry. From the Start menu, select Run and enter 'regedit'. You want to find the key 'HKEY_LOCAL_MACHINE\SOFTWARE\Thermo/FEI\BrickBox\Configurations\tem\default\MdlScreenDim\MdlScreenDimMgr\ScreenDim' You can use 'Ctrl-F' and F3 to search for the text 'ScreenDim' until you find an entry under 'MdlScreenDimMgr, although this is tedious. In Tecnai version 2 (Windows 2000), the key 'PowerSaveSupported' already exists under 'ScreenDim': double click on it, or right click and select 'Modify', then change its value from 1 to 0. In Tecnai version 3 (Windows XP), you need to add the key. To do this, right click on 'ScreenDim' in the left panel (the tree display) and select 'New - DWORD value' Then change the name of 'New Value #1' to 'PowerSaveSupported' and leave the value as 0.

    On the Tecnai, it is also possible to set a delay between the loading of the plate and the exposure, and to have a pre-exposure of the specimen before the film is exposed. To access these features, the server module 'adaexp.exe' must be installed. This module is used by Leginon, so if you have Leginon, you are all set. Otherwise, the right version of the module for your microscope needs to be obtained from Max Otten at Thermo/FEI. (The wrong version will do bad things like disable the HT until the computer is rebooted.)


    Files in the SerialEM Install Package

    The SerialEM_4-1-x.exe package will create a subfolder SerialEM_4-1-x under C:\Program Files\SerialEM with the following files (not all included in a 64-bit SerialEM package).  The 'Microsoft.VC140' folder and all of the DLL's above that line below are required for SerialEM to run.

    SerialEM.DontRunHere.bin The SerialEM executable, which is renamed to SerialEM.exe for use.  It will not run in this folder unless multiple scope plugins are removed.
    libifft-MKL.dll FFT library incorporating Intel Math Kernel Library FFT routines
    libctffind.dll Library based on Ctffind4, compiled in IMOD for better performance
    libmmd.dll Intel math libary
    libiomp5md.dll Intel OpenMP library
    hdf5.dll Library for HD5 files
    imodzlib1.dll Library needed by hdf5.dll
    msvcp120.dll Library needed by libctffind.dll and ctfplotter.exe, compiled with Visual Studio 2013
    msvcr120.dll Library needed by libctffind.dll and ctfplotter.exe
    Microsoft.VC140 Folder with DLL's for running the program compiled with Visual Studio 2015
    SerialEM.chm The help file
    ctfplotter.exe Ctf fitting program from IMOD
    ctfplotter.adoc Options file for this version of Ctfplotter
    svml_dispmd.dll Intel library needed by Ctfplotter
    FEIScopePlugin.dll A plugin for communicating with a Thermo/FEI microscope locally or remotely
    FEI-SEMserver.exe A server that is copied to a remote Thermo/FEI microscope computer and run there
    FEI-SEMserver-Win2K.exe A server version that will run on Windows 2000 and may be needed for some scopes on Windows XP before SP3.
    SEM-AutoIT.exe A compiled AutoIT script for controlling apertures on Thermo/FEI scopes running Windows 7 or 10 where built UI automation does not work
    JeolScopePlugin.dll A plugin for communicating with a JEOL microscope
    HitachiPlugin.dll A plugin for communicating with a Hitachi HT7700/HT7800 microscope
    ShMemSEMserver.exe A server for shared memory values that is copied to the HT7700 /HT7800 computer when running on another computer
    SerialEMCCD.dll The plugin to DigitalMicrograph for GMS 1.x
    SEMCCD-GMS2.0-32.dll The plugin to DigitalMicrograph for 32-bit GMS 2.0 - 2.2
    SEMCCD-GMS2.3-32.dll The plugin to DigitalMicrograph for 32-bit GMS 2.3 and above
    SEMCCD-GMS2.31-64.dll The plugin to DigitalMicrograph for 64-bit GMS 2.31 - 3.2
    SEMCCD-GMS3.01-64.dll The plugin to DigitalMicrograph for GMS 3.01 - 3.30
    SEMCCD-GMS3.31-64.dll The plugin to DigitalMicrograph for GMS 3.31 - 3.3x
    SEMCCD-GMS3.42-64.dll The plugin to DigitalMicrograph for GMS 3.4
    SEMCCD-GMS3.50-64.dll The plugin to DigitalMicrograph for GMS 3.5
    SEMCCD-GMS3.60-64.dll The plugin to DigitalMicrograph for GMS 3.6
    SerialEMCCDps.dll A DLL for communicating with the plugin for GMS 1.x
    SEMCCDps-GMS2-32.dll A DLL for communicating with the plugin for both 32-bit and 64-bit GMS 2-3
    SEMCCDps-GMS2-64.dll A DLL for communicating with the plugin for 64-bit GMS 2-3
    Shrmemframe A folder with shrmemframe.exe and its needed libraries from older Microsotf and Intel compilers.  This is a program that the plugin to 64-bit DM uses for frame alignment with the CPU or GPU, with data passed through shared memory.
    FrameGPU4.dll A DLL for using the GPU of an NVIDIA card for doing frame alignment in the plugin to DM or in SerialEM itself, built with CUDA 4
    FrameGPU6.dll A DLL for using  the GPU of an NVIDIA card for doing frame alignment in the plugin to DM or in SerialEM itself, built with CUDA 6
    FrameGPU8.dll A DLL for using  the GPU of an NVIDIA card for doing frame alignment in the plugin to DM or in SerialEM itself, built with CUDA 8
    register-GMS1.bat A batch file for copying the plugin and registering both DLL's for GMS 1.x
    register-GMS2-32.bat A batch file for copying the plugin and registering both DLL's for 32-bit GMS 2-3
    register-GMS2-64.bat A batch file for copying the plugin and registering two or three DLL's for 64-bit GMS 2-3
    b3dregsvr32.exe Program run by the batch file for registering the plugin for 32-bit and 64-bit GMS 2-3
    b3dregsvr64.exe Program run by the batch file for registering the plugin for 64-bit GMS 2-3
    FocusRamper.exe A COM executable for doing dynamic focus on a Thermo/FEI scope
    register-Ramper.bat A batch file for registering the FocusRamper on a remote microscope
    JeolCamPlugin.dll A plugin for accessing a JEOL camera or JEOL STEM signals on some scopes
    JEOL-SEMCamServer32.exe A server that is copied to a remote JEOL PC for accessing JEOL camera or STEM signals
    JEOL-SEMCamServer64.exe A camera server that is copied to a remote JEOL PC running 64-bit JEOL software
    TietzPlugin.dll A plugin for accessing Tietz (TVIPS) cameras
    Tietz-SEMServer.exe A camera server that is copied to a remote PC running a Tietz camera
    DEcamPlugin.dll A simple wrapper plugin for accessing Direct Electron cameras without linking the DE DLL into SerialEM
    DE.Win32.dll or DE.Win64.dll A DLL from Direct Electron for connecting with the DE server
    INSTALL.bat A batch file for copying appropriate files to the folder above and registering needed items
    SerialEM_Snapshot.txt Guenter Resch's script for collecting a snapshot of the SerialEM installation and configuration
    Copyright.txt Describes the MIT-style license covering SerialEM and the copyright and license terms for associated components
    GPL.txt GPL license covering the SerialEMCCD plugin to DM and Ctfplotter
    LGPL.txt LGPL licence covering libcfshr, libiimod, libimod, and libifft libraries from IMOD
    Mini-XML.txt License covering the libimxml library from IMOD
    Janelia.txt License covering the libctffind library from IMOD
    HDF5.txt License covering the HDF5 library