Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cook my template for priors #1195

Closed
andmark110 opened this issue May 15, 2021 · 17 comments
Closed

Cook my template for priors #1195

andmark110 opened this issue May 15, 2021 · 17 comments

Comments

@andmark110
Copy link

andmark110 commented May 15, 2021

Dear ANTs team,

I get a bad template priors from antsMultivariateTemplateConstruction2.sh as follow:
prior1.nii.gz
prior2.nii.gz
prior3.nii.gz
prior4.nii.gz
prior5.nii.gz
prior6.nii.gz

This is my template:
T_template0.nii.gz

This is my Cooktemplate command:

Cookmytemplate.txt

I can not solve it, please help me. Thank you.

@ntustison
Copy link
Member

Priors look pretty good to me. Why do you believe they are "bad"?

@andmark110
Copy link
Author

Template priors have some defects except prior1.
Such as:
Screen Shot 2021-05-16 at 10 48 40 AM

I thought these defects might be uncorrected, right?

@ntustison
Copy link
Member

Use ITK-SNAP to view the results. That's not what I see.

@andmark110
Copy link
Author

I have viewed the prior6 in ITK-SNAP as follow:
image

There are still some defects in prior6.

@ntustison
Copy link
Member

Again, that's not what I see in your prior6 file.

Screen Shot 2021-05-15 at 8 34 32 PM

@andmark110
Copy link
Author

I notice you view the priors6 file, but I viewed the prior6(not priors6). Might be the issue with the file upload?
I reupload them.
prior1.nii.gz
prior2.nii.gz
prior3.nii.gz
prior4.nii.gz
prior5.nii.gz
prior6.nii.gz

Thank you for viewing them again.

@ntustison
Copy link
Member

Okay, now I can see it.

Please prepare a complete example. Specifically, I want to be able to download a single folder with all the necessary input data. Also, please include just the command call. I want to be able to simply cd to the downloaded directory and run a single command to try to reproduce your output data.

@andmark110
Copy link
Author

Thank you. Can you give me an email? The input data was a bit big.

Actually, I have uploaded my new_template and the other files come from 'MICCAI2012-Multi-Atlas-Challenge-Data'.
new_template.nii.gz

If that is ok, you may need to modify my command (Cookmytemplate.txt) and try to run it.

@ntustison
Copy link
Member

You can find my email in my profile. And, again, please put together a sufficiently complete example that I can just navigate to the downloaded directory and run a single command without having to modify anything.

@andmark110
Copy link
Author

andmark110 commented May 18, 2021 via email

@ntustison
Copy link
Member

Thanks for this. Quick question, though---is there a reason why you just didn't call the ANTs script antsCookTemplatePriors.sh?

@andmark110
Copy link
Author

I did my 'Cooktemplateprior.sh' by referring to this command. In addition, I also have tried this script and the issue still existed. I think it might be caused by incorrect input data? Thanks for your help.

@ntustison
Copy link
Member

The problem is not the input data but rather numerical imprecision and this line. In your case, the max for these prior images is just greater than 1 so this line is removing those voxels. If you replace in your code (line 207) this

${ANTSPATH}ThresholdImage 3 $prior $tmp 0 1 1 0

with

${ANTSPATH}ThresholdImage 3 $prior $tmp 0 1 1.1 0

hen it should work.

@cookpa
Copy link
Member

cookpa commented May 19, 2021

This was also a problem in antsCorticalThickness.sh some time ago, I think @jeffduda discovered it. I think it was caused by the new implementation of Gaussian smoothing. The recursive algorithm can sometimes map data in the range of [0,1] to values just outside those ranges. Spline interpolation of warped priors can cause the same issue, but I don't think that's used in our scripts.

I fixed it with ImageMath's WindowImage, eg

${ANTSPATH}/ImageMath ${DIMENSION} $PRIOR WindowImage $PRIOR 0 1 0 1

I will make a PR to do the same for the cooking script.

@ntustison
Copy link
Member

Thanks @cookpa

@cookpa
Copy link
Member

cookpa commented May 19, 2021

#1197

@gdevenyi
Copy link
Contributor

gdevenyi commented May 19, 2021

I fixed it with ImageMath's WindowImage, eg

Oh wow, I missed this existing, this will simplify a number of things I write with the ThresholdImage/ImageMath multiply right now.

@cookpa cookpa closed this as completed Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants