i tried to transform the qsiprep dwi output from ACPC to T1 space with the following command:
antsApplyTransforms -d 3 -e 3 \
-i dwi/sub-00300_space-ACPC_desc-preproc_dwi.nii.gz \
-r dwi/sub-00300_space-ACPC_desc-preproc_dwi.nii.gz \
-t anat/sub-00300_from-ACPC_to-anat_mode-image_xfm.mat -o transformed.nii.gz
when i overlay transformed.nii.gz on top of the original T1w image (e.g., sub-0300_T1w.nii.gz), they dont seem to align well
am i doing it wrong?
cookpa
June 11, 2025, 7:31pm
2
Try with -r sub-0300_T1w.nii.gz
. The image passed with -r
should describe the space into which you want to resample the moving image.
I know it’s confusing because you have a 4D input image but a 3D reference image. It’s because antsApplyTransforms expects the reference image to match the dimension of the transform specified with -d
, which is 3.
i did this
antsApplyTransforms -d 3 -e 3 \
-i dwi/sub-00300_space-ACPC_desc-preproc_dwi.nii.gz \
-r $BIDS_dir/sub-00300/anat/sub-00300_T1w.nii.gz \
-t anat/sub-00300_from-ACPC_to-anat_mode-image_xfm.mat -o transformed.nii.gz
but when i overlay the transformed.nii.gz
(in red) on top of sub-00300_T1w.nii.gz
, it still doesnt look right
@gerardyu can you check the affine of your raw BIDS T1w? Sometimes these affines aren’t compatible with ITK, so we convert them to something that is compatible but maintains the correct voxel spacing.
i’m new to this, how do i check the affine of the T1w?
cookpa
June 16, 2025, 3:09pm
6
With fsl, you would do
fslhd sub-0300_T1w.nii.gz
with ANTs
PrintHeader sub-0300_T1w.nii.gz
here’s the output of fslhd sub-00300_T1w.nii.gz
sizeof_hdr 348
data_type INT16
dim0 3
dim1 192
dim2 256
dim3 256
dim4 1
dim5 1
dim6 1
dim7 1
vox_units mm
time_units s
datatype 4
nbyper 2
bitpix 16
pixdim0 1.000000
pixdim1 1.000000
pixdim2 1.000000
pixdim3 1.000000
pixdim4 2.530000
pixdim5 0.000000
pixdim6 0.000000
pixdim7 0.000000
vox_offset 352
cal_max 0.000000
cal_min 0.000000
scl_slope 1.000000
scl_inter 0.000000
phase_dim 1
freq_dim 2
slice_dim 3
slice_name Unknown
slice_code 0
slice_start 0
slice_end 0
slice_duration 0.000000
toffset 0.000000
intent Unknown
intent_code 0
intent_name
intent_p1 0.000000
intent_p2 0.000000
intent_p3 0.000000
qform_name Scanner Anat
qform_code 1
qto_xyz:1 0.999320 -0.031457 0.019218 -94.556938
qto_xyz:2 0.031451 0.999505 0.000605 -100.340317
qto_xyz:3 -0.019228 0.000000 0.999815 -104.852051
qto_xyz:4 0.000000 0.000000 0.000000 1.000000
qform_xorient Left-to-Right
qform_yorient Posterior-to-Anterior
qform_zorient Inferior-to-Superior
sform_name Scanner Anat
sform_code 1
sto_xyz:1 0.999321 -0.031457 0.019218 -94.556938
sto_xyz:2 0.031451 0.999505 0.000605 -100.340317
sto_xyz:3 -0.019228 0.000000 0.999815 -104.852051
sto_xyz:4 0.000000 0.000000 0.000000 1.000000
sform_xorient Left-to-Right
sform_yorient Posterior-to-Anterior
sform_zorient Inferior-to-Superior
file_type NIFTI-1+
file_code 1
descrip TE=1.6;Time=0.000;phase=1
aux_file