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

Questions about buildtemplateparallel and antsMultivariateTemplateConstruction #806

Closed
Pamsin opened this issue Jul 19, 2019 · 10 comments
Closed

Comments

@Pamsin
Copy link

Pamsin commented Jul 19, 2019

Dear ANTS experts,

I am reading the codes buildtemplateparallel and antsMultivariateTemplateConstruction.

What I cannot understand is why it used four times "${templatename}warp.nii.gz" when warping each template by the resulting transforms in the function "shapeupdatetotemplate ".

The code is "${ANTSPATH}/WarpImageMultiTransform ${dim} ${template} ${template} -i ${templatename}Affine${afftype} ${templatename}warp.nii.gz ${templatename}warp.nii.gz ${templatename}warp.nii.gz ${templatename}warp.nii.gz -R ${template}".
(buildtemplateparallel: line 414; antsMultivariateTemplateConstruction: line 262)

According to me, to calculate the inverse transform, we just need to use the "-i *Affine.mat *InverseWarp.nii.gz". Is it right? Why did it use the "*warp.nii.gz" so many times here?

Could anyone explain it? Or recommend a reference for this algorithm?

Any suggestions would be much appreciated.

Thanks!

@cookpa
Copy link
Member

cookpa commented Jul 19, 2019

The template update warp field is scaled by 0.25 (by default, the user can reduce it) and then applied four times, so the resulting warp vector at some point will have similar magnitude to the original version, but it will be slightly regularized because of linear interpolation at each of the four steps.

I can't recall the original reference for doing this in template construction, but I think it might have been one of the SPM papers.

@ntustison
Copy link
Member

We're actually determining the transform which updates the template shape to shift it closer to the estimated true mean of the cohort. In order to minimize deviations from a diffeomorphic transform, an exponentiated approach is used whereby the average displacement field transform is first multiplied by the gradient step (< 1.0, default = 0.25) and composed with itself multiple times.

@Pamsin Pamsin closed this as completed Jul 20, 2019
@Pamsin Pamsin reopened this Jul 20, 2019
@Pamsin
Copy link
Author

Pamsin commented Jul 20, 2019

We're actually determining the transform which updates the template shape to shift it closer to the estimated true mean of the cohort. In order to minimize deviations from a diffeomorphic transform, an exponentiated approach is used whereby the average displacement field transform is first multiplied by the gradient step (< 1.0, default = 0.25) and composed with itself multiple times.

Thanks for the answer.
So, I think this four times warp is because of using the gradien step 0.25 (1/4)? Should I need to change the warp times when I use a different gradient step?
Another queston is why we use the file *warp.nii.gz (from subject to template) to calculate the template shift? This algorithm just calculated "the inverse field by the resulting average affine transform". Why don't it use *InverseWarp.nii.gz (from template to subject)?

Does it work if using "${ANTSPATH}/WarpImageMultiTransform ${dim} ${template} ${template} -i ${templatename}Affine${afftype} ${templatename}InverseWarp.nii.gz -R ${template}"."

@ntustison
Copy link
Member

So, I think this four times warp is because of using the gradien step 0.25 (1/4)?

No, it's simply a coincidence.

Should I need to change the warp times when I use a different gradient step?

No.

Another queston is why we use the file *warp.nii.gz (from subject to template) to calculate the template shift? This algorithm just calculated "the inverse field by the resulting average affine transform". Why don't it use *InverseWarp.nii.gz (from template to subject)?

The "inverse transform" applied during the shape updated sense is not the same in the sense of the total transform found between template and subject. It's much more complicated than that which is why your proposed use of the inverse transform wouldn't work. I'd recommend reading the paper, specifically section 2.2.2.

@Pamsin
Copy link
Author

Pamsin commented Jul 22, 2019

So, I think this four times warp is because of using the gradien step 0.25 (1/4)?

No, it's simply a coincidence.

Should I need to change the warp times when I use a different gradient step?

No.

Another queston is why we use the file *warp.nii.gz (from subject to template) to calculate the template shift? This algorithm just calculated "the inverse field by the resulting average affine transform". Why don't it use *InverseWarp.nii.gz (from template to subject)?

The "inverse transform" applied during the shape updated sense is not the same in the sense of the total transform found between template and subject. It's much more complicated than that which is why your proposed use of the inverse transform wouldn't work. I'd recommend reading the paper, specifically section 2.2.2.

Hi Nick,

I have read the paper but I still cannot figure out why we use the warp.mii.gz to cal the template shift.
However, it may not be important because I just need to use it.

There are three programmes "buildtemplateparallel, antsMultivariateTemplateConstruction and antsMultivariateTemplateConstruction". So the last question is what is the difference between them? Olny the TRANSFORMATIONTYPE? Which one I can choose to start with? All of them can reach the SyN.

Thanks a lot!

@Pamsin Pamsin closed this as completed Jul 22, 2019
@ntustison ntustison reopened this Jul 22, 2019
@ntustison
Copy link
Member

buildtemplateparallel.sh was one of the initial scripts to do template building. It's functionality was extended in antsMultivariateTemplateConstruction.sh, including multimodal templates. antsMultivariateTemplateConstruction2.sh simply replaces the use of the original ANTS program with the more recent antsRegistration tool. We recommend using either one of the latter two scripts.

@Pamsin
Copy link
Author

Pamsin commented Jul 24, 2019

buildtemplateparallel.sh was one of the initial scripts to do template building. It's functionality was extended in antsMultivariateTemplateConstruction.sh, including multimodal templates. antsMultivariateTemplateConstruction2.sh simply replaces the use of the original ANTS program with the more recent antsRegistration tool. We recommend using either one of the latter two scripts.

Hi Nick,

Sorry to bother you again.

I am trying to use antsMultivariateTemplateConstruction2.sh to generate a template for my data.
However, I cannot get a good a result. I mean that the image is very blurred in the border region where it couldn't distinguish the gray matter and the white matter. I put an image compared with the icbm template in the attached file.

Could you tell me where I can improve for the parameters of this program? Or other codes and methods I can try to get the template?

The code I used is as following:
antsMultivariateTemplateConstruction2.sh
-d 3
-o ${outputPath}/T_
-i 5
-g 0.25
-c 4
-f 8x4x2x1
-s 3x2x1x0
-q 100x70x50x10
-n 0
-r 1
-l 1
-m MI
-t SyN
${inputPath}/*.nii.gz

ComparedWithICBM

Thanks a lot!

@ntustison
Copy link
Member

Have you looked at these examples?

@Pamsin
Copy link
Author

Pamsin commented Jul 24, 2019

Have you looked at these examples?

Yes, but I just read the sh files to confirm the transformation and parameters.
I don't know which parameters I can change to improve the border region.

@ntustison
Copy link
Member

You should actually run them, especially BrainSlices, as they're relevant to your problem.

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

3 participants