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

problem with 3d registration #496

Open esther1262 opened 1 year ago

esther1262 commented 1 year ago

Hi, I try to register two 3d labelmaps. The fixed one is a binary mask, dim 256x256x16. The moving one has 27 regions (values 0,1,...27), dim 256x512x256. Ultimately, I am only interested in a few regions.

img_mv = ants.image_read('results/templateLabels_27regions_256slices.nii.gz', dimension=3)
img_fx = ants.image_read('1.nii.gz', dimension=3) 

I think the pixel data are imported as float. Even if I specifed pixeltype='unsigned int' the registration results didnt improve.

mytx = ants.registration(fixed=img_fx , moving=img_mv, type_to_transform='BOLDAffine')
warped_moving = mytx['warpedmovout'] 

I tried all the possible choices for type_to_transform. None can improve the results.

img_fx.plot(axis=2, slices=11, overlay=warped_moving, title='After Registration (slice 11)', overlay_alpha=0.7)

image

This is one of the slices that has the worse result. Majority are okay, in terms of shape. Since I have a binary map, it's difficult to register all the regions. But I want the shape to be matched at least. This one has completely different shape.

Also,
moving labelmap image after registration, so much noise image

Anyone knows how to fix it? Thanks

cookpa commented 1 year ago

The correct arg is type_of_transform

Registering a binary mask to a label image is an unusual use case. There's very little information in a binary mask except at the edges. I would rethink this and reformulate the registration question if possible.

esther1262 commented 1 year ago

The correct arg is type_of_transform

Registering a binary mask to a label image is an unusual use case. There's very little information in a binary mask except at the edges. I would rethink this and reformulate the registration question if possible.

typo, but they didnt make a difference

i have a mouse head mri, I want to register the labelmap template to the brain area. Thats why I created a binary map for the brain only, registration between a head and a brain image is even worse.

cookpa commented 1 year ago

typo, but they didnt make a difference

If there's a typo in the function call, the argument is ignored. The default will be used.

i have a mouse head mri, I want to register the labelmap template to the brain area. Thats why I created a binary map for the brain only, registration between a head and a brain image is even worse.

I agree you shouldnt' register head to brain. If you have a head + brain mask, you can create a brain image and register brain to brain, unless I'm missing something?

The noisy appearance in the output is from linear interpolation of the labels. You can use ants.apply_transforms with interpolator= genericLabel to avoid this.

esther1262 commented 1 year ago

@cookpa we prefer not to change the pixel in brain images. we want to do it from the masks.