ctfphaseflip(1)             General Commands Manual            ctfphaseflip(1)



NAME
       ctfphaseflip - correct tilt series for microscope CTF by phase flipping

SYNOPSIS
       ctfphaseflip  options

DESCRIPTION
       This program will correct the CTF of an input tilt series by simple
       phase flipping.  The user can select a subset of projection views of
       the input tilt series to correct and can specify a defocus value for
       each selected view through a text defocus file.  The output file of
       ctfplotter is usually used as the defocus file.

       Ctfphaseflip corrects each view strip by strip.  A strip is defined as
       an image region whose defocus difference is less than a user specified
       value, but the width is usually limited further to reduce computation
       time.  The strips are vertically oriented and defocus is assumed to be
       the same along a vertical line.  Thus, the tilt series must be aligned
       so that the tilt axis is vertical before applying this correction.

       It can be run in a parallel mode similiar to the Tilt program by
       setting the TotalViews option.  The script Splitcorrection can be
       used to prepare command files for running the program in parallel.

       A sample command file for running the program with "subm" can be found
       in the IMOD/com directory (ctfcorrection.com).

       Originally, the program limited strip widths to 256, but the power
       spectra of low tilt images often showed rings of very low values right
       around the zeros of the CTF.  As of IMOD 4.8.17, the strip width is
       limited dynamically in a way that should minimize this effect.  Making
       the strips wider eliminates or reduces this effect, provided that the
       shift in the position of the first zero across the width of the strip
       is big enough.  At very low tilt, the maximum allowed width is
       increased to a value that would make the first zero shift by 0.6 pixel
       in the Fourier transform.  At higher tilts, the criterion shift is
       reduced by (1 - tan(tiltAngle)).  At zero tilt, the strip width is sim-
       ply half of the image size in X.  The spacing between adjacent strips
       is also adjusted to be larger for wider strips, to keep the computa-
       tional time down (see the -iWidth option below).


