Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Transformation map not working #30

Closed
mongoose54 opened this issue Mar 29, 2016 · 5 comments
Closed

Transformation map not working #30

mongoose54 opened this issue Mar 29, 2016 · 5 comments

Comments

@mongoose54
Copy link

@kaspermarstal So I am following I perform registration on 2 images and then I apply the transformation map on a 3rd image "image.nii" and I get the following messages on the console:

transformix is started at Mon Mar 28 19:05:30 2016.

Installing all components.
InstallingComponents was successful.

ELASTIX version: 4.801
Command line options from ElastixBase:
-out C:\elastixtestlogs
-threads unspecified, so all available threads are used
-def unspecified, so no input points transformed
-jac unspecified, so no det(dT/dx) computed
-jacmat unspecified, so no dT/dx computed

Reading input image ...
Reading input image took 0.000007 s
Calling all ReadFromFile()'s ...
Calling all ReadFromFile()'s took 6.963650 s
Transforming points ...
The command-line option "-def" is not used, so no points are transformed
Transforming points done, it took 0.00s
Compute determinant of spatial Jacobian ...
The command-line option "-jac" is not used, so no det(dT/dx) computed.
Computing determinant of spatial Jacobian done, it took 0.00s
Compute spatial Jacobian (full matrix) ...
The command-line option "-jacmat" is not used, so no dT/dx computed.
Computing spatial Jacobian done, it took 0.00s
Resampling image and writing to disk ...
Resampling took 4.97s

Transformix has finished at Mon Mar 28 19:05:42 2016.
Elapsed time: 11.9s.

Here is code. I don't understand what I need to pass to transformix other than the transformation map calculated previously.

`public void simpleelastixtest() {

CastImageFilter caster = new CastImageFilter();
caster.setOutputPixelType(PixelIDValueEnum.sitkFloat32);

// Instantiate SimpleElastix
org.itk.simple.SimpleElastix elastix = new org.itk.simple.SimpleElastix();

// Read input
org.itk.simple.ImageFileReader reader1 = new org.itk.simple.ImageFileReader();

reader1.setFileName("brain1.png");
Image castImage1 = caster.execute(reader1.execute());
elastix.setFixedImage(castImage1);

org.itk.simple.ImageFileReader reader2 = new org.itk.simple.ImageFileReader();
reader2.setFileName("brain2.png");
Image castImage2 = caster.execute(reader2.execute());
elastix.setMovingImage(castImage2);

elastix.setParameterMap(elastix.getDefaultParameterMap("nonrigid"));
elastix.logToConsoleOn();
elastix.logToFolder("\elastixtestlogs");

// Perform registration
elastix.execute();

// Write result image
ImageFileWriter writer = new org.itk.simple.ImageFileWriter();
writer.execute(elastix.getResultImage(),"output.nii",false);

//Apply transformation map
org.itk.simple.ImageFileReader reader3 = new org.itk.simple.ImageFileReader();
reader3.setFileName("image.nii");

org.itk.simple.SimpleTransformix transformix = new org.itk.simple.SimpleTransformix();
transformix.logToFolder("\elastixtestlogs");
transformix.setInputImage(reader3.execute());
transformix.setTransformParameterMap(elastix.getTransformParameterMap());

org.itk.simple.Image resultMask = transformix.execute()

writer.execute(resultMask, "result.nii", false);

}`

@kaspermarstal
Copy link
Member

The output you see is just transformix telling you what is doing while it is running (useful for debugging).
You can turn off logging to console using transformix.logToConsoleOff(). Just to be sure, transformix successfully warped your image right?

@mongoose54
Copy link
Author

@kaspermarstal No unfortunately transformix doesn't warp the image. See the output above:

The command-line option "-def" is not used, so no points are transformed

I am attaching the 2 test images that I am trying to register for your convenience.

knee2
knee1

Thanks!

@kaspermarstal
Copy link
Member

Thanks for the images. The -def message you refer to is related the warping of point sets, not images. For example, if you had specified transfomix.setInputPointSetFilename("points.pts") transformix would tell that the -def argument was detected and points would be warped. In this case the relevant lines here are

Resampling image and writing to disk ...
Resampling took 4.97s

Perhaps you can make a mean image of fixed and moving images and a mean image of fixed and result images to confirm that a transformation takes place?

@kaspermarstal
Copy link
Member

I should add a section to the documentation on how to interpret the log, I'd give you that 😊

@mongoose54
Copy link
Author

@kaspermarstal Thanks for clarifying. After testing the output of the transformix I saw that it has indeed applied the warping. It looked as if it hadn't applied it because it was so close to each other :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants