Qsiprep AMICO NODDI and "space-T1"

Hi Everyone!

Our lab is curious about the definition of “space-T1” in qsiprep’s recon pipeline using amico noddi. We are using the pipeline successfully with some multi-shell dwi and the following code:

qsiprep-docker /path-to-data /path-to-output/folder
-w /work/folder
–fs-license-file ~/path-to-file/license.txt
–pepolar-method TOPUP
–participant_label sub-XX
–output-resolution 1
–recon_input /data/path-to-qsiprep
–recon_spec amico_noddi
–nthreads=30

Our issue is that output (i.e. sub-02_acq-b0b1000b2000_dir-AP_space-T1w_desc-preproc_desc-OD_NODDI.nii.gz) doesn’t align with our T1s, and we’ve been using FSL’s epi_reg to align the output.

My first question: qsiprep assigns the T1 label for “space”, but does it mean it should be aligned to the T1, or am I interpreting that label incorrectly?

Second question: is there an easy transform using ANTs and qsiprep outputs that would allow us to bypass FSL? Which qsiprep outputs would I point to?

Any advice is appreciated!

Hi @imolax,

It is aligned to the qsiprep preprocessedT1 which is rotated to AC-PC orientation.

Yes! This should be in the qsiprep anatomical output folder in recent versions. E.g., anat/sub-01_from-T1wNative_to-T1wACPC_mode-image_xfm. ANTS is used in most qsiprep registration workflows.

Best,
Steven

1 Like

Hi @Steven , by coincidence I was working on this exact same issue today, trying to use anat/sub-01_from-T1wNative_to-T1wACPC_mode-image_xfm.mat to transform my raw T1w image from native space to ACPC space with ANTs but with no success so far.

I was using outputs of QSIPREP version 0.20.0

I tried this command:
antsApplyTransforms --float --default-value 0 --input sub-01_T1w.nii.gz -d 3 -e 3 --interpolation LanczosWindowedSinc --output new_to_ACPC.nii.gz --reference-image sub-01_T1w.nii.gz -t sub-01_from-T1wNative_to-T1wACPC_mode-image_xfm.mat

but the resulting image is not align with the image derivatives/qsiprep/sub-01/anat/sub-01_desc-preproc_T1w.nii.gz which is in the ACPC space.

Original image:

Preprocessed image in ACPC space:

Image resulting from my ANTs command:

Am I doing something wrong or is there something missing (deobliquing, moving to LPS…)?
(I also tried the opposite transform sub-01_from-T1wACPC_to-T1wNative_mode-image_xfm.mat but it is not the solution either)

Thanks!

Julien

Hi @jsein,

What if you change the reference image to the preprocessed T1?

Best,
Steven

Thank you @Steven for your quick answer!

I did try this, and also the template image and the _space-T1w_dwiref.nii.gz image as reference for antsApplyTransforms but it doesn’t change the output image orientation: I think the reference image in this command tells just the resolution and the bounding box of the output image…

Hmm, that’s odd the xfm isn’t working as is, I’ll look into that. But otherwise you should be able to calculate a rigid transform between your two T1s and use that as the native-to-acpc xfm.

Best,
Steven

We only recently started storing this transform in the derivatives. The main reason for not storing it was that the transform alone isn’t always enough to get the native T1w aligned to the T1w-ACPC. Before alignment, the raw T1w is deobliqued using just the affine and then reoriented to LPS+. This ensures that the image doesn’t lose any precision and goes through the various ITK programs without causing any errors. If your raw T1w isn’t oblique the transforms should work to go from raw to T1w-ACPC.

2 Likes

Thank you so much for this!

The output is SO CLOSE - just slightly tilted (in the AC-PC plane?) as compared to the alignment we get using epi_reg. Just to clarify, we are trying to get the ODI back into the native T1 space for some surface mapping.

I used a skull stripped brain and the following:

docker run --rm 
 -v /data/:/data 
antsx/ants antsApplyTransforms 
--dimensionality 3 \
--input-image-type 0 \
--input /data/qsirecon/sub/dwi/odi-file \
--default-value 0 \
--float 1 \
--interpolation LanczosWindowedSinc \ 
--output /data/out/file \
--reference-image /data/hd-bet/brain \
--transform /data/qsiprep/sub/anat/sub_from-T1wACPC_to-T1wNative_mode-image_xfm.mat

I’ve also tried using the full T1 (not skull stripped) as the reference image. It’s still slightly misaligned.
Please excuse my ignorance on this, but how can I tell if my raw T1 is oblique and causing issues?

Any ideas are appreciated!!

Just for fun: an overlay with the original ODI, the T1 and the transformed ODI (slightly misaligned - you can see it when you play with the transparency).

Hi @imolax ,

To see if your data is oblique you can run the afni command 3dinfo:
3dinfo your_image.

For instance on an oblique image you would get:

Data Axes Tilt:  Oblique (13.135 deg. from plumb)
1 Like

As my data is natively oblique, the transforms sub-SUB_from-T1wACPC_to-T1wNative_mode-image_xfm.mat and sub-SUB_from-T1wNative_to-T1wACPC_mode-image_xfm.mat are not useful in a straightforward manner.

As suggested, what works is to compute the rigid transformation from the native space to the ACPC space with antsRegistration (or easier with antsRegistrationSyNQuick.sh):

antsRegistrationSyNQuick.sh -d 3 -m sub-SUB_ses-01_T1w_orig.nii.gz -f sub-JEU02_desc-preproc_T1w.nii.gz -t r -o native_to_ACPC_

This will produce 3 files:

  • native_to_ACPC_0GenericAffine.mat: rigid transformation from native T1w to T1w in ACPC space
  • native_to_ACPC_Warped.nii.gz: native T1w image wrapped into ACPC space
  • native_to_ACPC_InverseWarped.nii.gz: ACPC T1w wraped into T1w native space

If you want to transform an image from the native space to the T1w ACPC space you would just need to use antsapplyTransforms:
antsApplyTransforms -d 3 -i your_image_in_native_space.nii.gz -r sub-JEU02_desc-preproc_T1w.nii.gz -t native_to_ACPC_0GenericAffine.mat -o your_image_in_ACPC_space.nii.gz -n LanczosWindowedSinc

and if you want to do the inverse to project an image from ACPC space to the T1w native space, you could inverse the transform using [ name_of_transform , 1 ]:
antsApplyTransforms -d 3 -i your_image_in_ACPC_space.nii.gz -r sub-SUB_ses-01_T1w_orig.nii.gz -t [native_to_ACPC_0GenericAffine.mat,1] -o your_image_in_native_space.nii.gz -n LanczosWindowedSinc

The documentation about ANTs transforms is here.

2 Likes