A question about transformation matrix

Hello,

I got an error information as below:

** FATAL ERROR: -matvec file not a 3x4 matrix!
** Program compile date = May 21 2017
** ERROR: Could not oblique/shift anat to epi data

I checked the matrix using in the code, it is a 3*4 matrix. Well, at least it contains 12 numbers.
Here it is:

3dAllineate matrices (DICOM-to-DICOM, row-by-row):

   1.00309    -0.0030288   -0.00490386      -0.45253    0.00511126       1.00771    0.00498307      -1.09497    0.00639334   -0.00971128      0.991483      -2.43748

So I don’t understand what the problem is. Please could someone help with this?

Many thanks,
Sarah

It would be useful to see the exact command that produced the error. There are two formats for the affine matrices in AFNI. To convert between the two, use cat_matvec.

Hi Daniel,

The command I used to generate the matrix is:
3dAllineate -prefix anat_within_aligned -base ${subj}_avg_anat+orig -1Dmatrix_save align_to_avg -source anat+orig

And then I used that matrix in afni_proc.py:
afni_proc.py -subj_id $subj.vol
-blocks tshift align volreg scale
-copy_anat ${subj}avg_anat+orig
-dsets run
*+orig.HEAD
-tcat_remove_first_trs 0
-align_opts_aea -pre_matrix $top_dir/align_to_avg.aff12.1D -cost lpa -partial_coverage -anat_has_skull ‘no’
-volreg_align_to MIN_OUTLIER
-volreg_align_e2a
-scr_overwrite
-execute

The matrix doesn’t have any problem when I did surface analysis. But when I tried to use the same matrix to do the volume based analysis, it gave me that error.

Sarah

Hi Daniel,

I tried the method you mentioned, unfortunately, I got another error:

#Script is running (command trimmed):
cat_matvec -ONELINE ./sub04_avg_anat_al_junk_e2a_only_mat.aff12.1D /Volumes/fMRI_Data/AFNI_PROCESSED_DATA/vis_loc/sub04_20170516/xform_test.aff12.1D -I > ./sub04_avg_anat_al_junk_mat.aff12.1D
** FATAL ERROR: File ‘/Volumes/fMRI_Data/AFNI_PROCESSED_DATA/vis_loc/sub04_20170516/xform_test.aff12.1D’ has 4 values per row, which isn’t 12

I’m totally confused now.

Sarah

Sorry, you’re missing one key piece of information. The files that end in “.aff12.1D” should have 12 values per row. If you redirect from another file or otherwise create a text file with 3 rows of 4 values, you should not use the .aff12.1D extension. Just use the .1D extension instead. Here are some example of how to use cat_matvec with these matrices. I start by creating a 4x3 matrix manually on the command line and then swap between the two formats.

cat > test.1D
1 0 0 10
0 1 0 -10
0 0 1 20
^C
% cat_matvec test.1D
1 0 0 10
0 1 0 -10
0 0 1 20
% cat_matvec -ONELINE test.1D
1 0 0 10 0 1 0 -10 0 0 1 20
% cat_matvec -ONELINE test.1D > test.aff12.1D
% cat_matvec -ONELINE test.aff12.1D
1 0 0 10 0 1 0 -10 0 0 1 20
% cat_matvec test.aff12.1D
1 0 0 10
0 1 0 -10
0 0 1 20

% cp test.1D test2.aff12.1D
% cat_matvec test2.aff12.1D
** FATAL ERROR: File ‘test2.aff12.1D’ has 4 values per row, which isn’t 12
** Program compile date = Nov 9 2017