OPTIONS
       Ctfphaseflip uses the PIP package for input (see the manual page for
       pip).  Options can be specified either as command line arguments
       (with the -) or one per line in a command file (without the -).
       Options can be abbreviated to unique letters; the currently valid
       abbreviations for short names are shown in parentheses.

       -input (-inp) OR -InputStack   File name
              Input stack that will be corrected.  It must be aligned so that
              the tilt axis is vertical.

       -output (-o) OR -OutputFileName     File name
              Name of output file for the corrected views

       -angleFn (-an) OR -AngleFile   File name
              File containing tilt angles for the input stack.  Each line of
              this file is the tilt angle for a view of the input stack.  The
              angles are listed in order starting from view 1.

       -invert (-inv) OR -InvertTiltAngles
              Invert the sign of the tilt angles to compensate for a left-
              handed coordinate system in the microscope.  When the sign of
              the tilt angles and the value of the tilt axis rotation angle
              are such that reconstructions are generated with inverted hand-
              edness, then this option is needed for a proper correction.
              One way to assess this need is to examine the aligned stack
              being corrected, which has its tilt axis vertical.  At positive
              tilt angles, the right side of the images should be more under-
              focused than the left side; if not, then this option is needed.

       -defFn (-defF) OR -DefocusFile      File name
              File with list of tilt angle ranges and defocus values in
              nanometers, such as was output by Ctfplotter.  The full spec-
              ification of the defocus file is given below.  Each line should
              have a starting and ending view number (numbered from 1), a
              starting and ending tilt angle, and a defocus value.  Defocus is
              in nanometers, with positive values for underfocus.  The program
              will assign that defocus value to the midpoint of the range of
              views.  For a view at a given tilt angle, it will find the defo-
              cus either by interpolating between two surrounding midpoint
              angles, if there are such angles, or by taking the nearest defo-
              cus value, if the angle is beyond the range of the available
              midpoint angles.  To correct a tilt series with a single value
              of defocus, supply a file with a single line containing "20 20
              0. 0. defocus_value".  If you prepare a defocus file with more
              than one line, be sure to use the exact angles from the tilt
              angle file specified with the -angleFn option; do not round to
              one decimal place.  Alternatively, add the number "2" as an
              extra value at the end of the first line of the file; this will
              prevent the program from thinking that the view numbers might be
              off by one.  If you use the -invert option, you must do one of
              two things: 1) either invert all the tilt angles in this file,
              2) or start the file with the line "16 0 0.  0. 0 3" to indicate
              that it is a version 3 file in which the angles need to be
              inverted.

       -xform (-x) OR -TransformFile       File name
              File with the linear transformations that were used to align the
              images.  With this option, the program will use the shifts in X
              to adjust the middle position that is considered to be at the
              nominal defocus value for each image.  Whether this is appropri-
              ate or not needs to be determined by experimentation.

       -defTol (-defT) OR -DefocusTol      Integer
              Defocus tolerance in nanometers that limits the width of the
              strips.  An image region with defocus difference less than this
              tolerance is considered to have constant defocus and can be cor-
              rected as one strip. The strip width is either the width of this
              region or the maximum strip width, whichever is smaller; but
              strips will also be constrained to be at least 128 pixels wide.
              Each strip is corrected based on the defocus at the center of
              the strip.

       -maxWidth (-m) OR -MaximumStripWidth     Integer
              Maximum width of strips in pixels.  This entry disables the
              dynamic adjustment of maximum width described above and applies
              a fixed maximum at all tilt angles.

       -iWidth (-iW) OR -InterpolationWidth     Integer
              The distance in pixels between the center lines of two consecu-
              tive strips.  A pixel inside the region between those two center
              lines resides in both strips. As the two strips are corrected
              separately, that pixel will have 2 corrected values. The final
              value for that pixel is a linear interpolation of the 2 cor-
              rected values.  If a value of 1 is entered, there is no such
              interpolation.  For a value greater than one, the entered value
              will be used whenever the strip width is less than 256 (i.e., at
              high tilt), and the value will be scaled proportional to the
              strip width for widths above 256.  This scaling keeps the compu-
              tational time down and is reasonable because the defocus differ-
              ence between adjacent wide strips at wider intervals is still
              less than that between the narrower strips at high tilt.  How-
              ever, strips at constant spacing can still be obtained by enter-
              ing the negative of the desired spacing, which disables the
              scaling of the spacing.

       -pixelSize (-pi) OR -PixelSize      Floating point
              Image pixel size in nanometers

       -volt (-vo) OR -Voltage   Integer
              Microscope voltage in kV

       -cs (-c) OR -SphericalAberration    Floating point
              Microscope spherical aberration in millimeters.  A value of 0
              can be entered; it will be made slightly larger to prevent divi-
              sion by 0 in the CTF equations.

       -ampContrast (-am) OR -AmplitudeContrast      Floating point
              The fraction of amplitude contrast. For Cryo-EM, it should be
              between 0.07 and 0.14.  The value should be the same as was used
              when detecting the defocus.

       -phase (-ph) OR -PhasePlateShift    Floating point
              A fixed value for the phase shift imposed by a phase plate, in
              radians.  It can be entered with either positive or negative
              sign; the absolute value of the entered value will be subtracted
              when computing phase within the program.  This entered value
              will be overridden by the presence of any view-specific phase
              shift values in the defocus file.

       -scale (-s) OR -ScaleByCtfPower     Floating point
              Scale frequency components by calculated CTF to the given power,
              in order to attenuate frequencies near the zeros of the CTF.
              The scaling does not occur below 0.9 times the frequency of the
              first zero, and it is introduced gradually between that point
              and the first zero to avoid a sharp transition in scaling.
              Lower powers give a narrower range of frequencies over which the
              strongest attenuation occurs around each zero.  This is not a
              Wiener filter; it will only attenuate signals and not boost any.

       -views (-vi) OR -StartingEndingViews     Two integers
              The starting view and the ending view to correct in this run of
              the program, numbered from 1.  This is an optional field.  The
              default is to correct all views in the input stack.

       -totalViews (-t) OR -TotalViews     Two integers
              The starting view and the ending view that need to be corrected
              in all parallel runs of the program.  This field is only needed
              when doing parallel runs with direct writing to a single output
              file.  The program is run initially with a StartingEndingViews
              entry of -1,-1 to set up the output file.  Then it is run with
              actual starting and ending views for each parallel run, and each
              run writes to the existing output file.

       -boundary (-b) OR -BoundaryInfoFile      File name
              Name of file with information about boundaries between chunks
              and files in which to write lines at the boundaries, when multi-
              ple runs are writing in parallel to an output file.

       -aAngle (-aA) OR -AxisAngle    Floating point
              This option is not supported.  The tilt axis has to be vertical,
              i.e., to be coincident with the Y axis.  Usually this means the
              input stack has to be the aligned stack.

       -param (-pa) OR -Parameter     Parameter file
              Read parameter entries from this file.

       -help (-h) OR -usage
              Print help output

       -StandardInput
              Read parameter entries from standard input

   Defocus File Format
       The defocus file consists of a series of lines, each containing at
       least 5 numbers: starting and ending view numbers for the range of
       views fit to (numbered from 1), starting and ending tilt angles for the
       range of angles fit to, and the defocus value in nanometers (underfocus
       positive). The first line of the file can have a version number at the
       end.  For versions 1 and 2, the first line must have fitting data as
       well.  The typical file currently written by Ctfplotter thus starts
       with lines like
       61      61      -58.94  -58.94    4376  2
       60      60      -56.94  -56.94    4599
       A version 3 file can have columns for astigmatism values, or the phase
       shift from a phase plate, or both.  Past version 2, the first line is a
       header line without data.  Thus a version 3 file should start with
         flags  0 0. 0. 0  3
           where "flags" is the sum of:
              1 if the file has astigmatism values
              2 if the astigmatism axis angle is in radians, not degrees
              4 if the file has phase shifts
              8 if the phase shifts are in radians, not degrees
             16 if tilt angles need to be inverted to match what the
                 program expects (what Ctfplotter would produce)
                 with the -invert option
       The other values on the header line could be used in the future but
       should be 0.  If there are astigmatism values, the lower defocus value
       should be in the standard column for defocus, followed by the higher
       defocus value, then by the angle (counterclockwise positive) of the
       axis with the lower defocus (the long axis of the ellipse in an FFT).
       A file with just astigmatism values could start with:
       1  0 0. 0. 0  3
       61      61      -58.94  -58.94    4376    4652  -43.2

       If there are phase shifts, they go in a column at the end of the line.
       They can be positive or negative; only the absolute value will be used
       and equations using these shifts subtract the absolute value of the
       number.  A file with just phase shifts in radians could start with:
       12  0 0. 0. 0  3
       61      61      -58.94  -57.94    4376  1.47
       while a file with both astigmatism and phase shifts could start with:
       13  0 0. 0. 0  3
       61      61      -58.94  -57.94    4376    4652  -43.2  1.47
       Ctfplotter will not accept a version 3 file with astigmatism values
       or varying phase shifts, but it will accept one with a phase shift that
       is the same on every line.  In fact, if it is run with the -phase
       option to specify a fixed phase shift, it will output a version 3 file
       with that value, so that the option does not need to be supplied to
       Ctfphaseflip also.


AUTHORS
       Quanren Xiong and David Mastronarde

SEE ALSO
       ctfplotter

BUGS
       Prior to IMOD 4.0.29, Ctfplotter had a bug in which the view numbers
       written to the defocus file were numbered from 0, not 1.  When Ctf-
       phaseflip reads in the defocus file, it will do its best to detect this
       situation and adjust all the view numbers up by 1.  If it does detect
       an inconsistency between view numbers and angular ranges, it will issue
       a warning.

       Email bug reports to mast at colorado dot edu.



IMOD                                4.10.10                    ctfphaseflip(1)