Run FreeSurfer to get all files for VBMEG. [Usage] vb_freesurfer_run(mri_file, fs_root_dir, subj_id) [Input] mri_file : Input MRI T1 Image file name. This file should be created using convert_dicom_nifti.m - NIfTI file(.nii) - LAS Analyze file(.hdr/.img) fs_root_dir : Root Dir for FS data. subj_id : Subject ID , it becomes Sub-directory name. [Output files] fs_root_dir/subj_id/bem/ - brain(cortex) model file lh.smoothwm.asc : smooth cortical surface rh.smoothwm.asc lh.inflated.asc : inflated surface rh.inflated.asc lh.curv.asc : curvature info file rh.curv.asc lh.white.asc : cortical surface rh.white.asc - skull surface for BEM inner_skull_surface.asc : inner skull surface outer_skull_surface.asc : outer skull surface outer_skin_surface.asc : skin surface - spherical registration surface lh.sphere.reg.asc rh.sphere.reg.asc Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function vb_freesurfer_run(mri_file, fs_root_dir, subj_id) 0002 % Run FreeSurfer to get all files for VBMEG. 0003 % [Usage] 0004 % vb_freesurfer_run(mri_file, fs_root_dir, subj_id) 0005 % [Input] 0006 % mri_file : Input MRI T1 Image file name. 0007 % This file should be created using convert_dicom_nifti.m 0008 % - NIfTI file(.nii) 0009 % - LAS Analyze file(.hdr/.img) 0010 % fs_root_dir : Root Dir for FS data. 0011 % subj_id : Subject ID , it becomes Sub-directory name. 0012 % 0013 % [Output files] 0014 % fs_root_dir/subj_id/bem/ 0015 % - brain(cortex) model file 0016 % lh.smoothwm.asc : smooth cortical surface 0017 % rh.smoothwm.asc 0018 % lh.inflated.asc : inflated surface 0019 % rh.inflated.asc 0020 % lh.curv.asc : curvature info file 0021 % rh.curv.asc 0022 % lh.white.asc : cortical surface 0023 % rh.white.asc 0024 % 0025 % - skull surface for BEM 0026 % inner_skull_surface.asc : inner skull surface 0027 % outer_skull_surface.asc : outer skull surface 0028 % outer_skin_surface.asc : skin surface 0029 % 0030 % - spherical registration surface 0031 % lh.sphere.reg.asc 0032 % rh.sphere.reg.asc 0033 % 0034 % 0035 % Copyright (C) 2011, ATR All Rights Reserved. 0036 % License : New BSD License(see VBMEG_LICENSE.txt) 0037 0038 if nargin < 3 0039 eval(['help ' mfilename]); 0040 return; 0041 end 0042 0043 % 0044 % --- Previous check 0045 % 0046 0047 if exist(fs_root_dir, 'dir') ~= 7 0048 error('fs_root_dir not found : %s', fs_root_dir); 0049 end 0050 if strfind(subj_id, ' ') 0051 error('subj_id contains white space : %s', subj_id); 0052 end 0053 if exist(mri_file, 'file') ~= 2 0054 error('mri_file not found : %s', mri_file); 0055 end 0056 0057 if strcmp(mri_file(end-3:end), '.hdr') 0058 mri_file(end-3:end) = '.img'; 0059 end 0060 0061 % 0062 % --- Main Procedure 0063 % 0064 0065 % give a script permission for execution. 0066 cmd = which('RunFreeSurfer.csh'); 0067 [result, err_txt] = system(['chmod 755 ' cmd]); 0068 if result ~= 0 0069 error(err_txt); 0070 end 0071 dest_dir = fullfile(fs_root_dir, subj_id); 0072 if exist(dest_dir, 'dir') == 7 0073 warning('FreeSurfer directory already exist. skip creating. :%s', dest_dir); 0074 return; 0075 end 0076 exe_cmd = [cmd, ' ', ... 0077 fs_root_dir, ' ',... 0078 subj_id, ' ', ... 0079 mri_file, ' ', ... 0080 '$FREESURFER_HOME']; 0081 0082 dmri_system(exe_cmd, '-echo');