align_warp
Purpose:
This is a nonlinear registration tool that can be used within or
across subjects and includes implementation of 2D and 3D nonlinear
spatial transformation models.
The program will generate a .warp
file that can be used to reslice the specified reslice data set
to match the specified standard data set.
Usage:
align_warp standard-file
reslice-file
.warp-out -m
model-menu-number
[final-model-menu-number]
[options]
- Model Menu:
- 3-D models:
- 1. first order linear 12 parameter model
- 2. second order nonlinear 30 parameter model
- 3. third order nonlinear 60 parameter model
- 4. fourth order nonlinear 105 parameter model
- 5. fifth order nonlinear 168 parameter model
- 2-D models:
- 21. first order linear 6 parameter model
- 22. second order nonlinear 12 parameter model
- 23. third order nonlinear 20 parameter model
- 24. fourth order nonlinear 30 parameter model
- 25. fifth order nonlinear 42 parameter model
options:
- where the following definitions apply:
- standard-file
- the name of the file that you want the other file resliced
to match (.img or .hdr suffix optional). The standard file will
often be an atlas, but can also be images from a single
subject.
- reslice-file
- the name of the file you want to reslice (.img or .hdr
suffix optional)
- .warp-out
- the exact name of the .warp transformation parameter output
file (cannot contain '.img' or '.hdr' and will not be modified
by the program).
- model-menu-number
- The order (a number from 1 through 5 ) of the polynomial
transformation used as a spatial transformation model. If the
optional final-model-menu-number (see next item) is provided,
the model selected here will be the model used initially, and
models will increment by one until the final model is reached.
If the optional final-model-menu-number is not provided, the
algorithm will start with a first order transformation and
increment to the order specified by this argument.
- final-model-menu-number
- See the description of the model-menu-number above.
- threshold-standard-file
- defines a minimum voxel value for the standard file. Voxels
in the standard file below this value are excluded from
analysis when computing the cost function and its derivatives.
The value should always be an integer less than the maximum
possible voxel value.
- threshold-reslice-file
- defines a minimum voxel value for the reslice file. Voxels
in the reslice file below this value are excluded from analysis
when computing the cost function and its derivatives. The value
should always be an integer less than the maximum possible
voxel value.
- FWHM-x FWHM-y
FWHM-z (standard-file)
- if this option is used, smoothing filters are applied along
the x, y and z axes of the standard file before performing
registration. The FWHM value specifies the full width at half
maximum of the Gaussian smoothing filter to be applied along
each dimension. The filters have units of millimeters (or
whatever units you use to specify voxel sizes in your .hdr
files). All three dimensions must be specified. If you give a
value of zero, no smoothing will be applied along the
corresponding dimension.
- FWHM-x FWHM-y
FWHM-z (reslice-file)
- if this option is used, smoothing filters are applied along
the x, y and z axes of the reslice file before performing
registration. The FWHM value specifies the full width at half
maximum of the Gaussian smoothing filter to be applied along
each dimension. The filters have units of millimeters (or
whatever units you use to specify voxel sizes in your .hdr
files). All three dimensions must be specified. If you give a
value of zero, no smoothing will be applied along the
corresponding dimension.
- standard-file-mask
- this file is applied to the standard file as a mask. The
file must match the standard file's dimensions, and voxels that
are zero in this file will be treated as if they were zero in
the standard file when computing the cost function. Mask files
can be binary or regular files.
- reslice_file_mask
- this file is applied to the reslice file as a mask. The
file must match the reslice file's dimensions, and voxels that
are zero in this file will be treated as if they were zero in
the reslice file when computing the cost function. Mask files
can be binary or regular files.
- initialization-file
- the name of an ASCII file containing spatial transformation
initialization parameters. If you override the default
procedure of starting with a first order model, it is very
important to use an initialization file (presumably derived
from some prior successful registration). Poor initialization
of high order transformations can lead to poor results. Each
spatial model requires different numbers of parameters in the
initialization file. Note that voxel intensity initialization
is performed separately in an
intensity parameter
initialization file.
- termination-file
- the name of an ASCII file to be created containing spatial
transformation termination parameters. These parameters can
then be used as initialization parameters to restart the
algorithm at the same location in parameter space. Unlike the
program alignlinear, in align_warp the termination file
automatically writes out an initialization file for the next
higher order of spatial transformation by adding an appropriate
number of zeros at the appropriate locations. If you don't
actually want to increment the model, use the -x argument as
well. Note that voxel intensity termination parameters must be
requested separately by identifying an
intensity parameter termination
file.
- overwrite?(y/n)
- 'y' if you want any preexisting file with the same name as
your termination file to be overwritten.
- scaling_initialization
file
- the name of an ASCII file containing the parameter that
initializes intensity scaling.
- scaling_termination_file
- the name of an ASCII file to be created containing the
intensity scaling parameter identified as optimal by the
algorithm. This parameter can be used to restart the algorithm
at the same location in parameter space where it left off. In
addition, the scaling parameter could be used as an intensity
normalization factor for subsequent statistical analysis of the
registered data.
- initial-sampling
- controls how densely data is sampled during the first
iterative cycle of the algorithm. Large values generally speed
up the registration process because gross misregistration can
be detected with fairly superficial sampling of the data.
However, choosing an excessively large value can be
counterproductive if the algorithm falls into an infinite loop
or is led far from the true value by nonrepresentative
sampling. Avoid multiples of two when choosing sampling
parameters. If any of your matrix dimensions are
divisible by two, the sampling will become spatially biased
until the sampling density reaches one, at which point the
algorithm will have to iteratively overcome the earlier bias at
the maximal sampling density. If your matrix dimensions are
divisible by three, you will have a similar problem with
sampling densities that are multiples of three.
- final-sampling
- controls how densely data is sampled during the final
iterative cycle of the algorithm. If your data is oversampled,
the time spent sampling very densely may not provide any
significant improvement in accuracy. Unlike alignlinear, the
default here is to end with sparse sampling at every ninth
voxel. Iterations will cease if the new sampling density is
less than the final_sampling density specified here.
- sampling-decrement-ratio
- determines the number of intermediate iterative cycles of
the algorithm. The current sampling is divided by this ratio
with each cycle to determine the new sampling.
- convergence-threshold
- controls how small the predicted change in the cost
function must be in order to meet the convergence criteria.
Setting this value too large will result in convergence while
the images are still misregistered; setting it too small may
lead to a failure to converge.
- repeated-iterations
- controls the maximum number of iterations permitted at each
sampling density. If this number is made too low, it will lead
to inaccurate results and/or slow down the overall performance
of the algorithm by preventing you from making use of
information that could have been derived more quickly at the
prematurely aborted, more superficial sampling.
- halt-after-(N)-iterations-without-improvement
- controls the maximum number of iterations without any
observed improvement in the cost function. If greater than or
equal to the "repeated_iterations" variable above, this value
has no effect. At lower values, it can help you escape from
situations where you are bouncing back and forth between two or
three locations in parameter space without making any real
progress. This sort of thing usually only happens at
superficial sampling densities.
- alternate-strategy-after-(M)-iterations-without-improvement
- similar to the preceding option except that it does not
force termination of the current sampling density, but rather
tries to split the difference between the locations in
parameter space at the current sampling. If greater than or
equal to the "halt-after-(N)-iterations-without-improvement" or
the "repeated-interations" variables above, this value has no
effect.
- don't write extra zeros (for
higher order model) in termination file
- this will prevent the program from appending zeros to a
termination file. This will allow the termination file to be
reused with the same spatial transformation model rather than
with the next higher order model.
- assume noninteraction of
spatial parameter derivatives
- ignoring the second derivatives of the interpolated voxel
values with respect to spatial location by selecting this
option can significantly improve the speed of the algorithm
with little cost in terms of accuracy.
- verbose mode
- information about every iteration will be printed to the
screen if you use the -v option. If you run a lot of
registrations and leave screen scrolling enabled with this
option, you will eventually fill up the disk and the system
will grind to a halt.
Examples:
align_warp subject1 subject2 subject2.warpsubject1 -m 2 -t1
10 -t2 10 -g s2.init -gs s2.inits
- This will derive a .warp file for aligning an image of
subject2 to match an image of subject1. Thresholds of 10 are
applied to each file, and the algorithm will start with a first
order transformation using the default assumption that the centers
of the files should be aligned. The algorithm will automatically
proceed to a second order polynomial spatial transformation model.
Termination files will called s2.init and s2.inits will be
created. If files called s2.init or s2.inits already exist, the
program won't run because it doesn't have permission to overwrite
these files.
align_warp subject1 subject2 subject2.warpsubject1 -m 3 3 -t1
10 -t2 10 -f s2.init -fs s2.inits -g s3.init y -gs s3.inits y
- This example picks up where the previous one left off. It
reads the parameters of the previous model from the termination
files and performs registration using a third order polynomial
spatial transformation model. Termination files called s3.init and
s3.inits are created. The .warp file from the first registration
is overwritten.If files called s3.init or s3.inits already exist,
they will be overwritten.
align_warp subject1 subject2 subject2.warpsubject1 -m 3 5 -t1
10 -t2 10 -f s3.init -fs s3.inits
- This example again picks up where the previous one left off.
It reads the parameters of the previous model from the termination
files and performs registration using a fourth and then a fifth
order polynomial spatial transformation model. It does not create
a termination file. The .warp file from the previous third order
registration is overwritten.
Comments:
- For MR data, it is recommended that you edit the data to
remove nonbrain structures (e.g., scalp, skull and dura). Even if
the algorithm does run successfully, you will have invested a lot
of computation time in making sure that your subjects' noses are
of similar size and shape, even if this means that their
cerebellums don't line up so well. For human PET data where
nonbrain structures are not prominent, editing is probably not
required.
- If you do edit the data, you can choose thresholds of 1
(unless you want the threshold to provide some additional editing
of low voxel values). Note that 8 and 16 bit data will require
different thresholds and that the thresholds should be chosen to
exclude nonbrain voxels.
- If you are using the algorithm for the first time, its best to
start with a low order polynomial and work your way up to get a
feel for how long the registration requires. Second order
polynomial models run reasonably fast, but fifth order polynomials
are extremely slow. You might also consider using very sparse
sampling to get a feeling for speed (e.g.,add " -s 81 81 3" to
your command line).Termination and initialization files will allow
you to proceed to higher order models without having to rederive
any work already done. If you want to do a fifth order fit right
away, set it up to run overnight (or maybe even over a weekend).
- For PET data, you probably will only get a third order
polynomial even if you request a fifth order because the algorithm
generally can't improve upon the third order results with PET
data. Since fifth order fits take much much longer, you might as
well save a lot of time and only ask for third order in the first
place. MRI data can generally sustain improvements through fifth
order.
- Missing data due to a limited field of view can lead to
unexpected or even bizarre results with high order warping. If you
are dealing with a restricted field of view, you should probably
stay with second or third order nonlinear models (or at least
carefully inspect the results obtained with higher order models.
- The -q option makes a substantial difference in terms of
reducing registration time.
- The first order polynomial registration provided by this
algorithm is probably not as accurate as the one that can be
derived using alignlinear. Although
the spatial transformation models are identical, alignlinear takes
advantage of the invertibility of the transformation to compute
the cost function in an unbiased fashion such that registration of
image A to image B will be the exact inverse of registration of
image B to image A. This is not the case here. In fact, I prefer
to use alignlinear to derive the initial linear transformation
using the scaled least squares cost function (-x 3 flag) and then
use that data to create an initialization file for this program
starting with a second order transformation. It is now possible to
have alignlinear create a termination file that is properly
formatted for use as an initialization file with this program (use
the alignlinear -w option, possibly also with the -ws option).
Alternatively, if you already used the -g option with alignlinear,
you can convert it to the correct
format.
- The use of mask files by this program is different from
alignlinear. There, the masks are
applied in a way that assures that edited images are never
directly compared to one another, preventing any tendency to just
line up the edited edges. Here, the masks are applied to both
images immediately, and the two edited images are directly
compared in computing the cost function. Maskfiles are included
here merely as a convenience. You will get the same results if you
simply edit the images and register the edited versions.
- Nonlinear transformations cannot be inverted analytically, so
think carefully when deciding which file should be the standard
file and which should be the reslice file.
Error messages: (alphabetical by
case)
See also: Generic error messages
- An image file name must follow -e1 or -e2
- These are flags that indicate that the next argument is a
mask file.
- A positive decimal number must follow -c
- A positive integer must follow -a
- A positive integer must follow -h
- A positive integer must follow -r
- A termination file name must follow -g
- -g is a flag indicating that the name of an ASCII file to
be created will follow
- A valid model number from the menu must follow -m
- valid models are: 1, 2, 3, 4, 5, 21, 22, 23, 24, and 25
- An initialization parameter file name must follow
-f
- -f is a flag indicating that the name of an existing ASCII
file will follow
- An integer must follow -t1 or -t2
- Argument after -a cannot start with - ; it must be a
positive integer
- Argument after -c cannot start with - ; it must be a
positive decimal number
- -c is followed by the convergence threshold, it must be
nonnegative
- Argument after -f cannot start with - ; it must be an
initialization parameter file name
- -f is a flag indicating that the name of an existing ASCII
file will follow
- Argument after -g cannot start with -; it must be a
termination file name
- -g is a flag indicating that the name of an ASCII file to
be created will follow
- Argument after -h cannot start with - ; it must be a
positive integer
- Argument after -m cannot start with - ; it must be a
valid model number from the menu
- valid models are: 1, 2, 3, 4, 5, 21, 22, 23, 24, and 25
- Argument after -r cannot start with - ; it must be a
positive integer
- -r is a flag that should be followed by the maximum number
of iterations at each sampling density
- Attempt to save .warp file ____ failed.
- Do you have write permission for the specified directory?
- Is the disk full?
- Dimension mismatch: ____: ____ ____ ____, ____: ____
____ ____
- Mask files must have the same dimension as the
corresponding data files.
- Failure in smoothing routine
- Inadequate RAM memory is the most likely cause
- File '____' exists, no permission to overwrite
- Termination files will not overwrite existing files of the
same name unless the termination file name is followed by a 'y'
- First three arguments cannot begin with a -
- the first three arguments are reserved for the names of the
standard file, reslice file and output file.
- Initial and final models must have the same dimension
(2D or 3D)
- You can't start with a 2D model and end with a 3D model or
vice versa. Check the two arguments after -m
- Name of output .air file cannot contain .hdr or
.img
- self-explanatory--this is to prevent overwriting of your
original data.
- Name of termination file cannot contain .hdr or
.img
- self-explanatory--this is to prevent overwriting of your
original data.
- Sorry, flag -____ is not defined for this program
- The specified flag does not have meaning to this program.
- Sorry, model ____ is not defined
- The specified model is not implemented in this program.
- Standard (____) and reslice (____) files both have only
a single plane of data ...
- A 2D model is required in this case
- The final model cannot be lower than the initial
model
- The first argument after -m must be lower than the second
argument after -m
- The initialization file provided ____ parameters, ____
are required for this model
- The number of parameters in the initialization file must
exactly match the number required by the selected model. Use
your text editor to revise the initialization file.
- Three arguments that follow -s cannot start with - ;
they must be positive integers
- Three integers must follow -s
- Three positive numbers must follow -b1 or -b2
- These are the FWHM smoothing values for the x, y, and z
dimensions of the files.
- WARNING: File '____' will be overwritten by the output
of this program
- The .warp file that you have specified will overwrite an
existing file with the same name. Hit Control-C to terminate
the program if overwriting is undesirable.
- WARNING: It is recommended that you use initialization
files with nonlinear transformations
- You have requested that the algorithm start with a higher
order (i.e.,nonlinear model) and have not provided an
initialization file. You risk seeing the evil "Hessian matrix
is not positive definite" warning and/or getting a bad result.
- WARNING: Hessian matrix is not positive
definite...
- The minimization algorithm has identified a potential
problem with the cost function tending towards a maximum or
being at a saddle point. Depending on whether you were close to
or far from convergence at the time, the results may be
acceptable or they may be bad. Either inspect the results
closely, or consider using the -q option which is less likely
to give rise to a non-positive definite Hessian matrix.
- You cannot use the -e1 flag twice on the same command
line
- You have requested two different masks be applied to the
same data set.
- You cannot use the -e2 flag twice on the same command
line
- You have requested two different masks be applied to the
same data set.
- You must specify a spatial transformation model using
the -m argument
- The -m argument, followed by a model number, is mandatory.
- Your final model ____ is not defined on the menu
- final_sampling (2nd argument after -s) cannot be >
initial_sampling (1st argument after -s)
- sampling_decrement_ratio (3rd argument after -s) must be
> 1
- threshold ____ is not in range of possible pixel
values
- The threshold must be in the possible range for the data
type of the corresponding file. If the threshold seems right,
review the data in the header of the data file.
- unable to create termination file '____'
- Do you have the necessary write permissions?
- Is the disk full?
- unable to open initialization file '____'
- Does the file exist?
- Do you have read permission?
- unable to parse arguments,argument ____ was expected to
begin with a -
- You have a number or letter where a new argument flag was
expected.
See also:
Modified:
October 25, 1997
© 1995-97 Roger P. Woods,
M.D.(rwoods@ucla.edu)