0001 function brain_parm = vb_freesurfer_get_files(brain_parm, fs_sbj_dir)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 if nargin ~= 2
0028 error('Please check function usage');
0029 end
0030
0031
0032
0033
0034
0035
0036 fs_label_dir = fullfile(fs_sbj_dir, 'label');
0037 [tmp, num_found_files] = search(brain_parm, fs_label_dir);
0038 if num_found_files ~= 2
0039 error('This is not Freesurfer subject directory.');
0040 end
0041
0042
0043
0044
0045
0046
0047 fs_surf_dir = fullfile(fs_sbj_dir, 'surf');
0048 fs_bem_dir = fullfile(fs_sbj_dir, 'bem');
0049 [tmp, num_found_files] = search(brain_parm, fs_surf_dir);
0050 if num_found_files >= 6
0051 brain_parm = tmp;
0052 else
0053 [tmp, num_found_files] = search(brain_parm, fs_bem_dir);
0054 if num_found_files >= 6
0055 brain_parm = tmp;
0056 else
0057 warning('Freesurfer files not found.');
0058 end
0059 end
0060
0061
0062
0063
0064 [brain_parm] = search(brain_parm, fs_label_dir);
0065
0066
0067 function [brain_parm, num_found_files] = search(brain_parm, target_dir)
0068
0069 num_found_files = 0;
0070 target_files = {'lh.smoothwm.asc';
0071 'rh.smoothwm.asc';
0072 'lh.inflated.asc';
0073 'rh.inflated.asc';
0074 'lh.curv.asc';
0075 'rh.curv.asc';
0076 'lh.cortex.label';
0077 'rh.cortex.label';
0078 'lh.sphere.reg.asc';
0079 'rh.sphere.reg.asc'};
0080
0081 for k=1:length(target_files)
0082 target_file = fullfile(target_dir, target_files{k});
0083 if exist(target_file, 'file') ~= 2
0084 continue;
0085 end
0086 switch(target_files{k})
0087 case 'lh.smoothwm.asc'
0088 brain_parm.FS_left_file = target_file;
0089 case 'rh.smoothwm.asc'
0090 brain_parm.FS_right_file = target_file;
0091 case 'lh.inflated.asc'
0092 brain_parm.FS_left_infl_file = target_file;
0093 case 'rh.inflated.asc'
0094 brain_parm.FS_right_infl_file = target_file;
0095 case 'lh.curv.asc';
0096 brain_parm.FS_left_curv_file = target_file;
0097 case 'rh.curv.asc';
0098 brain_parm.FS_right_curv_file = target_file;
0099 case 'lh.cortex.label'
0100 brain_parm.FS_left_label_file = target_file;
0101 case 'rh.cortex.label'
0102 brain_parm.FS_right_label_file = target_file;
0103 case 'lh.sphere.reg.asc'
0104 brain_parm.FS_left_sphere_file = target_file;
0105 case 'rh.sphere.reg.asc'
0106 brain_parm.FS_right_sphere_file = target_file;
0107 otherwise
0108 error('Unknown target file is found.');
0109 end
0110 num_found_files = num_found_files + 1;
0111 end