mtffilter(1)                                                      mtffilter(1)



NAME
       mtffilter - filter by inverse of MTF and general Fourier filter

SYNOPSIS
       mtffilter [options] input_file [output_file]

DESCRIPTION
       Mtffilter can restore contrast in CCD camera images by multiplying them
       by the inverse of the camera's modulation transfer function (MTF).  It
       can also apply a low pass filter to reduce high frequency noise, as
       well as a high pass filter to eliminate low frequencies.  Any combina-
       tion of these filters may be applied.  In fact, the program provides
       all of the options that Enhance does for specifying a general
       Fourier filter.  Because images are automatically padded to dimensions
       suitable for taking an FFT, there are no restrictions on image size,
       unlike with Enhance.  This program can filter either real-space
       images in 2D planes, real-space images in 3D or 3D Fourier transforms
       in 3D.  The filter functions produced by these options can be visual-
       ized with the program Filterplot; see that man page for a full
       description of their effects.

       The program can also apply a third kind of filter that has been found
       useful for reducing fringe effects in EM images taken with a phase
       plate.  This filter is specified by a cutoff radius, and exponential
       power, and an amplification factor, the amount by which it amplifies
       low frequencies relative to high ones.  It goes from 1 at zero fre-
       quency to a floor of 1/ amplificationFactor at high frequencies and
       falls 1/e of the way to the floor at the cutoff radius.  A higher power
       increases the sharpness of the falloff.  This filter is referred to
       here as a low-frequency amplifier filter.  It is selected by entering
       the -amplifier option plus either the cutoff radius (with -cutoff) or
       parameters of the phase plate imaging (with -phase).  It cannot be used
       together with the low-pass and high-pass filter options.

       Simply multiplying by the inverse of an MTF would amplify noise too
       much, so the inverse MTF filter is shaped by three parameters.  The
       first and most important is the maximum inverse value, which limits how
       high the inverse can become.  The other two parameters are a cutoff
       frequency at which to start a Gaussian rolloff of the inverse back to
       1.0, and the sigma value for this Gaussian rolloff.  The default values
       for these parameters (listed below) are based on limited experimenta-
       tion and are fairly conservative.  All of these parameters together
       will keep the inverse filter from amplifying high frequency noise.  The
       low pass filter's role is to filter out those high frequencies.

       If both filters are used, there are potentially 4 different frequency
       ranges:
         1) From 0 to the frequency at which the inverse reaches its maximum,
       the filter is actually the inverse of the MTF,
         2) From there to the cutoff frequency for the inverse rolloff, the
       filter equals the maximum inverse,
         3) Beyond this cutoff frequency, the filter progressively decays back
       to 1.0,
         4) Beyond the cutoff radius for the low-pass filter, the filter is
       multiplied by another Gaussian and decays to 0.

       The MTF curve to be applied should be read in from a file containing
       values for spatial frequency (in reciprocal pixels) and for the MTF,
       one pair per line.  The program has one built-in curve in which the MTF
       crosses 0.5 at 0.117/pixel.  This curve can be adjusted by scaling its
       axis, which will make it approximately correct for other situations.

       To apply only low-pass and high-pass filters, omit the -mtf and -stock
       options; to apply only an inverse filter, omit the -lowpass and other
       options for general filtering.  Similarly, to apply only a low-fre-
       quency amplifier filter, omit the -mtf and -stock other general filter
       options.

       If the input file is a real image, then without the "-3d" option the
       program will take the FFT of each section, apply the filter, take the
       inverse FFT, and write out the filtered section.  With the "-3d"
       option, it will load the whole file into memory, tapered and padded
       just as in Taperoutvol, take the 3D FFT, filter, inverse FFT, and
       write the volume.  If the input file is a Fourier transform, it must be
       a 3D FFT (obtained from "clip fft -3d" or "fftrans -3d").  In this case
       the program will apply the filter to the transforms in three dimensions
       and write out a filtered FFT.

       The program allocates memory dynamically, so it is capable of filtering
       a rather large volume in 3D, as long as the padded volume is smaller
       than 2 gigavoxels.  However, it will require 4 bytes of memory per
       voxel; e.g., 4 GB for a 1 gigavoxel volume.  In addition, the time per
       voxel increases as the log of the volume size, so it can be quicker to
       chop a volume into pieces, filter them, and reassemble the result.  To
       filter a large image file in 3D this way, simply make a file filter-
       big.com with one line:
          $mtffilter -3d <filtering options> INPUTFILE OUTPUTFILE
       where you insert your filtering options, but INPUTFILE and OUTPUTFILE
       are exactly as shown, and not the names of your actual input and output
       files.  The run:
          chunksetup -p 0 filterbig.com  input_file output_file
       where "-p 0" eliminates padding because Mtffilter will take care of
       padding, and this time you do put your actual input and output file
       names.  See Chunksetup for details.  You can execute the resulting
       command files with parallel processing (via Processchunks or eTomo)
       or sequentially with:
          subm filterbig-all

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


       -input (-inp) OR -InputFile    File name
              Input file with images to be filtered

       -output (-o) OR -OutputFile    File name
              Output file for filtered images.  If this file is omitted, the
              program will write filtered images back to the input file.

       -zrange (-z) OR -StartingAndEndingZ      Two integers
              First and last Z values in the file to filter.  Values are num-
              bered from 1 and the default is to do all sections.

       -3dfilter (-3) OR -FilterIn3D
              Filter data in 3D instead of in 2D.  The entire volume will be
              filtered, so it must fit into memory and -zrange cannot be
              entered.  If the volume will not fit in memory, use "clip fft
              -3d" to get an FFT, run Mtffilter on the 3D FFT, then inverse
              transform with "clip fft -3d -m mode", where mode is the desired
              output mode, typically the same as the input.

       -lowpass (-l) OR -LowPassRadiusSigma     Two floats
              Cutoff radius and sigma for a low pass filter that imposes a
              high-frequency Gaussian roll-off to 0.0.  The default is no
              high-frequency filtering.  These entries correspond to the
              Radius2 and Sigma2 entries to Enhance and other programs; see
              the Enhance or Filterplot man pages for a full explanation
              of the effects of changing the sign of the Sigma2 or the Sigma1
              and Radius1 parameters entered with the next two options.

       -highpass (-hi) OR -HighPassSigma   Floating point
              Sigma for a high pass filter based on an inverted Gaussian that
              starts at 0.0 at zero frequency and decays up to 1 with the
              given sigma.  The default is no high-frequency filtering.  This
              entry corresponds to the Sigma1 entry to Enhance and other
              programs.  A negative Sigma1 can be used to get a band-pass fil-
              ter based on the second derivative of a Gaussian.

       -radius1 (-r) OR -FilterRadius1     Floating point
              Cutoff radius for a high-pass filter that is 1.0 at this radius
              and falls off as a Gaussian to the left of this point with sigma
              equal to the Sigma2 value entered with -lowpass.  This entry
              corresponds to the Radius1 entry to Enhance and other pro-
              grams.  A negative Radius1 will make the inverted Gaussian
              invoked by -highpass be zero out to |Radius1|.

       -mtf (-mt) OR -MtfFile    File name
              File with MTF curve.  The format of the file is a series of
              lines, with a spatial frequency in reciprocal pixels and an MTF
              value on each line.

       -stock (-s) OR -StockCurve     Integer
              The number of the stock (built-in) MTF curve to use.  Since
              there is only one curve, only an entry of 1 is allowed.

       -maxinv (-ma) OR -MaximumInverse    Floating point
              Maximum value for inverse of MTF.  The inverse should always be
              limited to reduce noise.

       -invrolloff (-inv) OR -InverseRolloffRadiusSigma   Two floats
              Radius and sigma for gaussian roll-off of inverse to 1.0
              (default 0.12 and 0.05)

       -xscale (-x) OR -XScaleFactor       Floating point
              Scaling factor for X-axis of MTF curve.  Scaling the X axis is
              probably an adequate way to adapt a curve from one camera or
              binning to another.

       -denscale (-d) OR -DensityScaleFactor    Floating point
              Scaling factor for image intensities after filtering.

       -amplifier (-a) OR -AmplifierFactorAndPower   Two floats
              Amplification factor and exponent for low-frequency amplifier
              filter.  Either -cutoff or -phase must also be entered.

       -cutoff (-c) OR -CutoffForAmplifier      Floating point
              Cutoff radius in reciprocal pixels for amplifier filter.  This
              option cannot be entered together with -phase.

       -phase (-ph) OR -PhasePlateParameters    Three floats
              Parameters of phase plate imaging, used to compute a nominal
              cutoff radius for the low-frequency amplifier filter.  Enter the
              phase plate diameter in nanometers, the voltage in kilovolts,
              and the objective lens focal length in millimeters.

       -pixel (-pi) OR -PixelSize     Floating point
              Pixel size in nanometers.  A pixel size is needed to compute the
              cutoff radius for the amplifier filter from the phase plate
              parameters.  This entry is needed only if the pixel size in the
              image file header is incorrect.

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

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

       -StandardInput
              Read parameter entries from standard input.


HISTORY
       Added to package, 3/30/04
       Added ability to operate on 3D FFT, 6/19/04
       Added ability to take filter real volume in 3D, 5/20/08

BUGS
       Email bug reports to mast at colorado dot edu.



BL3DEMC                              4.7.3                        mtffilter(1)