External Email - Use Caution Hi Yujing, I'll try to explain it more explicitly, I rerun my Code and show the results beyond attaching the Registration files too.
Consider a 3D-Nifti image called "Image.nii" the steps bellow executed in order: 0- Every time we Will generate a random Registration Matrix and Save it under the name "fsl.mat" which is the desired Registration matrix. ============================================================================== fsl.mat := [[ 0.95509431, -0.28438761, 0.08317783, -5. ] [ 0.2961434, 0.90701597, -0.29936787, -5. ] [ 0.00969289, 0.31055712, 0.9505053, -2. ] [ 0., 0., 0., 1. ]] ============================================================================== 1- using a known registration matrice (called and attached in the first message and this message as "fsl.mat") resample the "Image.nii" to second Image called "fsl_resampled.nii" Command : flirt -ref ./Image.nii -in ./Image.nii -applyxfm -init ./fsl.mat -out ./fsl_resampled.nii -interp spline 2- find out the registration matrices using Registration Methods, here we will use FSL, FreesSurefer, ANTs: 2.1. FSL Commands: =============================================================================== Command : flirt -in ./Image.nii -out ./fslregistered.nii.gz -ref ./fsl_resampled.nii.gz -cost normmi -dof 6 -omat ./fslregistered.mat -interp spline =============================================================================== fslregistered : 0.9551458402 -0.2842262621 0.08313877187 -5.029802253 0.2959789517 0.9070999982 -0.2992758021 -5.014360215 0.009646861275 0.3104593324 0.9505376886 -1.971170444 0 0 0 1 ======================================================= The Registration Matrice in this Case Called "fslregistered.mat", using lta_convert we will make "fslregistered.lta" Command : lta_convert --infsl ./fsl/fslregistered.mat --outlta ./fsl/fslregistered.lta --src ./Image.nii --trg ./fsl/fslregistered.nii.gz --ltavox2vox =============================================================================== fslregistered.lta : 9.551459550857544e-01 -2.368552237749100e-01 6.928230822086334e-02 -4.191513061523438e+00 3.551747798919678e-01 9.071001410484314e-01 -2.992758452892303e-01 -5.014381408691406e+00 1.157622877508402e-02 3.104593753814697e-01 9.505378007888794e-01 -1.971183776855469e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00 2.2. FreeSurfer Commands: =============================================================================== Command : mri_robust_register --mov ./Image.nii --dst ./fsl_resampled.nii.gz --mapmov ./freesurfer.nii --lta freesurfer.lta --halfmov half-mov.nii --halfdst halfdst.nii --halfmovlta h1.lta --halfdstlta h2.lta --iscale --satit =============================================================================== freesurfer.lta : type = 0 # LINEAR_VOX_TO_VOX nxforms = 1 mean = 87.0000 129.0000 106.0000 sigma = 10000.0000 1 4 49.550938606262207e-01 -2.369909435510635e-01 6.931482255458832e-02 -4.167178630828857e+00 3.553738296031952e-01 9.070160388946533e-01 -2.993661761283875e-01 -4.999662876129150e+00 1.163147203624249e-02 3.105554580688477e-01 9.505058526992798e-01 -2.000635147094727e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00 ================================================================================ The Registration Matrice in this Case Called "freesurfer.lta", using lta_convert we will do the conversion and build the FSL-Space "freesurfer.mat" Command : lta_convert --inlta ./freesurfer/freesurfer.lta --outfsl ./freesurfer/freesurfer.mat --src ./Image.nii --trg ./fsl_resampled.nii.gz ======================================================== freesurfer.mat : 0.95509410 -0.28438917 0.08317780 -5.00063801 0.29614490 0.90701610 -0.29936624 -4.99965954 0.00969290 0.31055552 0.95050597 -2.00067019 0.00000000 0.00000000 0.00000000 1.00000000 ================================================================================ 2.3. ANTs Commands: ================================================================================ Commands : antsRegistrationSyNQuick.sh -d 3 -f ./fsl_resampled.nii.gz -m ./Image.nii -o ants_ -t r Using the ConvertTransform File we will make the "ants.txt" Command : ConvertTransformFile 3 ./ANTS/ants_0GenericAffine.mat ./ANTS/ants.txt ================================================================================ ants.txt: #Insight Transform File V1.0 #Transform 0 Transform: AffineTransform_double_3_3 Parameters: 0.9996357319973235 -0.01682948721742278 -0.021099091785527296 0.015864886388920783 0.9988573896699559 -0.045080156184165145 0.02183365965755943 0.04472900023162478 0.9987605357863502 -2.215029749904149 1.2122977228542815 -6.0667455324006445 FixedParameters: 5.195914900051355 -10.250280974097581 -6.670270481513606 ================================================================================ Using lta_convert we first make "ants.lta" Command: lta_convert --initk ./ANTS/ants.txt --outlta ./ANTS/ants.lta --src ./Image.nii --trg ./fsl_resampled.nii.gz --ltavox2vox ================================================================================ type = 0 # LINEAR_VOX_TO_VOX nxforms = 1 mean = 0.0000 0.0000 0.0000 sigma = 1.0000 1 4 49.996357560157776e-01 -1.322073861956596e-02 1.819471642374992e-02 1.924201965332031e+00 2.019538544118404e-02 9.988574385643005e-01 -4.472899809479713e-02 3.623344421386719e+00 -2.531890943646431e-02 4.508015885949135e-02 9.987605214118958e-01 2.642463684082031e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 1.000000000000000e+00 ================================================================================= Using the lta_convert we make the "ants.mat", the FSL-Spaced Registration matrix for ANTs Command: lta_convert --inlta ./ANTS/ants.lta --outfsl ./ANTS/ants.mat --src ./Image.nii --trg ./fsl_resampled.nii.gz ================================================================================= 0.99963582 -0.01586489 0.02183366 2.30903101 0.01682949 0.99885744 -0.04472899 3.62335658 -0.02109909 0.04508016 0.99876052 2.64244890 0.00000000 0.00000000 0.00000000 1.00000000 As we could see there are problems in 'ants.lta' and 'ants.mat', I'm not sure Yet but I Suspect that the "PSR" Orientation of the Image Which is a Left-handed coordination System may cause that because in Another Experiment with "LAS" these problem had been occured but in another "RAS" Image the lta_convertor worked precisely with no problem. The Registration Files are attached for More Information about Image's Geometry Sform's and Other ... Best, Yazdan On Mon, 25 Sept 2023 at 17:16, Huang, Yujing <yhuan...@mgh.harvard.edu> wrote: > External Email - Use Caution > > Hi Yazdan, > > > > I’m trying to understand the issues. > > > > Can you specify the commands used to generate the matrices attached to > your email? And give more details of the issues you are seeing? > > > > Best, > > > > Yujing > > > > *From:* freesurfer-boun...@nmr.mgh.harvard.edu < > freesurfer-boun...@nmr.mgh.harvard.edu> *On Behalf Of *Yazdan Rezaee > Jouryabi > *Sent:* Monday, September 25, 2023 1:49 AM > *To:* freesurfer@nmr.mgh.harvard.edu > *Subject:* [Freesurfer] lta_convert issue with ants Registration Matrix > > > > * External Email - Use Caution * > > Dear all, Hi > > > > for checking registration i used fsl applyxfm on an Image(1)(Called > Image.nii ) with specific Registration Matrice (Which we suppose to receive > when we apply registration Methods) and Generate the "fsl_resampled.nii.gz" > (Note: Image Orientations were LAS and in one other Experiment with also > the same problem PSR) > > > > for our case i will attach the "fsl.mat" (Desired Matrix) > > > > using, fsl, freesurfer, and ants i got the correct results (let's call > them "fslregistered.mat" and "freesurfer.mat" the converted lta to > fsl-liked Matrix) Everything is OK till now > > > > But the converted lta-like and fsl-like matrix for ANTs (Which are called > ants.lta, and ants.mat) using the lines below: > > - ConvertTransformFile 3 ./ANTS/ants_0GenericAffine.mat ./ANTS/ants.txt > > - lta_convert --initk ./ANTS/ants.txt --outlta ./ANTS/ants.lta --src > ./Image.nii --trg ./fsl_resampled.nii.gz --ltavox2vox > > - lta_convert --inlta ./ANTS/ants.lta --outfsl ./ANTS/ants.mat --src > ./Image.nii --trg ./fsl_resampled.nii.gz > > > > As All Results Images (Registered Image of all Methods) are aligned > perfectly i think that there might be some issues with lta_convert > > > > > > Best Regards > > Yazdan Rezaee J > > > > > > > *P.S. *" I've checked the one similar mail on this topic and the > conclusion on that was about (sform, qform) incompatibility but the affine > matrices of S-form and q-form are equivalent in my case." > > > _______________________________________________ > Freesurfer mailing list > Freesurfer@nmr.mgh.harvard.edu > https://secure-web.cisco.com/1CVysUaKA0QPJhHH2wwhYBipzUhFEaeL8kkwOtuATULgzm-ARVtRifTqrnuMch9mPrhoX5WsrgJCZI4n6LV0QrBOiwz8JOJSZcKXl0-srjhHE7Ez1eAdpgDrWIqslv1yZuu9lDDu4UrcCR_1k8-OHZM1lX5im7TD25ziCO5ibM6spWh-yZJ_pdgSrOWg3COhe2JLUiyCL3VPWaa-l3gJ-VY8E3fKgFi47mdINsuywYT2Z2bpFzMA0qVMOcxBZP6V2Jz-SpyfFbeS55S0r_f_lNm2JigMyuajjviAgHw-npf_6HYFs541IzQp4hzn0kOTN/https%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fmailman%2Flistinfo%2Ffreesurfer > The information in this e-mail is intended only for the person to whom it > is addressed. If you believe this e-mail was sent to you in error and the > e-mail contains patient information, please contact the Mass General > Brigham Compliance HelpLine at > https://secure-web.cisco.com/1iXmC6GDGT_irmtwnhqZdBKSxywaeJC3Q1wdvh_a0KY5o7X2IMOclXP4f0k-GqI_PRroMRHLYU-2PytqXKGTg6_fWW1KVDHATy0ENxJF3psR7lP7a-RRfcFNfBEjlwcIVKlvbWPxlCCMyKVbMe6U5Fh-MyOLPX0g_j4lWjXAjcWLJkRG0g4PBTK_xzSz904-Aq-5yTIzIoulIOOVdRa03bD2RdUbEfx4x44oD3QmrEeVyAQcHQXg97yGoNqncOG-pa601HCmc65kmd9kIqklmkjAhm1NA5O-PbF2zqMYfQYmUWbVziolYCOD5tYgNE9wx/https%3A%2F%2Fwww.massgeneralbrigham.org%2Fcomplianceline > < > https://secure-web.cisco.com/1iXmC6GDGT_irmtwnhqZdBKSxywaeJC3Q1wdvh_a0KY5o7X2IMOclXP4f0k-GqI_PRroMRHLYU-2PytqXKGTg6_fWW1KVDHATy0ENxJF3psR7lP7a-RRfcFNfBEjlwcIVKlvbWPxlCCMyKVbMe6U5Fh-MyOLPX0g_j4lWjXAjcWLJkRG0g4PBTK_xzSz904-Aq-5yTIzIoulIOOVdRa03bD2RdUbEfx4x44oD3QmrEeVyAQcHQXg97yGoNqncOG-pa601HCmc65kmd9kIqklmkjAhm1NA5O-PbF2zqMYfQYmUWbVziolYCOD5tYgNE9wx/https%3A%2F%2Fwww.massgeneralbrigham.org%2Fcomplianceline> > . >
#Insight Transform File V1.0 #Transform 0 Transform: AffineTransform_double_3_3 Parameters: 0.9996357319973235 -0.01682948721742278 -0.021099091785527296 0.015864886388920783 0.9988573896699559 -0.045080156184165145 0.02183365965755943 0.04472900023162478 0.9987605357863502 -2.215029749904149 1.2122977228542815 -6.0667455324006445 FixedParameters: 5.195914900051355 -10.250280974097581 -6.670270481513606
fsl.mat
Description: Binary data
fslregistered.lta
Description: Binary data
fslregistered.mat
Description: Binary data
freesurfer.lta
Description: Binary data
freesurfer.mat
Description: Binary data
ants.mat
Description: Binary data
ants.lta
Description: Binary data
_______________________________________________ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer Please note that this e-mail is not secure (encrypted). If you do not wish to continue communication over unencrypted e-mail, please notify the sender of this message immediately. Continuing to send or respond to e-mail after receiving this message means you understand and accept this risk and wish to continue to communicate over unencrypted e-mail.