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
608 stars 161 forks source link

Rotation in registration module #494

Closed Volodimirich closed 1 year ago

Volodimirich commented 1 year ago

Hello, I have a question about the registration module. I am solving the task of atlas overlay for brain CT and an important step in solving this task is registration. The most important step in solving this problem is the rotation of the brain, because the position of the head can deviate by +- 30 degrees.

In your library I have found a module that is perfect for this task, but there is a small problem:

gr_tm, br_tm = ants.from_numpy(gr_truth[120]), ants.from_numpy(brain2[120])
res_ants = ants.registration(gr_tm, br_tm, type_of_transform='Similarity', aff_metric='GC', restrict_transformation=(1,1,0))

After that I have the following results (third picture):

image

But the problem is that the brain has not only turned, but has also changed size, which is highly undesirable in this task.

I tried changing the transform type to Rigid, but the results are much worse that way:

image

I tried changing the function parameters, but couldn't achieve the result. Is there any way to keep only the rotation from the first transformation? Or get the rotation matrix from the current transformation?

ntustison commented 1 year ago

How are you visualizing the results? The fact that you're converting from a numpy array without any explicitly supplied image geometry information suggests that perhaps you're performing registration with potentially incorrect assumptions.

Volodimirich commented 1 year ago

@ntustison In both cases, the voxel size is 1 and I thought that was enough for correct visualization. Initially the data were dicom files and were read with pydicom. If I read the files through ants.core.ants_image_io.dicom_read, will the situation change?

ntustison commented 1 year ago

In both cases, the voxel size is 1 and I thought that was enough for correct visualization.

That might be the case but that's not in your description and it's certainly not best practice as ANTs tools utilize the geometric information in the header. I don't know how well-vetted ants.core.ants_image_io.dicom_read (I use dcm2niix) but please use something so that information is not lost in the processing. Also, if you're just starting to use ANTs, please use ITK-SNAP to show results as we know the visualization is compatible with ANTs.

Once you've done that, come back and we'll be in a shared knowledge space for fixing any issues.

Volodimirich commented 1 year ago

Solved the problem by changing the matrix of the affine transformation, closing the issue