ANTsX / ANTsPy

A fast medical imaging analysis library in Python with algorithms for registration, segmentation, and more.
https://antspyx.readthedocs.io
Apache License 2.0
586 stars 161 forks source link

How to output and save deformation fields #648

Open yesulove opened 1 month ago

yesulove commented 1 month ago

I have a question that I would like to ask: For nonlinear transformations(eg:out['warpedmovout']), the output deformation field list has two elements

1.out['warpedmovout'][0] The first element is a. nii.gz file, but its shape is not three-dimensional but two-dimensional, so it should not be a deformation field but a Jacobian determinant of the deformation field. Because for two-dimensional registration, the dimension of the deformation field should be three.Can we obtain a deformation field with a three-dimensional shape? How to obtain and save it?

  1. out['warpedmovout'][1] The second element is a. mat file. What does this mean?
ntustison commented 1 month ago

The transformation components are located in out['fwdtransforms'] and out['invtransforms']. out['warpedmovout'] is the moving image warped to the space of the fixed image and is not a list.

With that correction and correcting the indices in the out['fwdtransforms']:

  1. `out['fwdtransforms'][0]`` is a .mat file describing the linear transform component of the transformation. It's an ITK format
  2. out['fwdtransforms'][1] is a nifti file constituting a 3-D displacement field for a 3-D registration. If that is not the case in your situation, we would need more information to diagnose.
cookpa commented 1 month ago

Nick, I think the warp field comes first, so that the elements go in order to antsApplyTransforms. It's reversed in the invtransforms

@yesulove, as to dimensions, the nifti warp field from a 2D registration has two dimensions and two components. At every voxel (i,j) there is a displacement vector (x,y). This, when composed with the linear transform matrix, is the full transform.

ntustison commented 1 month ago

Oops, thanks @cookpa. It's early here.

cookpa commented 1 month ago

@ntustison to err is human, but I've also noticed chatGPT gets confused about this

domadaaaa commented 2 weeks ago

Nick, I think the warp field comes first, so that the elements go in order to antsApplyTransforms. It's reversed in the invtransforms

@yesulove, as to dimensions, the nifti warp field from a 2D registration has two dimensions and two components. At every voxel (i,j) there is a displacement vector (x,y). This, when composed with the linear transform matrix, is the full transform.

I have a question too... Why do I calculate outs['fwdtransforms'][0] that the number of non-normal Jacobian determinants is always 0 after reading, but I am doing a deformable SyN registration