Our imaging team is running a pre-processing script on our imaging data, and we are getting the error message "“Could not open matrix file epi2anat.mat”
Here is what our script looks like:
#!/bin/tcsh
This script does motion correction, field-map correction and registers the functional to the anatomical.
To QC the results, you need to overlay coreg_slice_e2a over the anatomical image to make sure the alignment
is good.
set rawDataDirectory = /Users/naiirlab/Documents/MRI_Raw_Data
set subjectsDirectory = /Users/naiirlab/Documents/MRI_Scan_Data
foreach subj ( TD004 )
echo
echo "Processing functional for ${subj}... "
echo
echo "Motion correction..."
cd ${subjectsDirectory}/${subj}/rest
mkdir motion
3dvolreg -zpad 4 -tshift 0 -base 90 \
-1Dmatrix_save motion/${subj}_vr -nomaxdisp -1Dfile motion/${subj}_vr_motion.1D \
-prefix ${subj}_resting_moco.nii.gz rest.nii.gz
echo
echo "Reorienting to LPI..."
cd ${subjectsDirectory}/${subj}
fslreorient2std ${subj}_resting_moco.nii.gz ${subj}_resting_moco_LPI
echo
echo "Coregistering EPI to anatomical..."
cd ${subjectsDirectory}/${subj}/rest
3dcalc -a ${subj}_resting_moco.nii.gz'[0]' -prefix coreg_slice.nii.gz -expr "a"
flirt -ref ${subjectsDirectory}/${subj}/anat/${subj}_anat_biascorr_brain.nii.gz -in coreg_slice.nii.gz -out coreg_slice_e2a.nii.gz -omat epi2anat.mat -cost corratio -dof 6 -interp trilinear
end
The above script creates the matrix file, but it defaults to a Matlab file with the suffix .mat. We have tried running it as a 1D file as well, but we still get the same result, that we cannot open the matrix file. So we are thinking that there is a problem in this step. How can we correct this?
Hello,
This is the AFNI forum, and the function that produced it is an FSL function. So you may want to ask that question over at their mailing list: https://www.jiscmail.ac.uk/cgi-bin/webadmin?A0=fsl
That said, what are you trying to open this file with? If it is an AFNI program, then it is not designed to load an FSL file. If you are using Matlab to open it (which is what your OS will default to if you click on it) then it will attempt to read the file as a binary blob, and it is actually plain text, so it won’t load in matlab either.
I agree with Josh on this… The error being produced is from FSL’s flirt, so you should probably check with them…
I will say that this script is somewhat problematic in the following ways:
- you’re using 3dvolreg with the -tshift option, which is convenient but you probably also should to slice timing correction in 3dTshift in case your file doesn’t have the slice information.
- The reorientation of the image after calculating motion might cause havoc in later applying the matrix, particularly when crossing softwares
Since you asked the question on the AFNI message board, I’ll be happy to also say that our tools can do this entire process for you as well using 3dAllineate[/url] instead of Flirt. Or you could make use of our superscript [url=https://afni.nimh.nih.gov/pub/dist/doc/program_help/afni_proc.py.html]afni_proc.py to fully process your data and thanks to the Paul Taylor and others, get very pretty QC images at the end of it.
A full introduction to AFNI can be found on YouTube. And of course we’re here to help.
Hi,
This is an FSL script. We have tried messaging the AFNI help too- but no reply back.
Do you know how to bypass the Matlab issue? It’s not loading in Matlab so we are trying to convert the file so its not .mat, but nothing has worked yet.
Thank you