ANTsX / ANTs

Advanced Normalization Tools (ANTs)
Apache License 2.0
1.18k stars 381 forks source link

antsAtroposN4.sh needs registered prior maps? #1096

Closed dbrennan44 closed 3 years ago

dbrennan44 commented 3 years ago

Describe the problem ITK failure on antsAtroposN4.sh:

Description: itk::ERROR: N4BiasFieldCorrectionImageFilter(0x2df2770): Inputs do not occupy the same physical space! InputImage Origin: [1.0000000e+00, 2.9250000e+02, -1.0000000e+00], InputImageMaskImage Origin: [9.1966103e+01, 8.0550140e+01, -5.7974781e+01]

Command run:

antsAtroposN4.sh -d 3 -a 0007_t1_mpr_AX_MPRAGE.nii -x skullstrip_BrainExtractionMask.nii.gz -p ../../../MICCAI2012-Multi-Atlas-Challenge-Data/Priors2/priors%d.nii.gz -c 3 -y 2 -y 3 -w 0.25 -o /data/dbrennan/raw/c001_s1/STRUC/output_test`

where "skullstrip...Mask.nii.gz" was created with antsBrainExtraction.sh, and did not have an issue with physical space.

I've just rebuilt ANTs from scratch so latest ITK etc shouldn't be an issue.

Does antsAtroposN4.sh need co-registered images?

ntustison commented 3 years ago

The priors need to be pre-aligned to the target image.

dbrennan44 commented 3 years ago

Okay, thanks. I need the GM/WM probability maps in subject-space, so:

it doesn't appear antsBrainExtraction needs pre-aligned priors. Is there a way to utilize a transformation matrix from this step to not have to co-register again? Another better way of approaching this?

Thanks in advance.

ntustison commented 3 years ago
dbrennan44 commented 3 years ago

excellent, this is really helpful. I think I will try antsCorticalThickness.sh since that seems well encapsulated.

just for my own interest, is the deep learning approach just an approximation of the current registration/segmentation algorithms, or something new altogether?

Thanks again, looking forward to reading the paper

ntustison commented 3 years ago

Just a deep learning analog to what we already have---simply to see what kind of improvement gains we could see in terms of accuracy and speed.

dbrennan44 commented 3 years ago

a weird quirk, but not tragic of course, is that the stages must be fed in reverse to antsCorticalThickness.sh ; e.g.:

antsCorticalThickness.sh -d 3 -a ${sub_dir}/STRUC/000?_t1_mpr_AX_MPRAGE.nii \ -e ${pdir}/T_template0.nii.gz \ -m ${pdir}/T_template0_BrainCerebellumProbabilityMask.nii.gz \ -y 3 \ -y 2 \ -y 1 \ -z 1 \ -x skullstrip_BrainExtractionMask.nii.gz \ -p ${pdir}/Priors2/priors%d.nii.gz \ -c 3 -w 0.25 -o ${sub_dir}/STRUC/output

ntustison commented 3 years ago

Here's an example of usage.

dbrennan44 commented 3 years ago

I see, I didn't realize we had to loop over steps. Thanks!

JinDJsuper commented 2 months ago

The priors need to be pre-aligned to the target image.

hello,i also have met the same problem,which was“ Inputs do not occupy the same physical space! ”.

i have a question that how to do "The priors need to be pre-aligned to the target image" , to use antsRegistrationSyn.sh ?

is this antsRegistrationSyNQuick.sh -d 3 -f template.nii.gz -m prior.nii.gz -n 8 -t s -o prior_warp_ ?

When using ANTs for registration, relying solely on the gray matter probability map usually does not result in good registration. Issues such as the misidentification of white matter and gray matter may occur.

and other question , Is it necessary to have prior1-4, including the fourth deep cortical probability map, for antsCorticalThickness.sh? I am working with animal MRI images and do not have the fourth deep cortical probability map.

Thanks in advance

cookpa commented 2 months ago

is this antsRegistrationSyNQuick.sh -d 3 -f template.nii.gz -m prior.nii.gz -n 8 -t s -o priorwarp ?

Your priors should be aligned to template.nii.gz already. If you want to segment a target t1w.nii.gz, then

antsRegistrationSyNQuick.sh -d 3 -f template.nii.gz -m t1w.nii.gz -n 8 -t s -o t1w_to_template_
for i in 1 2 3 4; do 
  antsApplyTransforms -d 3 -i prior${i}.nii.gz -t [ t1w_to_template_0GenericAffine.mat, 1 ] -t t1w_to_template_1InverseWarp.nii.gz -r t1w.nii.gz -o t1w_prior${i}.nii.gz` ]
done

Is it necessary to have prior1-4, including the fourth deep cortical probability map, for antsCorticalThickness.sh? I am working with animal MRI images and do not have the fourth deep cortical probability map.

Yes, it is required for that script. However, if you do a 3-class segmentation, you can call the thickness program KellyKapowski directly without the fourth class.

JinDJsuper commented 2 months ago

is this antsRegistrationSyNQuick.sh -d 3 -f template.nii.gz -m prior.nii.gz -n 8 -t s -o priorwarp ?

Your priors should be aligned to template.nii.gz already. If you want to segment a target t1w.nii.gz, then

antsRegistrationSyNQuick.sh -d 3 -f template.nii.gz -m t1w.nii.gz -n 8 -t s -o t1w_to_template_
for i in 1 2 3 4; do 
  antsApplyTransforms -d 3 -i prior${i}.nii.gz -t [ t1w_to_template_0GenericAffine.mat, 1 ] -t t1w_to_template_1InverseWarp.nii.gz -r t1w.nii.gz -o t1w_prior${i}.nii.gz` ]
done

Is it necessary to have prior1-4, including the fourth deep cortical probability map, for antsCorticalThickness.sh? I am working with animal MRI images and do not have the fourth deep cortical probability map.

Yes, it is required for that script. However, if you do a 3-class segmentation, you can call the thickness program KellyKapowski directly without the fourth class. thank you ,i get this code and method ,and i will try to do it

Thanks in advance