[MINC-users] Issue with itk_convert_xfm

Vladimir S. FONOV vladimir.fonov at gmail.com
Thu Jan 14 17:46:13 EST 2016


This code works properly:



make_phantom phantom.mnc
param2xfm -translation 10 10 10 trans.xfm

# Apply the xfm
mincresample -use_input_sampling -invert_transform -transform trans.xfm 
phantom.mnc out.mnc -clob

# Do the same transform in nifti space
itk_convert_xfm trans.xfm trans.mat --clob

itk_convert phantom.mnc phantom.nii --clob
antsApplyTransforms --input phantom.nii \
--transform trans.mat \
--output out.nii \
--reference-image phantom.nii

itk_convert out.nii thru_nifti.mnc --clob








On 16-01-14 05:04 PM, Andrew Wood wrote:
> Hi Vlad,
>
> I think I didn't explain my issue correctly. Let me
> add -invert_transformation to my mincresample invocation and try again.
>
>
> Here are the commands that I think illustrates a problem:
> $ make_phantom phantom.mnc
> $ param2xfm -translation 10 10 10 trans.xfm
>
> # Apply the xfm
> $ mincresample -use_input_sampling -*invert_transformation* -transform
> trans.xfm phantom.mnc out.mnc
>
> # Do the same transform in nifti space
> $ itk_convert_xfm trans.xfm trans.mat
> $ mnc2nii phantom.mnc phantom.nii
> $ antsApplyTransforms --input phantom.nii \
> --transform trans.mat \
> --output out.nii \
> --reference-image phantom.nii
>
> # Open result in a minc+nifti-friendly viewer, or convert back to minc
> $ nii2mnc out.nii thru_nifti.mnc
> $ register out.mnc thru_nifti.mnc
>
>
>
> As far as I can tell, out.mnc and thru_nifti.mnc should be identical, but
> they clearly are not.
>
> Best,
> Andrew
>
> On Thu, Jan 14, 2016 at 4:39 PM, Vladimir S. FONOV <vladimir.fonov at gmail.com
>> wrote:
>
>> antsApplyTransforms is basically equivalent to mincresample
>> -invert_transformation
>>
>> On Thu, Jan 14, 2016 at 3:18 PM, Andrew Wood <andrew at biospective.com>
>> wrote:
>>
>>> Hi all,
>>>
>>> I came across a set of transforms generated by ANTs which I've been
>> trying
>>> to convert and use on minc volumes. There seems to be a bug in one or
>> more
>>> of the tools I'm using, where applying the transforms to nifti volumes
>> does
>>> not give the same result as applying them to minc volumes.
>>>
>>> Likely culprits:
>>> - itk_convet_xfm
>>> - mnc2nii or nii2mnc
>>> - antsApplyTransforms
>>> - mincresample
>>>
>>> Somewhere along the way, several components of the transforms get
>> inverted.
>>> Here is an example:
>>>
>>> $ make_phantom phantom.mnc
>>> $ param2xfm -translation 10 10 10 trans.xfm
>>>
>>> # Apply the xfm
>>> $ mincresample -use_input_sampling -transform trans.xfm phantom.mnc
>> out.mnc
>>>
>>> # Do the same transform in nifti space
>>> $ itk_convert_xfm trans.xfm trans.mat
>>> $ mnc2nii phantom.mnc phantom.nii
>>> $ antsApplyTransforms --input phantom.nii \
>>> --transform trans.mat \
>>> --output out.nii \
>>> --reference-image phantom.nii
>>>
>>> # Open result in a minc+nifti-friendly viewer, or convert back to minc
>>> $ nii2mnc out.nii thru_nifti.mnc
>>> $ register out.mnc thru_nifti.mnc
>>>
>>> The result of this for me is that the z component of the transform was
>>> inverted, but the x and y components are OK.
>>>
>>>  From experimenting with various simple transforms, it seems that the
>>> following components are inverted:
>>>     - z translation
>>>     - z rotation
>>>     - x,y,z scale
>>>     - x shear
>>>
>>> Has anybody else noticed or dealt with this before?
>>>
>>> Thanks,
>>> Andrew
>>> _______________________________________________
>>> MINC-users at bic.mni.mcgill.ca
>>> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>>>
>>
>>
>>
>> --
>> Best regards,
>>
>>   Vladimir S. Fonov ~ vladimir <dot> fonov <at> gmail <dot> com
>> _______________________________________________
>> MINC-users at bic.mni.mcgill.ca
>> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>>
> _______________________________________________
> MINC-users at bic.mni.mcgill.ca
> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>


-- 
Best regards,

  Vladimir S. FONOV ~ vladimir.fonov <at> gmail.com


More information about the MINC-users mailing list