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

Custom atlas in T1w space #283

Closed
Giuseppe1988 opened this issue Aug 4, 2021 · 5 comments
Closed

Custom atlas in T1w space #283

Giuseppe1988 opened this issue Aug 4, 2021 · 5 comments

Comments

@Giuseppe1988
Copy link

Dear qsiprep experts,
I am trying to obtain structural connectivity matrices for my dataset and I was thinking of using a custom brain parcellation that has been previously obtained with external software in the T1w space.
Is there a way to specify that the custom atlas is already in T1w space and the template-to-T1w transformation must not be applied?
Otherwise, I was thinking of applying the T1w-to-template transformation computed in the preprocessing stage to the custom atlas (with nearest neighbour interpolation) before feeding it to the reconstruction process. Any suggestions on how to efficiently implement this step? Could you please provide the exact command used by qsiprep to warp templates in the T1w space?

Thank you so much for your help,
Giuseppe

@Giuseppe1988 Giuseppe1988 changed the title Custom atlas in T1w Custom atlas in T1w space Aug 4, 2021
@Giuseppe1988
Copy link
Author

Dear experts,

to obtain what I need, I decided to bring the custom parcellation from the original T1w space to the T1w space used in qsiprep.
I applied the from-orig_to-T1w-mode_imake-xfm.txt transformation using antsApplyTransform and at first, I got the "no end of line detected" error.
After manually adding it, the transformation seems fine but the original image is actually aligned to the T1w_lps.nii file found in $WORK_DIR/qsiprep/single_subject*/anat_preproc_wf/anat_template_wf/t1_conform/mapflow/_t1_conform0 directory, and not to the desc-preproc_T1w.nii (the one written in the derivatives directory that defines the space in which dwi analyses are conducted).
Am I missing something?

How exactly the original T1w image is brought into the T1w-mode space used for subsequent analyses?

Thank you so much for your help!

@mattcieslak
Copy link
Collaborator

Hi @Giuseppe1988, you've found a bug or at least something that's not well documented. Does your data have multiple T1w images per subject? Those "mode" transforms are supposed to be register individual T1w scans to a subject's T1w template. This template image is then put into AC-PC alignment, which is what ultimately defines the T1w space where the DWI images are aligned. If there is only one image, then that "to mode" transform is an identity transform.

@Giuseppe1988
Copy link
Author

Dear @mattcieslak, thank you for your answer.
In my dataset I have only one T1w per subject, but I think I found the issue here (and probably I wasn't so clear in explaining the issue). The "from-orig_to-T1w-mode_image-xfm.txt" stored in the derivatives just brings the original T1w image in LPS orientation, while the rigid transformation putting it in AC-PC alignment remains in the WORK_DIR in /anat_preproc/skullstrip/rigid_acpc_align (maybe it could be useful to retain this in the derivatives so that the process of going from original T1w space to qsiprep-T1w space can always be reconstructed). Combining the two transformations with antsApplyTransform I was able to correctly map the original T1w space to the one used by qsiprep.

Regarding my original question (using custom atlases in subject space for the reconstruction), I am trying to do so by creating custom reconstruction and atlas_config .json files using the original parcellation warped into the template space as input. Is there any simpler solution to do that?

@mattcieslak
Copy link
Collaborator

To add a new atlas you'll need to make sure its aligned with this image in world coordinates. I recommend using ITK SNAP to check because it interprets headers the same way ANTs will. You also have to edit the atlas_config.json to ensure the metadata is there.

I'm working on overhauling how the recon workflows ingress data and custom atlases will be part of this. Unfortunately for now the only way to add a custom T1w atlas is if it's already in MNI space. Since you have some experience looking through the working directories, you could copy one of the calc_connectivity directories used with a built-in atlas and substitute your files in it.

A less accurate way would be to use the T1w-MNI transform to get your subject's atlas into MNI and then add this to the atlas_config.json. But this will cost you two interpolations, which would be sad for an atlas.

@Giuseppe1988
Copy link
Author

Ok thanks. The files are correctly oriented.

For now I think the simplest strategy is just to bring the custom atlas in the qsiprep-T1w space (applying the rigid transform computed in the preprocessing stage) and use the recon output (.tck and weights) to build the connectome outside of qsiprep.

Looking forward for new advances in thi wondeful project!

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