Hello Freesurfer Experts,
We've used the following tcsh script to convert MEG surface data, morphed to fsaverage .w paint (every timestep) format, to volume data in NIFTI format:
# Convert to .nii format (volume from surface data of dSPM) placing .nii files in NII_DIR # FREESURFER_HOME is the base directory for FreeSurfer; sourcing from SetUpFreesurfer.sh setenv FREESURFER_HOME /apps/freesurfer/ && source ${FREESURFER_HOME}SetUpFreeSurfer.csh # set file numbers denoting each time step set Tmin = -0200 && set Tstep = 10 && set Tmax = 1000 # foreach FileNum (` seq -w $Tmin $Tstep $Tmax ` ) # CONVERT SURFACE DATA TO VOLUME DATA FROM PAINT TO MGZ to NII mri_surf2vol --surfval ${STC_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-lh.w paint --hemi lh --volreg ${SUBJECTS_DIR}/fsaverage/mri/transforms/reg.mni152.2mm.dat --template ${SUBJECTS_DIR}/fsaverage/mri/T1.mgz --outvol ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-lh.mgz mri_convert ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-lh.mgz ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-lh.nii mri_surf2vol --surfval ${STC_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-rh.w paint --hemi rh --volreg ${SUBJECTS_DIR}/fsaverage/mri/transforms/reg.mni152.2mm.dat --template ${SUBJECTS_DIR}/fsaverage/mri/T1.mgz --outvol ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-rh.mgz mri_convert ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-rh.mgz ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-rh.nii # mri_concat does temporal concatenation. Done this way, each image will include the left # hemisphere solution, and then the right hemisphere solution. You have to do this separately #for each hemisphere, and then add the two hemispheres together using something like #fslmaths or 3dcalc. # Have to convert mgz to nii first using e.g.: mri_convert input.mgz output.nii # e.g., 3dcalc -a left.nii -b right.nii -expr 'a+b' -prefix test_combined.nii
# MERGING OF HEMISPHERES (.nii) AT EACH TIMESTEP ${AFNI_DIR}/3dcalc -a ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-lh.nii -b ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-rh.nii -expr 'a+b' -prefix ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0.nii
set ExecString = 'mri_concat ' foreach FileNum (` seq -w $Tmin $Tstep $Tmax ` ) set ExecString = "${ExecString} ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0.nii " end
The .nii files come out uniform size and a colleague suggested that I add a baseline to the original data. It seems like the issue is happening at the mri_convert step and the T1.mgz fsaverage template seems to not register properly. Is there some syntax I should be adding to the --template option in mri_surf2vol? Perhaps it's something else.
-Franklin
Sorry, I don't understand what the issue/problem is doug
On 05/20/2014 02:01 PM, Franklin Lovell Orndorff-Plunkett wrote:
Hello Freesurfer Experts,
We've used the following tcsh script to convert MEG surface data, morphed to fsaverage .w paint (every timestep) format, to volume data in NIFTI format:
# Convert to .nii format (volume from surface data of dSPM) placing .nii files in NII_DIR # FREESURFER_HOME is the base directory for FreeSurfer; sourcing from SetUpFreesurfer.sh setenv FREESURFER_HOME /apps/freesurfer/ && source ${FREESURFER_HOME}SetUpFreeSurfer.csh # set file numbers denoting each time step set Tmin = -0200 && set Tstep = 10 && set Tmax = 1000 # foreach FileNum (` seq -w $Tmin $Tstep $Tmax ` ) # CONVERT SURFACE DATA TO VOLUME DATA FROM PAINT TO MGZ to NII mri_surf2vol --surfval ${STC_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-lh.w paint --hemi lh --volreg ${SUBJECTS_DIR}/fsaverage/mri/transforms/reg.mni152.2mm.dat --template ${SUBJECTS_DIR}/fsaverage/mri/T1.mgz --outvol ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-lh.mgz mri_convert ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-lh.mgz ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-lh.nii mri_surf2vol --surfval ${STC_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-rh.w paint --hemi rh --volreg ${SUBJECTS_DIR}/fsaverage/mri/transforms/reg.mni152.2mm.dat --template ${SUBJECTS_DIR}/fsaverage/mri/T1.mgz --outvol ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-rh.mgz mri_convert ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-rh.mgz ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-rh.nii # mri_concat does temporal concatenation. Done this way, each image will include the left # hemisphere solution, and then the right hemisphere solution. You have to do this separately #for each hemisphere, and then add the two hemispheres together using something like #fslmaths or 3dcalc. # Have to convert mgz to nii first using e.g.: mri_convert input.mgz output.nii # e.g., 3dcalc -a left.nii -b right.nii -expr 'a+b' -prefix test_combined.nii
# MERGING OF HEMISPHERES (.nii) AT EACH TIMESTEP ${AFNI_DIR}/3dcalc -a${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-lh.nii -b ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0-rh.nii -expr 'a+b' -prefix ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0.nii
set ExecString = 'mri_concat ' foreach FileNum (` seq -w $Tmin $Tstep $Tmax ` ) set ExecString = "${ExecString} ${NII_DIR}/${SUBJECT}${STC_MORPH_SUFFIX}-30_45_80-${FileNum}.0.nii " end
The .nii files come out uniform size and a colleague suggested that I add a baseline to the original data. It seems like the issue is happening at the mri_convert step and the T1.mgz fsaverage template seems to not register properly. Is there some syntax I should be adding to the --template option in mri_surf2vol? Perhaps it's something else.
-Franklin
Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
freesurfer@nmr.mgh.harvard.edu