ANTsX / ANTs

Advanced Normalization Tools (ANTs)
Apache License 2.0
1.19k stars 380 forks source link

EPI slab to T1 rigid registration fails even after troubleshooting #1110

Closed ccn30 closed 3 years ago

ccn30 commented 3 years ago

Describe the problem

Thank you for the wiki/your efforts to make ANTs as user friendly as possible! I'm trying to coregister EPI slabs and T1W structurals within subject (EPIs are mean image of first functional run 1.5x1.5x1 voxels and T1W are brain extracted 0.7iso, all data 7T) but 15/18 subjects keep failing (no errors, just non aligned results). I've tried proposed solutions in (slightly) similar issues e.g. #400 or #908 but no success. I'd very grateful for any advice on next steps in troubleshooting.

I have tried:

before I spend more time trying different possibilities, do you think:

Thank you!

To Reproduce

I'm calling the command verbatim from https://github.com/ntustison/PartialSlabEpiT1ImageRegistration/blob/master/commandRigid.sh ${movingImage}=T1.nii ${fixedImage}=epi.nii ${maskImage}=mask.nii these are attached examples of subject that fails epi.nii.tar.gz mask.nii.tar.gz t1.nii.tar.gz

System information (please complete the following information) Many issues are specific to a particular system. Please include all information about your computing environment.

ANTs version information

ntustison commented 3 years ago

Try this modification:

#! /bin/sh

baseDirectory=${PWD}

fixedImage=${baseDirectory}/epi.nii
fixedImageN4=${baseDirectory}/epiN4.nii
movingImage=${baseDirectory}/t1.nii
maskImage=${baseDirectory}/mask.nii

# make mask of slab image

N4BiasFieldCorrection -d 3 -i $fixedImage -o $fixedImageN4 -b [100] -c [200x200x200x200,0] -v 1 -s 4

ThresholdImage 3 ${fixedImageN4} ${maskImage} 100 Inf

# Register T1 to EPI slab with mask
outputPrefix=${baseDirectory}/epiSlabxT1

antsRegistration --verbose 1 \
                 --dimensionality 3 \
                 --float 0 \
                 --interpolation Linear \
                 --use-histogram-matching 0 \
                 --winsorize-image-intensities [0.005,0.995] \
                 --output [${outputPrefix},${outputPrefix}Warped.nii.gz,${outputPrefix}InverseWarped.nii.gz] \
                 --initial-moving-transform [${fixedImageN4},${movingImage},1] \
                 --transform translation[0.2] \
                   --metric MI[${fixedImageN4},${movingImage},1,32,Random,0.5] \
                   --convergence [400x200x100,1e-6,10] \
                   --shrink-factors 8x4x2 \
                   --smoothing-sigmas 0x0x0vox \
                   --masks [${maskImageN4},NULL] \
                 --transform Rigid[0.2] \
                   --metric MI[${fixedImageN4},${movingImage},1,32,Random,0.5] \
                   --convergence [500x500x250x50,1e-6,10] \
                   --shrink-factors 6x4x2x1 \
                   --smoothing-sigmas 2x1x0x0vox \
                   --masks [${maskImage},NULL]
ccn30 commented 3 years ago

Thanks for the fast response! Alas these changes seem to make the problem worse - previously successful subjects now fail as well as those that previously failed. Attached is a screenshot which is representative of most of the registrations fail - the T1W is shifted down and sometimes over rotated. I get similar results using the registration tool in ITKsnap (rigid, MI). Unfortunately I don't have a whole brain EPI to use as an intermediate. Screenshot 2020-11-05 at 19 27 41

ntustison commented 3 years ago

I don't know how you ran it. The results I get look pretty good to me.

Screen Shot 2020-11-05 at 11 42 30 AM
ccn30 commented 3 years ago

They do look good, thank you! I think it may be a version issue - are you running 2.3.4? I tried to get my IT dept to compile 2.3.4, but I don't think they installed it (antsRegistration --version prints 0.0.0.0 and there are no bin/ or lib/ dirs) so I'm stuck on 2.1.0. I'll get them to fix it and try again.

ntustison commented 3 years ago

Built from the latest GitHub repo but I don't know why it would be a version issue as antsRegistration has been stable for quite some time. I would make sure that you didn't make a mistake anywhere in running what I wrote above.

ccn30 commented 3 years ago

You're right, I forgot to change masking threshold down to 100. But didn't solve the issue unfortunately. I copied the above script verbatim, into a new dir with same images I gave you, loaded ANTs/2.3.4, and it still didn't work. Output of command and the warped images attached (can't attach inverse as file too large in GitHub file selector). Does this output look successful on your end? Could it be my ITKsnap? epiSlabxT1Warped.nii.gz output.txt

ntustison commented 3 years ago

Looks correct on my end.

ccn30 commented 3 years ago

I'll move over to the ITKsnap forum in that case. Thanks for all your help!