Closed neurorishika closed 7 months ago
I would check out antsMultivariateTemplateConstruction.sh, (no 2), which uses ANTS - will be most similar to old BTP script
And I would email the authors of the article and ask them what they did.
@ntustison the paper came out a while ago and they just used btp.sh a while ago.
It looks like the paper came out Feb. of last year. It would seem to me to still be worth reaching out versus us just guessing at what they did.
@ntustison, they use buildtemplateparallel.sh
. I'm not guessing, its in their supplementary material and their method has been the same since their earlier paper.
Okay, that wasn't clear from your original post. So are those command line arguments that you posted above the exact ones that they used?
@ntustison I thought i linked the earlier paper (lol) that's why I said it came out a while ago.
@cookpa I'm trying out antsMultivariateTemplateConstruction.sh
, but I am unsure how to affine only initial templates with that. There doesn't seem to be an affine-only version for transforms? The only options I found were:
-s: Type of similarity metric used for nonlinear registration (affine is always MI). Default = CC.
Options are case sensitive.
CC : Cross-correlation
MI : Mutual information
MSQ : Mean squared differences
PR : CC after subtraction of local mean from the image (deprecated)
-t: Type of transformation model used for nonlinear registration. Options are case sensitive.
GR : Greedy SyN (default for scalar data)
GR_Constrained : Greedy SyN with regularization on the total deformation (default for time series)
EL : Elastic
EX : Exponential
DD : Greedy exponential, diffemorphic-demons-style optimization
SY : LDDMM-style SyN with symmetric time-dependent gradient estimation
LDDMM : Like SY, but with asymmetric time-dependent gradient estimation
S2 : Like SY, but with no time-dependent gradient estimation
It does mention there MI is default for Affine, but what is the transform model should I specify?
@ntustison yeah, sorry bout that! their parameters are essentially the same except:
Essentially our parameters were slightly optimized for our data, we just wanted to transition to a better maintained script than btp.sh since we were getting a bug on the affine only registration.
For an (almost) affine-only template, I used to do -t GR
and -m 1x0x0
@cookpa is there a way to make it affine only? the way we can with antsMultivariateTemplateConstruction2.sh
?
It's been a long time since I've used ANTS. I don't think it allows affine only (you could try 0x0x0 iterations and see).
You could use the updated script for affine-only initialization, and then pass the output to the older script with -z
.
@cookpa 0x0x0 doesnt generate a warp.nii.gz and gives an error. When you used to use 1x0x0 which transformation model did you use? GR or RA?
I used GR
@cookpa seems to get rid of the error. It would be nice to have an RA-only transform possibility, but for now, this works.
I did two runs one with btp.sh
and one run with mtc.sh
, and then made a composite with them, there were minor differences in the artifacts but overall they look almost the same.
# Setup the number of threads to be used
THREADS_AFFINE=40
THREADS_SYN=40
# Setup the number of iterations to be used
ITERATIONS_AFFINE=4
ITERATIONS_SYN=6
# Setup a identifier (with wildcards) for the images to be registered (e.g. synA647_*.nii.gz)
ID=brains_*.nrrd
# BTP version
./ANTs/Scripts/buildtemplateparallel.sh -d 3 -i $ITERATIONS_AFFINE -m 1x0x0 -t GR -s MI -r 1 -c 2 -j $THREADS_AFFINE -o affine_ $ID > >(tee -a stdout-affine-template.txt) 2> >(tee -a stderr-affine-template.txt >&2)
./ANTs/Scripts/buildtemplateparallel.sh -d 3 -i $ITERATIONS_SYN -m 30x90x20x8 -t GR -s CC -z affine_template.nii.gz -c 2 -j $THREADS_SYN -o complete_ $ID > >(tee -a stdout-syn-template.txt) 2> >(tee -a stderr-syn-template.txt >&2)
# MTC version
./ANTs/Scripts/antsMultivariateTemplateConstruction.sh -d 3 -n 1 -c 2 -j $THREADS_AFFINE -i $ITERATIONS_AFFINE -k 1 -w 1 -m 1x0x0 -t GR -s MI -r 1 -o affine_ $ID > >(tee -a stdout-affine-template.txt) 2> >(tee -a stderr-affine-template.txt >&2)
./ANTs/Scripts/antsMultivariateTemplateConstruction.sh -d 3 -n 1 -c 2 -j $THREADS_SYN -i $ITERATIONS_SYN -k 1 -w 1 -m 30x90x20x8 -t GR -s CC -r 0 -o complete_ -z affine_template0.nii.gz $ID > >(tee -a stdout-syn-template.txt) 2> >(tee -a stderr-syn-template.txt >&2)
This seems to be working mostly equivalently! Ill be closing the issue. Thanks @ntustison @cookpa
I have been trying to replicate the results from this paper that used ANTs to build a template brain using
buildtemplateparallel.sh
. I was able to get the code to work somewhat and give us the result we wanted using the following commands:./ANTs/Scripts/buildtemplateparallel.sh -d 3 -i 2 -m 1x0x0 -t RA -s CC -c 2 -j 40 -o affine_ brains* > >(tee -a stdout-affine-template.txt) 2> >(tee -a stderr-affine-template.txt >&2)
followed by
./ANTs/Scripts/buildtemplateparallel.sh -d 3 -i 4 -m 30x90x20x8 -t GR -s CC -z affine_template.nii.gz -c 2 -j 40 -o complete_ brains* > >(tee -a stdout-syn-template.txt) 2> >(tee -a stderr-syn-template.txt >&2)
But then I noticed the segmentation fault described in https://github.com/ANTsX/ANTs/issues/791. See below:
From https://github.com/ANTsX/ANTs/issues/791, I learned that
buildtemplateparallel.sh
is quasi-deprecated? So I shifted to usingantsMultivariateTemplateConstruction2.sh
, this is what I figured would work:./ANTs/Scripts/antsMultivariateTemplateConstruction2.sh -d 3 -A 2 -b 1 -c 2 -j 40 -i 2 -k 1 -f 4x2x1 -s 2x1x0vox -q 1x0x0 -t Affine -m CC -r 1 -o affine_ $ID > >(tee -a stdout-affine-template.txt) 2> >(tee -a stderr-affine-template.txt >&2)
followed by
./ANTs/Scripts/antsMultivariateTemplateConstruction2.sh -d 3 -b 1 -c 2 -j 40 -i 4-k 1 -f 8x4x2x1 -s 4x2x1x0vox -q 30x90x20x8 -t SyN -m CC -r 0 -o complete_ -z affine_template0.nii.gz $ID > >(tee -a stdout-syn-template.txt) 2> >(tee -a stderr-syn-template.txt >&2)
But when I run it, while there are no major errors, the results are a little different looking, especially the individual brains warped to the template. Is there a way to make the calls more equivalent?