Dear FreeSurfers,
I am using "mri_vol2surf" to map my SPM processed t images onto 9 intermediate surfaces created by "mris_expand". When every step is done manually it works perfectly. However, for very large datasets I would need to run mri_vol2surf for multiple subjects, multiple conditions, multiple ROIs, and etc. Therefore, automising the command to be executed on multiple datasets at once is a requirement. Unfortunately there is no Matlab function for mri_vol2surf, this brings me to my question: how can I use mri_vol2surf in Matlab for multiple datasets, how the command must be written, how the variables and directories must be redefined so Matlab and FreeSurfer both have access to what they need. In other words, how mri_vol2surf should be used, either in Matlab or in shell, in order to be executed on multiple datasets at once? As a side note I am using Mac OS 10.9.5 with FreeSurfer v5.3.0. Thank you in advance for your guidance.
Kind Regards,
Fatemeh Molaei-Vaneghi
Max Planck Institute for Biological Cybernetics Tübingen Germany
why do you need to do it in matlab? Why not use a shell script (tcsh, sh, python, etc)? If you run it with --help, it will give you info on how to run it.
On 11/10/2015 12:56 PM, Fatemeh.Molaei-Vaneghi wrote:
Dear FreeSurfers,
I am using "mri_vol2surf" to map my SPM processed t images onto 9 intermediate surfaces created by "mris_expand". When every step is done manually it works perfectly. However, for very large datasets I would need to run mri_vol2surf for multiple subjects, multiple conditions, multiple ROIs, and etc. Therefore, automising the command to be executed on multiple datasets at once is a requirement. Unfortunately there is no Matlab function for mri_vol2surf, this brings me to my question: how can I use mri_vol2surf in Matlab for multiple datasets, how the command must be written, how the variables and directories must be redefined so Matlab and FreeSurfer both have access to what they need. In other words, how mri_vol2surf should be used, either in Matlab or in shell, in order to be executed on multiple datasets at once? As a side note I am using Mac OS 10.9.5 with FreeSurfer v5.3.0. Thank you in advance for your guidance.
Kind Regards,
Fatemeh Molaei-Vaneghi
Max Planck Institute for Biological Cybernetics Tübingen Germany _______________________________________________ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
Dear Douglas,
Thanks for your reply. The reason I want to use mri_vol2surf in Matlab is that I have a huge dataset saved in cell arrays of Matlab i.e. multiple subjects, multiple datasets for each subject, multiple ROIs for each of these datasets, multiple surfaces for each of these ROIs, and etc. Therefore the most convenient way for me is to save my data in cell arrays: in Matlab some thing like "data {sub,tval}{hem,roi}{s,1} = MRIread ([tvalss{tval} hemphh{hem} roiss{roi} depth{s} 'p_surf.nii']);.
As far as I know multidimensional arrays are not supported in shell scripting. How, in a shell script, I can use mri_vol2surf with it's input variables stored in cell arrays? In a shell I wrote some thing like the following, but it does not work!
# freesurfer project directory export PATH=$PATH:/Volumes/DATA/projects/ret_obj_purs_recon/subjects
# subjects: SUBJ=(“ 2_MzBOLD02_GB15042014_UnMasked_Mp2rage_1_0” “4_MzBOLD04_US14082015_Masked_Mp2rage_1_0” “5_MzBOLD05_MW14082015_Masked_Mp2rage_1_0” “7_MzBOLD07_HG21082015_Masked_Mp2rage_1_0” “8_MzBOLD08_SN21082015_Masked_Mp2rage_1_0” “9_MzBOLD09_AS28082015_Masked_Mp2rage_1_0” “10_MzBOLD10_CS28082015_Masked_Mp2rage_1_0” )
# smp directory SPMDIR=/spm/
# smoothness: SMOOTH=( “0_8mm” “1_2mm” “1_6mm” )
# t-values TVALS=( “ret_tval_” “obj_tval_” “purs_tval_” “v3a_tval_” )
# hemispheres 1 HEMPH=( “_lh_” “_rh_” )
# hemispheres 2 HEM=( “lh” “rh” )
# rois 1 ROIS=( “v3aroi” “v6roi” “v7roi” )
# rois 2 ROISS=( “v3a” “v6” “v7” )
# depth line:44 DEPTH=( “000” “001” “002” “003” “004” “005” “006” “007” “008” “009” “010” )
# ==============================================================
for sub in ${SUBJ[@]} ; do for sm in ${SMOOTH[@]} ; do cd /Volumes/DATA/projects/ret_obj_purs_recon/subjects/ “${SUBJ[sub]}” “${SMOOTH[sm]}“ echo “current directory: /Volumes/DATA/projects/ret_obj_purs_recon/subjects/ ${SUBJ[sub]} ${SMOOTH[sm]}“ for tval in ${TVALS[@]} ; do for h in ${HEMPH[@]} ; do for roi in ${ROIS[@]} ; do mri_vol2surf --src $SUBJECT_DIR/${SUBJ[1]}/spm/${SMOOTH[1]}/"spmT_000${TVALS[tval]}.nii" --srcreg register.dat --hemi ${HEMPH[h]} --surf depth ${DEPTH[s]} --mask "${HEM[h]}.${ROISS[roi]}.label" --out ./"${TVALS[tval]} ${HEM[h]}_${ROIS[roi]}_depth ${DEPTH[s]}_surf.nii" --out_type nii done done done done done
I would really appreciate it if you could please let me know what you think.
All the Best, Fatemeh
Are you saying that you have the actual surface data stored as an array in matlab or just the filename pointing to the surface data. The routine that you have there will not work because mri_vol2surf is a linux command. However, you can run linux commaand from matlab using the matlab "system" command.
On 11/10/2015 05:21 PM, Fatemeh.Molaei-Vaneghi wrote:
Dear Douglas,
Thanks for your reply. The reason I want to use mri_vol2surf in Matlab is that I have a huge dataset saved in cell arrays of Matlab i.e. multiple subjects, multiple datasets for each subject, multiple ROIs for each of these datasets, multiple surfaces for each of these ROIs, and etc. Therefore the most convenient way for me is to save my data in cell arrays: in Matlab some thing like "data {sub,tval}{hem,roi}{s,1} = MRIread ([tvalss{tval} hemphh{hem} roiss{roi} depth{s} 'p_surf.nii']);.
As far as I know multidimensional arrays are not supported in shell scripting. How, in a shell script, I can use mri_vol2surf with it's input variables stored in cell arrays? In a shell I wrote some thing like the following, but it does not work!
# freesurfer project directory export PATH=$PATH:/Volumes/DATA/projects/ret_obj_purs_recon/subjects
# subjects: SUBJ=(“ 2_MzBOLD02_GB15042014_UnMasked_Mp2rage_1_0” “4_MzBOLD04_US14082015_Masked_Mp2rage_1_0” “5_MzBOLD05_MW14082015_Masked_Mp2rage_1_0” “7_MzBOLD07_HG21082015_Masked_Mp2rage_1_0” “8_MzBOLD08_SN21082015_Masked_Mp2rage_1_0” “9_MzBOLD09_AS28082015_Masked_Mp2rage_1_0” “10_MzBOLD10_CS28082015_Masked_Mp2rage_1_0” )
# smp directory SPMDIR=/spm/
# smoothness: SMOOTH=( “0_8mm” “1_2mm” “1_6mm” )
# t-values TVALS=( “ret_tval_” “obj_tval_” “purs_tval_” “v3a_tval_” )
# hemispheres 1 HEMPH=( “_lh_” “_rh_” )
# hemispheres 2 HEM=( “lh” “rh” )
# rois 1 ROIS=( “v3aroi” “v6roi” “v7roi” )
# rois 2 ROISS=( “v3a” “v6” “v7” )
# depth line:44 DEPTH=( “000” “001” “002” “003” “004” “005” “006” “007” “008” “009” “010” )
# ==============================================================
for sub in ${SUBJ[@]} ; do for sm in ${SMOOTH[@]} ; do cd /Volumes/DATA/projects/ret_obj_purs_recon/subjects/ “${SUBJ[sub]}” “${SMOOTH[sm]}“ echo “current directory: /Volumes/DATA/projects/ret_obj_purs_recon/subjects/ ${SUBJ[sub]} ${SMOOTH[sm]}“ for tval in ${TVALS[@]} ; do for h in ${HEMPH[@]} ; do for roi in ${ROIS[@]} ; do mri_vol2surf --src $SUBJECT_DIR/${SUBJ[1]}/spm/${SMOOTH[1]}/"spmT_000${TVALS[tval]}.nii" --srcreg register.dat --hemi ${HEMPH[h]} --surf depth ${DEPTH[s]} --mask "${HEM[h]}.${ROISS[roi]}.label" --out ./"${TVALS[tval]} ${HEM[h]}_${ROIS[roi]}_depth ${DEPTH[s]}_surf.nii" --out_type nii done done done done done
I would really appreciate it if you could please let me know what you think.
All the Best, Fatemeh _______________________________________________ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
What is saved in Matlab cell arrays is simply volumetric SPM data for different subjects, ROIs, and etc. For example I have "data {subject no.,contrast no.}{roi, hemisphere}" which is a 2D cell with each cell being a cell too. What I want is run mri_vol2surf for each of these subjects, each of these contrasts, each of these ROIs, each of these hemispheres, and finally for each of 9 intermediate surfaces.
I already tried "system","unix", and "!" in order to run unix commands in Matlab, not successful either.
mri_vol2surrf operates on volumetric data. If your data is not volumetric, then you can't use it. If it is volumetric but not stored on disk in a volume format (eg, nii. mgz), then you cannot use it directly. If you can write out your data in such a format, then you can use it.
On 11/11/15 6:51 AM, Fatemeh.Molaei-Vaneghi wrote:
What is saved in Matlab cell arrays is simply volumetric SPM data for different subjects, ROIs, and etc. For example I have "data {subject no.,contrast no.}{roi, hemisphere}" which is a 2D cell with each cell being a cell too. What I want is run mri_vol2surf for each of these subjects, each of these contrasts, each of these ROIs, each of these hemispheres, and finally for each of 9 intermediate surfaces.
I already tried "system","unix", and "!" in order to run unix commands in Matlab, not successful either. _______________________________________________ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
Thank you for taking the time and responding. I managed to correct my shell script, and now it works! I would guess running shell scripts from Matlab is generally not a good idea.
Best, Fatemeh
freesurfer@nmr.mgh.harvard.edu