KCL-BMEIS / niftyreg

This project contains command line tools to perform rigid, affine and non-linear registration of nifti or analyse images as well as utilities
BSD 3-Clause "New" or "Revised" License
133 stars 41 forks source link

transforming points #97

Open taborzbislaw opened 1 year ago

taborzbislaw commented 1 year ago

I would like to determine how the points in the moving image are mapped to the points in the moving image registered to the fixed image. How to get this information? reg_f3d only returns the moving image registered to the fixed image but correspondence between the points in the moving image and in the registered moving image are lost. Thank you in advance for help.

taborzbislaw commented 1 year ago

Or at least how to apply transform between moving and fixed image to some other image e.g. mask

mmodat commented 1 year ago

Hi,

reg_f3d returns the warped floating (moving) image as well as the control point grid that encodes the transformation. The default name for the grid is outputCPP.nii. You can change the output filename using the -cpp argument.

Should you want to obtain a dense deformation or displacement field, you can use reg_transform to convert the control point grid into a dense field: reg_transform -ref referenceFile -def CPP_from_f3d output_deformation reg_transform -ref referenceFile -disp CPP_from_f3d output_displacement

The deformation and displacement fields are saved as 5D images with dimension <dimX, dimY, 1, 1, 2> and <dimX, dimY, dimZ, 1, 3> for 2D and 3D respectively, where dimX, dimY and dimZ are the number of voxel along each axis of your reference (fixed) image. Assuming 3D images, the deformation or displacement at position x, y, z along the x-, y- and z-axis are stored in [x, y, z, 0, 0], [x, y, z, 0, 1] and [x, y, z, 0, 2] respectively.

Note that the transformation are encoded from the reference to the floating space and all is stored in physical space (mm) rather than voxel space.

Hope that helps.

koegl commented 6 months ago

Hi,

reg_f3d returns the warped floating (moving) image as well as the control point grid that encodes the transformation. The default name for the grid is outputCPP.nii. You can change the output filename using the -cpp argument.

Should you want to obtain a dense deformation or displacement field, you can use reg_transform to convert the control point grid into a dense field: reg_transform -ref referenceFile -def CPP_from_f3d output_deformation reg_transform -ref referenceFile -disp CPP_from_f3d output_displacement

The deformation and displacement fields are saved as 5D images with dimension <dimX, dimY, 1, 1, 2> and <dimX, dimY, dimZ, 1, 3> for 2D and 3D respectively, where dimX, dimY and dimZ are the number of voxel along each axis of your reference (fixed) image. Assuming 3D images, the deformation or displacement at position x, y, z along the x-, y- and z-axis are stored in [x, y, z, 0, 0], [x, y, z, 0, 1] and [x, y, z, 0, 2] respectively.

Note that the transformation are encoded from the reference to the floating space and all is stored in physical space (mm) rather than voxel space.

Hope that helps.

I'm trying to use the output_displacement in 3D Slicer to deform the reference image, however, I get very different (I guess) results than from the output of reg_f3d. Do you maybe have an idea why this might be the case?

I'm wondering if the fact that it is stored in physical space has something to do with that.