Open dyhan316 opened 1 year ago
You can use c3d to convert between ITK transforms and FSL-style transforms. Something like
c3d_affine_tool -ref sub-130917_desc-preproc_T1w.nii.gz -src your_non-acpc_image.nii -itk sub-130917_from-T1wNative_to-T1wACPC_mode-image_xfm.mat -ras2fsl -o fsl_transformation_file.mat
should work. More robust would be to use antsApplyTransforms -d 3 -i your_non-acpc_image.nii -o your_image_in_acpc.nii -t sub-130917_from-T1wNative_to-T1wACPC_mode-image_xfm.mat --interpolation BSpline
@mattcieslak Thank you for your response! Using antsApplyTrnasform on the mat file, I was able to get something like this! (The base grey image is the qsiprep image, and the overlay is the warped BIDS anat image)
The code used was
##1. read images (https://antspy.readthedocs.io/en/latest/core.html#ants.image_read)
bids_img = ants.image_read(filename = './BIDS/sub-150758/anat/sub-150758_T1w.nii.gz')
qsi_img = ants.image_read(filename = './QSIPREP/sub-150758/anat/sub-150758_desc-preproc_T1w.nii.gz')
##2. Apply the trnasform
warped_image = ants.apply_transforms(fixed = qsi_img, moving = bids_img,
transformlist = './QSIPREP_ver18_with_matrix/sub-150758_from-T1wNative_to-T1wACPC_mode-image_xfm.mat',
interpolator = "bSpline")
It seems that the alignment was slightly off?
Is this expected? Why is this happening?
One oddity I found that might help is that the bids img and the qsiprep image have different dimensions, as the data below shows :
bids_img, qsi_img
=========
(ANTsImage (LPI)
Pixel Type : float (float32)
Components : 1
Dimensions : (512, 512, 120)
Spacing : (0.4297, 0.4297, 1.0)
Origin : (113.4008, 83.5237, -40.7669)
Direction : [-1. 0. 0.0038 0. -1. 0. 0.0038 0. 1. ],
ANTsImage (RAI)
Pixel Type : float (float32)
Components : 1
Dimensions : (193, 229, 193)
Spacing : (1.0, 1.0, 1.0)
Origin : (-96.0, -96.0, -78.0)
Direction : [1. 0. 0. 0. 1. 0. 0. 0. 1.])
(for reference, below is the bids image "before" the alignment, which seems to be way off)
In other words, it seems that while the antsapplytransform does move the two images closer, they are still slightly off?
Hi, it seems that I am having a similar issue with qsiprep version 0.20.0: the resulting image after antsApplyTransforms
is not aligned with the output of qsiprep in the T1w ACPC space.
I described the issue here: https://neurostars.org/t/qsiprep-amico-noddi-and-space-t1/28529/3?u=jsein
@julfou81 and @dyhan316 are your original T1w images oblique?
Hi @mattcieslak , thank you for your question!
Yes indeed, the original T1w image is oblique:
3dinfo sub-JEU02_ses-01_T1w.nii.gz
++ 3dinfo: AFNI version=AFNI_22.1.14 (Jun 24 2022) [64-bit]
Dataset File: /Users/jsein/Documents/Centre_IRMf/DATA/BIDS/EcriPark/derivatives/qsiprep/sub-JEU02_ses-01_T1w.nii.gz
Identifier Code: NII_K8Q8CrSlSAIy2lM2_pnuhw Creation Date: Sat Mar 9 20:30:57 2024
Template Space: ORIG
Dataset Type: Anat Bucket (-abuc)
Byte Order: LSB_FIRST {assumed} [this CPU native = LSB_FIRST]
Storage Mode: NIFTI
Storage Space: 25,165,824 (25 million) bytes
Geometry String: "MATRIX(-0.996849,0.052032,-0.059925,96.11948,-0.037712,-0.97495,-0.219202,136.4017,-0.069829,-0.216251,0.973837,-109.5287):192,256,256"
Data Axes Tilt: Oblique (13.135 deg. from plumb)
Data Axes Approximate Orientation:
first (x) = Left-to-Right
second (y) = Posterior-to-Anterior
third (z) = Inferior-to-Superior [-orient LPI]
R-to-L extent: -94.881 [R] -to- 96.119 [L] -step- 1.000 mm [192 voxels]
A-to-P extent: -118.598 [A] -to- 136.402 [P] -step- 1.000 mm [256 voxels]
I-to-S extent: -109.529 [I] -to- 145.471 [S] -step- 1.000 mm [256 voxels]
Number of values stored at each pixel = 1
-- At sub-brick #0 '?' datum type is short [*0.04]
I tried to deoblique it ( with 3dwarp -deoblique sub-JEU02_ses-01_T1w.nii.gz -prefix new_T1w.nii.gz
) before applying the sub-JEU02_from-T1wNative_to-T1wACPC_mode-image_xfm.mat
transform but the image was moved to another space than sub-JEU02_desc-preproc_T1w.nii.gz
given as output of qsiprep.
I just saw your comment on Neurostars. Thank you!
When the qsiprep version 18.0 is run, for the anat results, we get something like
We want to use the
sub-130917_from-T1wNative_to-T1wACPC_mode-image_xfm.mat
matrix to perform flirt. However, the.mat
is something like :How can I change this into a 4x4 matrix form to use for flirt?