WIP: Estimate inverse warp field when invert is set in MINC Grid XFM#194
WIP: Estimate inverse warp field when invert is set in MINC Grid XFM#194gdevenyi wants to merge 1 commit intoInsightSoftwareConsortium:masterfrom
Conversation
|
This patch addresses half of the problem cited at #147 (comment) The other half will be added in that patch (flipping vector field directions) |
|
Hi @vfonov this fix is independent of the RAS<->LPS work, it estimates the inverse transform via a method similar to grid_inverse_transform_point_with_input_steps from grid_transform.c |
|
|
Hi @vfonov, The default for the filter is to create a domain and sampling identical to the input deformation field. The time added for a 1mm iso nlin registration invert for the default 5 iterations is ~7ms. |
|
well in my experiment, running InvertDisplacementFieldImageFilter with default parameters on a a 2x2x2 grid file produced by MINC longitudinal pipeline takes about 1 min. Is IterativeInverseDisplacementFieldImageFilter that much faster and still produces appropriate result? |
|
Sorry, follow-up here, a bit of a mixup on the timings, I was using the internal timing from the Print() functionality of the IterativeInverse function, which seems to be the mean of some loop within the code, rather than the true value. I annotated the code with a itk::TimeProbe Here are the results for a 1x1x1 mm deformation field generated from antsRegistration between the GAD and MNI model mentioned in the RAS/LPS discussion, applied using antsApplyTransforms, this is specifically the time spent in the inversion filter. Settings for the filters, Invert (settings based on the ITK example): InverativeInverse: Time elapsed: 8.78565 minccmp comparing the transformed images made with the "true" inverse field (generated by antsRegistration) and the inverted fields: Invert: Happy to switch to the Invert filter based on it being faster and more accurate. |
|
So, it looks like it works fast on a "good" deformation field from ANTs , how long would it take on a not so smooth field from minctracc? |
|
Here, this is output of CIVET pipeline on SAMIR-99 data sample. Let's see what the proposed code will do. |
|
Thanks @vfonov I generated nlpfit outputs (2x2x2) using the same GAD-MNI pairs and got the following results: And generating inverse field files from the SAMIR-99 data you sent with antsApplyTransforms -o [output.mnc,1] |
d174e02 to
67327b3
Compare
|
Updated PR to use Invert filter instead of IterativeInverse filter. |
|
is the result similar to |
|
I don't have/couldn't find a copy of SAMIR-99 so I couldn't directly compare resamples, but for the GAD-MNI pair from nlpfit: Its not quite as nice a comparison as the antsRegistration one since minctracc doesn't produce a forward/reverse pair that I can use to do a more-head-to-head comparison, but everything looks fine. |
|
technically it is pretty trivial to see if the inverse is good - i.e X * inv(X) = identity |
|
Thanks @vfonov, an excellent suggestion re: identity. Here, I concat (via added two transforms to the text of the .xfm) the forward and reverse transforms and apply those transforms with mincresample, and antsApplyTransforms with the itkInvertDisplacementField. I then compare these outputs using minccmp against the original image since this operation should be the identity operation: antsApplyTransforms: Look like the InvertDisplacement filter does a good job, and does so in 0.973168 seconds according to my instrumentation of the code. |
|
ok, let's merge it into the mainline ITK. |
|
+1 on a test. I'll look at how to add one and whether some of the existing example files could be used. |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
vfonov
left a comment
There was a problem hiding this comment.
We still need a test code to check if concatenation of inverted transform with itself is identity.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
This code is valid, I still need to add tests |
Currently, the handling for the TransformMINC Grid nonlinear transforms fail to handle files with
Invert_Flag = True;in them due to the following failure:This line:
https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/IO/TransformMINC/include/itkMINCTransformIO.hxx#L163
Results in this failure in antsApplyTransforms:
In this patch I add a itkIterativeInverseDisplacementFieldImageFilter stage to estimate an inverted displacement field and provide it to the displacement field input.
I originally tried this with InverseDisplacementFieldImageFilter however the filter update step caused a segfault with no exception thrown so I'm currently unable to debug any further. Another alternative implementation would use FixedPointInverseDisplacementFieldImageFilter however it is currently an external module so I don't want to depend on it.
This was tested by:
Invert_Flag = True;Paging @vfonov