lassoan / SlicerElastix

This extension makes available Elastix medical image registration toolkit (http://elastix.isi.uu.nl/) available in Slicer.
MIT License
49 stars 29 forks source link

Prevent Transformix from writing output image if output volume node note given #19

Closed prash-p closed 5 years ago

prash-p commented 5 years ago

Pull request in response to this discussion https://discourse.slicer.org/t/prevent-transformix-running-in-slicer-elastix/7902

lassoan commented 5 years ago

Does this work? If you don't run transformix then what would generate deformationField.mhd?

I think we need to implement a reader for elastix transformation files as I described it here.

prash-p commented 5 years ago

It works on the data I had to test on. Transformix still runs to produce the deformation field, but the input parameters are altered so an output image isn't created if not required. This can save a little bit of time at the end of the registration process.

I agree the ideal situation would be to convert the proprietary transforms into a slicer transform, instead of running transformix. I'll take a look at your work on it and see if I can contribute in any way.

lassoan commented 5 years ago

OK, I see, so we run transformix anyway, but we don't generate resampled output volume if we don't need it.

Could we simply make inputParamsTransformix += ['-in', os.path.join(inputDir, 'moving.mha')] conditional (only add it if resampled moving volume is needed) instead of duplicating about 20 lines of code?

This change will help a bit, but implementing transform reader would make a huge difference: we could get the transform in seconds (immediately if only linear) and store it in a few kilobytes instead of hundreds of megabytes.

prash-p commented 5 years ago

Yes that would work I think, but we need to consider the condition when the user wants an output volume but no transformation. In this case we could just not create an output transform node?

lassoan commented 5 years ago

Yes, we need to handle volume, transform, and volume+transform cases, preferably with a single call of transformix (just by tuning its command-line arguments).

prash-p commented 5 years ago

Do you want me to make those changes, or are you working on it?

lassoan commented 5 years ago

Please make the changes. Thank you!

prash-p commented 5 years ago

Should work same as before but with fewer lines now.