Import FreeSurfer's sphere coordinate into cortical surface file. (VBMEG public function) FreeSurfer's cortical surface model has a (coregistered) sphere coordinate values at each vertex. This function is used to import the sphere coordinate values into an existing cortical surface file (.brain.mat). Struct variables 'Vall' will be added to the cortical surface model file (see [output]). [syntax] vb_job_brain_add_sphcoord(brain_parm) vb_job_brain_add_sphcoord(proj_root,brain_parm) [input] proj_root : <<string>> VBMEG project root directory. brain_parm: <<struct>> Parameters for import. --- fields of brain_parm brain_file: <<string>> Cortical surface model file (.brain.mat). Struct variable 'Vall' will be added to this file (see [output]). brain_sphL: <<string>> Sphere surface file (.sphere.reg(.asc)) corresponding to the left hemisphere of the source model. brain_sphR: <<string>> Sphere surface file (.sphere.reg(.asc)) corresponding to the right hemisphere of the source model. key : <<string>> Arbitrary ID of the coordinate value (e.g., 'Sphere_coreg'). It is used to load coordinate values by vb_load_cortex. --- [output] Struct variable 'Vall' will be added to brain_parm.brain_file. --- fields of Vall V : <<cell of matrix>> Spherical coordinate values. key: <<cell of string>> Used to get spherical coordinate values by vb_load_cortex. --- [example] You can add sphere coordinate values to existing cortical surface model file by the following code: >> brain_parm.brain_file = 'existing_brain_file'; % .brain.mat >> brain_parm.brain_sphL = 'lh.sphere.reg.asc'; >> brain_parm.brain_sphR = 'rh.sphere.reg.asc'; >> brain_parm.key = 'Sphere_coreg'; % arbitrary string available >> proj_root = 'your_project_root_directory'; >> vb_job_brain_add_sphcoord(proj_root,brain_parm); You can get the spherical coordinate values of the cortical surface model by the following code: >> V = vb_load_cortex('your_brain_file','Sphere_coreg'); [see also] @see vb_load_cortex.m [history] 2010-11-18 Taku Yoshioka 2010-12-22 taku-y [minor] Bug fix: 'proj_root' attached with directroies specified by 'brain_parm.brain_file'. Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function vb_job_brain_add_sphcoord(varargin) 0002 % Import FreeSurfer's sphere coordinate into cortical surface file. 0003 % (VBMEG public function) 0004 % 0005 % FreeSurfer's cortical surface model has a (coregistered) sphere 0006 % coordinate values at each vertex. This function is used to import the 0007 % sphere coordinate values into an existing cortical surface file 0008 % (.brain.mat). Struct variables 'Vall' will be added to the cortical 0009 % surface model file (see [output]). 0010 % 0011 % [syntax] 0012 % vb_job_brain_add_sphcoord(brain_parm) 0013 % vb_job_brain_add_sphcoord(proj_root,brain_parm) 0014 % 0015 % [input] 0016 % proj_root : <<string>> VBMEG project root directory. 0017 % brain_parm: <<struct>> Parameters for import. 0018 % --- fields of brain_parm 0019 % brain_file: <<string>> Cortical surface model file 0020 % (.brain.mat). Struct variable 'Vall' will be added to this 0021 % file (see [output]). 0022 % brain_sphL: <<string>> Sphere surface file (.sphere.reg(.asc)) 0023 % corresponding to the left hemisphere of the source 0024 % model. 0025 % brain_sphR: <<string>> Sphere surface file (.sphere.reg(.asc)) 0026 % corresponding to the right hemisphere of the source 0027 % model. 0028 % key : <<string>> Arbitrary ID of the coordinate value 0029 % (e.g., 'Sphere_coreg'). It is used to load coordinate 0030 % values by vb_load_cortex. 0031 % --- 0032 % 0033 % [output] 0034 % Struct variable 'Vall' will be added to brain_parm.brain_file. 0035 % --- fields of Vall 0036 % V : <<cell of matrix>> Spherical coordinate values. 0037 % key: <<cell of string>> Used to get spherical coordinate values by 0038 % vb_load_cortex. 0039 % --- 0040 % 0041 % [example] 0042 % You can add sphere coordinate values to existing cortical surface model 0043 % file by the following code: 0044 % 0045 % >> brain_parm.brain_file = 'existing_brain_file'; % .brain.mat 0046 % >> brain_parm.brain_sphL = 'lh.sphere.reg.asc'; 0047 % >> brain_parm.brain_sphR = 'rh.sphere.reg.asc'; 0048 % >> brain_parm.key = 'Sphere_coreg'; % arbitrary string available 0049 % >> proj_root = 'your_project_root_directory'; 0050 % >> vb_job_brain_add_sphcoord(proj_root,brain_parm); 0051 % 0052 % You can get the spherical coordinate values of the cortical surface 0053 % model by the following code: 0054 % 0055 % >> V = vb_load_cortex('your_brain_file','Sphere_coreg'); 0056 % 0057 % [see also] 0058 % @see vb_load_cortex.m 0059 % 0060 % [history] 0061 % 2010-11-18 Taku Yoshioka 0062 % 2010-12-22 taku-y 0063 % [minor] Bug fix: 'proj_root' attached with directroies specified by 0064 % 'brain_parm.brain_file'. 0065 % 0066 % Copyright (C) 2011, ATR All Rights Reserved. 0067 % License : New BSD License(see VBMEG_LICENSE.txt) 0068 0069 % 0070 % check input arguments 0071 % 0072 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0073 if length(varargin) == 1 0074 proj_root = []; 0075 brain_parm = varargin{1}; 0076 elseif length(varargin) == 2 0077 proj_root = varargin{1}; 0078 brain_parm = varargin{2}; 0079 else 0080 error('Error: invalid usage of vb_job_brain_sphcoord.'); 0081 end; 0082 0083 if ~isempty(proj_root), 0084 proj_root = vb_rm_trailing_slash(proj_root); 0085 end; 0086 0087 % 0088 % Make absolute path 0089 % 0090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0091 brain_parm_abs = brain_parm; 0092 brain_parm_abs.brain_file = [proj_root filesep brain_parm.brain_file]; 0093 0094 % 0095 % Verbose level 0096 % 0097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0098 global vbmeg_inst 0099 verbose_const = vb_define_verbose; 0100 0101 if isempty(vbmeg_inst) | ~isfield(vbmeg_inst,'verbose_level'), 0102 verbose_level = verbose_const.VERBOSE_LEVEL_NOTICE; 0103 else 0104 verbose_level = vbmeg_inst.verbose_level; 0105 end; 0106 0107 % 0108 % Load coordinate values 0109 % 0110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0111 [tmp1,tmp2,ix_V_org] = vb_load_cortex_info(brain_parm_abs.brain_file); 0112 VL0 = vb_fs_load_surface(brain_parm_abs.brain_sphL); 0113 VR0 = vb_fs_load_surface(brain_parm_abs.brain_sphR); 0114 VL = VL0(ix_V_org.Left,:); 0115 VR = VR0(ix_V_org.Right-size(VL0,1),:); 0116 V = [VL; VR]; 0117 0118 % 0119 % Add coordinate values 0120 % 0121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0122 S = load(brain_parm_abs.brain_file); 0123 if isfield(S,'Vall'), 0124 Vall = S.Vall; 0125 else 0126 Vall.V = cell(0); 0127 Vall.key = cell(0); 0128 end; 0129 0130 flag = true; 0131 for i=1:length(Vall.key) 0132 if strcmp(Vall.key{i},brain_parm_abs.key), 0133 flag = false; 0134 if verbose_level>=verbose_const.VERBOSE_LEVEL_NOTICE, 0135 msg = ['Brain coordinate ID ''' brain_parm_abs.key ... 0136 ''' is already used. Overwrite ?']; 0137 str = questdlg(msg,'Brain coordinate registration','Yes', ... 0138 'Cancel','Cancel'); 0139 if strcmp(str,'Yes') 0140 Vall.V{i} = V; 0141 h = msgbox(['Brain coordinate ID ''' brain_parm_abs.key ... 0142 ''' was overwritten.']); 0143 uiwait(h); 0144 end; 0145 else 0146 vb_disp(['Brain coordinate ID ''' brain_parm_abs.key ... 0147 ''' is already ' ... 0148 'used, so it was overwritten with new data. '], ... 0149 verbose_const.VERBOSE_LEVEL_WARNING); 0150 Vall.V{i} = V; 0151 end; 0152 end; 0153 end; 0154 0155 if flag, 0156 Vall.V{length(Vall.key)+1} = V; 0157 Vall.key{length(Vall.key)+1} = brain_parm_abs.key; 0158 end; 0159 0160 vb_save(brain_parm_abs.brain_file,'Vall'); 0161 0162 % 0163 % project_file save 0164 % 0165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0166 proj_file = get_project_filename; 0167 if isempty(proj_file) 0168 return; 0169 end; 0170 0171 project_file_mgr('load', proj_file); 0172 project_file_mgr('add', 'brain_parm', brain_parm); 0173 0174 return;