ChristianGaser / cat12

Computational Anatomy Toolbox for SPM12
https://neuro-jena.github.io/cat
GNU General Public License v2.0
33 stars 5 forks source link

Compatibility with Freesurfer issues #20

Closed MauricePasternak closed 8 months ago

MauricePasternak commented 8 months ago

Hey folks, loved your program from day 1.

Not sure if there is a workaround in the meantime, but I've been meaning to use the resampled surfaces from your program in other softwares like Freesurfer.

Issue 1 - num_cols and nvertices seem to be flipped.

However, upon trying to load a 164K-resampled .gii file into, say, freeview from Freesurfer, I receive the following error:

freeview -f s12.mesh.thickness.resampled.rsub-001_ses-01_T1w.gii
mrisReadGIFTIdanum: malformed data array [0] in file /home/mpasternak/Documents/tmp/surf/s12.mesh.thickness.resampled.rsub-001_ses-01_T1w.gii: num_vertices=1 num_cols=327684 expected nvertices=327684, num_cols=1
MRISread failed
mrisReadGIFTIdanum: malformed data array [0] in file /home/mpasternak/Documents/tmp/surf/s12.mesh.thickness.resampled.rsub-001_ses-01_T1w.gii: num_vertices=1 num_cols=327684 expected nvertices=327684, num_cols=1

Issue 2 - cat_io_FreeSurfer does not convert resampled .gii files

I chanced upon this while thinking "okay, maybe they have a script that needs to be run in order to fix the above." Some Google-fu lead me to your cat_io_FreeSurfer.m script, but it seems to not work either:

Example issue:

>> cat_io_FreeSurfer('gii2fs', '/home/mpasternak/Documents/tmp/surf/s12.mesh.thickness.resampled.rsub-001_ses-01_T1w.gii')
Error using  '  (line 9)
file_array objects can not be transposed.

Error in cat_io_FreeSurfer>write_surf (line 370)
  vert = reshape(vert',size(vert,1)*size(vert,2),1);

Error in cat_io_FreeSurfer>gii2fs (line 219)
      write_surf(char(surfname{si}), CS.vertices , CS.faces);

Error in cat_io_FreeSurfer (line 68)
        gii2fs(varargin{1})

If it assists in any way, I have uploaded the native-space and resampled thickness files:

cat12_issue20.zip

My apologies if this is just my ignorance to all this coming through and making a non-issue. But if not, could this be addressed?

ChristianGaser commented 8 months ago

The surfaces saved in native space before resampling (i.e. lh.central.name.gii) can be viewed with Freeview. However, the resampled surfaces are saved in a gifti format which is not supported by Freeview and uses an additional dat file. The advantage of using this format is that the surfaces are not saved in the SPM.mat file for statistical analysis, which would otherwise result in a huge SPM.mat file. Also, the resampled surface contains the thickness texture and I am not sure if this is correctly recognised by Freeview. The attached file allows you to convert from this dat/gii format to the pure gii format under Linux: CAT_SurfConvert.zip However, I would recommend to view the native surface file before resampling...

lyhoo23618-csu commented 2 weeks ago

Hello everyone,

I encountered a similar issue. I used CAT12 to perform group comparisons for cortical thickness (TFCE-based FWE correction), and I obtained the T_log_pFWE_0001.dat and T_log_pFWE_0001.gii files. My plan is to use the regions that show group differences as seed masks for a functional connectivity analysis. I tried using this file CAT_SurfConvert.zip to convert the T_log_pFWE_0001.gii and .dat files into a single .gii file for further file conversion. However, I encountered an issue with the CAT_SurfConvert step. My code is:

/CAT_SurfConvert T_log_pFWE_0001.dat T_log_pFWE_0001.gii

The error message is: “input_freesurfer: Unknown magic identifier: 12174918.”

Any insights on this issue would be appreciated.