Home > vbmeg > functions > job > subdirectory > vb_job_brain_add_sphcoord.m

vb_job_brain_add_sphcoord

PURPOSE ^

Import FreeSurfer's sphere coordinate into cortical surface file.

SYNOPSIS ^

function vb_job_brain_add_sphcoord(varargin)

DESCRIPTION ^

 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'.
 2015-11-26 Masa-aki Sato
  [change] original spherical coordinate is saved to Vall

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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 % 2015-11-26 Masa-aki Sato
0066 %  [change] original spherical coordinate is saved to Vall
0067 %
0068 % Copyright (C) 2011, ATR All Rights Reserved.
0069 % License : New BSD License(see VBMEG_LICENSE.txt)
0070 
0071 %
0072 % check input arguments
0073 %
0074 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0075 if length(varargin) == 1
0076   proj_root = [];
0077   brain_parm = varargin{1};
0078 elseif length(varargin) == 2
0079   proj_root = varargin{1};
0080   brain_parm = varargin{2};
0081 else
0082   error('Error: invalid usage of vb_job_brain_sphcoord.');
0083 end;
0084 
0085 if ~isempty(proj_root), 
0086   proj_root = vb_rm_trailing_slash(proj_root);
0087 end;
0088 
0089 %
0090 % Make absolute path
0091 %
0092 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0093 brain_parm_abs = brain_parm;
0094 
0095 if isempty(proj_root)
0096     brain_parm_abs.brain_file = [brain_parm.brain_file];
0097 else
0098     brain_parm_abs.brain_file = [proj_root filesep brain_parm.brain_file];
0099 end
0100 %
0101 % Verbose level
0102 %
0103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0104 global vbmeg_inst
0105 verbose_const = vb_define_verbose; 
0106 
0107 if isempty(vbmeg_inst) | ~isfield(vbmeg_inst,'verbose_level'), 
0108   verbose_level = verbose_const.VERBOSE_LEVEL_NOTICE;
0109 else
0110   verbose_level = vbmeg_inst.verbose_level;
0111 end;
0112 
0113 %
0114 % Load coordinate values
0115 %
0116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0117 [tmp1,tmp2,ix_V_org] = vb_load_cortex_info(brain_parm_abs.brain_file);
0118 
0119 VL0 = vb_fs_load_surface(brain_parm_abs.brain_sphL);
0120 VR0 = vb_fs_load_surface(brain_parm_abs.brain_sphR);
0121 
0122 %  [change] original spherical coordinate is saved to Vall
0123 V0  = [VL0; VR0];
0124 
0125 %  spherical coordinate corresponding to cortical vertex
0126 VL  = VL0(ix_V_org.Left,:);
0127 VR  = VR0(ix_V_org.Right-size(VL0,1),:);
0128 
0129 V   = [VL; VR];
0130 %
0131 % Add coordinate values
0132 %
0133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0134 S = load(brain_parm_abs.brain_file);
0135 if isfield(S,'Vall'), 
0136   Vall = S.Vall;
0137 else
0138   Vall.V = cell(0);
0139   Vall.key = cell(0);
0140 end;
0141 
0142 flag = true;
0143 flag_org = true;
0144 
0145 for i=1:length(Vall.key)
0146   if strcmp(Vall.key{i},brain_parm_abs.key), 
0147      flag = false;
0148      Vall.V{i} = V;
0149 %    if verbose_level>=verbose_const.VERBOSE_LEVEL_NOTICE,
0150 %      msg = ['Brain coordinate ID ''' brain_parm_abs.key ...
0151 %             ''' is already used. Overwrite ?'];
0152 %      str = questdlg(msg,'Brain coordinate registration','Yes', ...
0153 %             'Cancel','Cancel');
0154 %      if strcmp(str,'Yes')
0155 %    Vall.V{i} = V;
0156 %    h = msgbox(['Brain coordinate ID ''' brain_parm_abs.key ...
0157 %            ''' was overwritten.']);
0158 %    uiwait(h);
0159 %      end;
0160 %    else
0161       vb_disp(['Brain coordinate ID ''' brain_parm_abs.key ...
0162                ''' is already ' ...
0163                'used, so it was overwritten with new data. '], ...
0164               verbose_const.VERBOSE_LEVEL_WARNING); 
0165 %      Vall.V{i} = V;
0166 %    end;
0167   end;
0168   
0169   if strcmp(Vall.key{i},'orig_sphere'), 
0170     flag_org = false;
0171   end
0172 end;
0173 
0174 if flag_org, 
0175   Vall.V{length(Vall.key)+1} = V0;
0176   Vall.key{length(Vall.key)+1} = 'orig_sphere';
0177 end;
0178 
0179 if flag, 
0180   Vall.V{length(Vall.key)+1} = V;
0181   Vall.key{length(Vall.key)+1} = brain_parm_abs.key;
0182 end;
0183 
0184 vb_save(brain_parm_abs.brain_file,'Vall');
0185 
0186 %
0187 % project_file save
0188 %
0189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0190 % proj_file = get_project_filename;
0191 % if isempty(proj_file)
0192 %   return;
0193 % end;
0194 %
0195 % project_file_mgr('load', proj_file);
0196 % project_file_mgr('add', 'brain_parm', brain_parm);
0197 %
0198 % return;

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005