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

AHEAD template corregistration #86

Open
Shashank-Vijayaprasadh opened this issue Mar 26, 2024 · 4 comments
Open

AHEAD template corregistration #86

Shashank-Vijayaprasadh opened this issue Mar 26, 2024 · 4 comments

Comments

@Shashank-Vijayaprasadh
Copy link

Shashank-Vijayaprasadh commented Mar 26, 2024

Dear Kwok,
After running SEPIA for the participants, now I want to corregister the subject Chimap to AHEAD template. So, I used the SEPIA GUI for this but the problem is, it is very slow. I have used the latest version of SEPIA 1.2.2.5. It has been 10 hours of running it in MATLAB, but it is still not finished. Is there something that should be changed in the option to make it run faster? Would be great to know how to solve this!

PS: I have attached some images of the config I used along with some command line steps that came as it was getting executed
sepia ahead config_1pp
AHEAD_template fitting
AHEAD_template fitting_1
AHEAD_template fitting2

@kschan0214
Copy link
Owner

Dear Shashank,

Just want to clarify: is that the processing time of running the segmentation on the DCCN cluster using 1 core only? The segmentation is based on non-linear registration which is generally computationally intensive. The use of the AHEAD atlas could be even slower due to the high spatial resolution (0.5x0.5x0.5 mm iso) of the atlas. I have some ideas on how to speed up the process but haven't had time to implement them yet.

If you are running the analysis on the DCCM cluster, there are a few tricks to speed up the process depending on the size of your cohort and how familiar you are with image registration. Here are some of my suggestions:

  1. Run the analysis with multiple cores
    ANTs supports multithread processing so you can speed up the process by running the script on a multi-core session. You can check https://hpc.dccn.nl/docs/cluster_howto/compute_torque.html#specifying-resource-requirement to see how to request multiple cores in one session.

  2. Run multiple subjects in parallel
    One thing I usually do is to create a shell script to automatically create Matlab processing scripts for multiple subjects and submit the jobs to the cluster simultaneously so that you don't need to wait for one subject at a time. You might still need to be mindful about the computational resource available though (e.g. CPU and Matlab license availability)

  3. Create group templates and use them for segmentation instead
    Another strategy I used is to first register all subjects into the same space (e.g. MNI 1mm), and create a T1w, Chimp, GRE magnitude group template by averaging all subjects together. Once the templates are created, you can use them for AHEAD atlas segmentation like what you do on a single subject. The advantage is that you only have one very expensive registration remains (AHEAD-group template registration), which you can speed up using Suggestion#1. The drawback is that there might be some steps you need to perform outside of SEPIA.

How many datasets do you have in your study in total?

Best,

Kwok

@Shashank-Vijayaprasadh
Copy link
Author

Dear Kwok,
Thank you for your suggestions! I am completely new to image registrations but I am very interested in learning them. I have made a script which can submit multiple jobs to the cluster for the participants. I have 108 participants for who I want to use the registration. But the only thing is that I want to bring it back to the subject space where I want to fit a VTA template which I have in the AHEAD atlas space (which I want to do a bit later) so that it is more personalized.
sepia_ahead_jobcommand

This is the command I used to submit it to cluster which I have adapted from the SEPIA command used to submit to cluster.
I was also keen on seeing if a group template could be developed, but the VTA template is already in the AHEAD space so, I was thinking maybe I would lose some voxels by doing so.
But after reading your suggestion, if its possible to warp the VTA template from the AHEAD space to group template space without losing much precision and if it will speed up the process, I would be happy to give it a try.

Please let me know what you think!

Much thanks,
Shashank

@Shashank-Vijayaprasadh
Copy link
Author

Shashank-Vijayaprasadh commented Apr 22, 2024 via email

@kschan0214
Copy link
Owner

Hi Shashank

Sorry for the late reply. I cannot see the image but I guess the process slow down during SyN, is that the case?

Reducing the number of iterations may or may not speed up the process, depending on how many iterations needed for the cost function to converge. In my experience, each step often takes 50-100 iterations to converge (convergence <1e-6). Current maximum allowed iterations are 500 (4x subsampled), 500 (2x subsampled), and 250 (full resolution). Unless these numbers are reduced to, say <50, it won’t speed up the registration process.

Another way is to set a larger convergence value (say 1e-5), i.e.,

--convergence [500x500x250,1e-5,10] \

This might reduce the number of iterations by at least ~20-30 on each step. It might still be ok for your application because the optimisation cost comes mostly from the cortex (difficult to match on volumetric data), and you are only interested in subcortical nuclei of the AHEAD atlas. You can overlay the atlas labels on the registered image to check the registration quality.

Alternatively, you can also try using a mask focusing on the registration on the subcortical nuclei (which is my idea to speed up the registration). You can generate a dilated mask based on the AHEAD labels to include all nuclei and some white matter tissue (let’s called this mask_AHEAD.nii.gz). Then you can incorporate this mask to the script as

antsRegistration \
        --dimensionality 3 --float 0 \
        --output [${t1_2_atlas_vol},${t1_2_atlas_template_nii}] \
        --interpolation Linear \
        --winsorize-image-intensities [0.005,0.995] \
        --use-histogram-matching 0 \
        --initial-moving-transform [${ref_vol},${in_vol},1] \
        --transform Rigid[0.1] \
        --metric MI[${ref_vol},${in_vol},1,32,Regular,0.1] \
        --convergence [1000x500x250x100,1e-6,10] \
        --shrink-factors 4x3x2x1 \
        --smoothing-sigmas 3x2x1x0vox \
        --transform Affine[0.1] \
        --metric MI[${ref_vol},${in_vol},1,32,Regular,0.1] \
        --convergence [500x250,1e-6,10] \
        --shrink-factors 2x1 \
        --smoothing-sigmas 1x0vox \
        --transform SyN[0.1,3,0] \
        --metric CC[${ref_vol},${in_vol},1,2] \
        --convergence [500x500x250,1e-6,10] \
        --shrink-factors 4x2x1 \
        --smoothing-sigmas 2x1x0vox \
        --x mask_AHEAD.nii.gz \
        --verbose 1 

I think this should speed up the process quite a lot but I haven't had the chance to test this yet.

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

2 participants