Skip to content
Marius Staring edited this page Apr 13, 2021 · 4 revisions

I am getting the error message: "Library not loaded: libANNlib.dylib" (on Mac) or similar on Linux.

  1. On Linux, the solution is: add the elastix lib directory to your LD_LIBRARY_PATH. You can add the following line to ~/.bashrc or ~/.bash_profile:

    export LD_LIBRARY_PATH=yourelastixdir/lib:$LD_LIBRARY_PATH

  2. On Mac, the solution is: add the elastix lib directory to your DYLD_LIBRARY_PATH. You can add the following line to ~/.bashrc or ~/.bash_profile:

    export DYLD_LIBRARY_PATH=yourelastixdir/lib:$DYLD_LIBRARY_PATH

With what compilers does elastix work?

At least with the ones that are used on the nightly dashboard: https://my.cdash.org/index.php?project=elastix. Currently (2013), these include Microsoft Visual C++ 2008 and 2010 on Windows and gcc 4.x and clang 3.3+ on Linux 64bit or on Mac OS X. The underlying ITK code works with numerous compilers.

Do you have a manual?

Yes!

elastix does not start on Windows and complains about missing libraries.

On some Windows systems it might be necessary to install the Microsoft Visual C++ Redistributable Package. Depending on the elastix version you are using it may be the one for MSVS 2008 (x64), for MSVS 2010 (x64), for MSVS 2012 (x64), or MSVS 2015 (x64). Redistributable packages for x86 or for other MSVS compiler versions are also available on that website, via this link.

The error message may be something like:

  1. The application failed to initialize properly (0xc0000135).
  2. This application has failed to start because the application configuration is incorrect. Reinstalling application may fix this problem.
  3. The system cannot execute the specified program.
  4. R6034 An application has made an attempt to load the C runtime library incorrectly.
  5. This application has failed to start because MSVCR90.dll was not found. Re-installing the application may fix this problem.
  6. Resolve Partial Assembly failed for Microsoft.VC90.CRT. Reference error message: The referenced assembly is not installed on your system.

Since elastix 4.8 we also have a dependency on the OpenCL library for GPU support. In case of issues you may want to update the drivers of your GPU.

I am getting the error message: "Too many samples map outside moving image buffer". What does that mean?

This can have several causes:

  1. Wrong initialization: the fixed and moving image are for a large part or completely non-overlapping. It is not possible to start the registration now. Check the headers of your images. Good image formats store the origin and image orientation. It will tell you if this is indeed the cause of the problem. You can solve the problem by:

    1. manually specifying an initialization by providing a proper transformation that roughly aligns the two images. This can be done by using "-t0 TransformParameters.txt" in the call to elastix.

    2. automatically initializing the registration by putting the centres of the two images on top of each other. This can be done by adding "(AutomaticTransformInitialization "true")" to the parameter file.

  2. Too large steps are taken during the registration. Initially the images have an overlap, but during the registration the moving image is moved such that the overlap disappears. Usually, this is because too large steps are taken during the registration. You can solve the problem by:

    1. decreasing the stepsize of the optimizer.
    2. if you are using a rigid or affine transformation, then maybe only too large steps are taken for the parameters that define the rotations (or the affine matrix). These parameters are differently scaled as the translations, and therefore the stepsize for these parameters are scaled by some user-specified number. You may need to increase the scales by setting "(Scales float)" in the parameter file to an appropriate value.
  3. Too small moving image mask. This can happen especially when no mask for the fixed image is used. During registration samples are drawn from the fixed image, and subsequently mapped to the moving image. If a mask for the moving image is used, some of these samples have no corresponding points within the moving image mask. When the mask is small the correspondence is insufficient to compute a valid metric value. You can solve this problem by:

    1. using a mask for the fixed image instead of the moving image.
    2. using also a mask for the fixed image on the corresponding region.
    3. Make elastix retry drawing samples for a number of times by specifying (MaximumNumberOfSamplingAttempts 10) in the parameter file.
  4. Moving image much smaller than fixed image. During registration samples are drawn from the fixed image, and subsequently mapped to the moving image. When the moving image is much smaller than the fixed image (in physical space), some of these samples have no corresponding points within the moving image. The correspondence is insufficient to compute a valid metric value. You can solve this problem by:

    1. Make elastix accept insufficient overlap earlier (RequiredRatioOfValidSamples 0.05) in the parameter file. The default is 0.25, i.e. 25% of the fixed image samples should have a correspondence.

I am getting the error message: "Could not find enough image samples within reasonable time. Probably the mask is too small". What can I do about it?

Explanation: When sampling the fixed image you walk over it and check for each voxel if it is within the fixed image mask. If so, the sample is included, if not it is excluded. Drawing image samples is stopped:

  1. when the desired number of samples are drawn. This is ok, you will not get this error message.
  2. after drawing 10 times the desired number of samples. If after this, you still don't have the desired number of samples, elastix is terminated and this error message is thrown. This is to avoid getting stuck in a seemingly endless loop.

Solution: You can use the RandomSamplerSparseMask by adding "(ImageSampler "RandomSparseMask")" to the parameter file. This sampler walks over the fixed image mask to draw samples. Note that for this sampler, samples are drawn from the voxel grid, no RandomCoordinateSamplerSparseMask is currently available.

I registered two downsampled images. How do I apply the transformation on the full sized moving image?

You take the TransformParameter.txt file resulting from the registration and change the Size and Spacing to the ones of the full image. Then you can use transformix to apply this transformation:

transformix -in fullImage.ext -tp TransformParameter_Changed.txt -out outputDirectory

I applied the transformation as found by the registration on a binary segmentation, but the deformed segmentation is not binary anymore and contains holes?

This is due to the interpolation. You can change the interpolation order in the TransformParameter.txt file to nearest neighbour interpolation:

(FinalBSplineInterpolationOrder 0)

Is it possible to transform a set of points instead of a complete image with transformix?

Yes, that is possible. See section 4.2 of the manual.

transformix -tp TransformParameters.txt -out outputDirectory -def FileWithPoints.txt

The text file "FileWithPoints.txt" should be created with a certain structure. The first line should be "index" or "point", depending if the user supplies voxel indices or real world coordinates. The second line should be the number of points that should be transformed. The third and following lines give the indices or points. It is also possible to deform all points, thereby generating a deformation field image. This is done using -def all in the call to transformix.

Is it possible to apply the inverse transformation with elastix?

Section 6.1.6 of the manual explains how to compute the inverse.

Clone this wiki locally