Add MNI and Talairach coordinate value to Cortical model file. [USAGE] vb_job_brain_add_mni_tal_coord(proj_root, brain_parm[,disp_flag]); [IN] proj_root : VBMEG project root directory. brain_parm : <<struct>> parameters for add. .brain_file : Cortical surface model file (.brain.mat) relative path from proj_root. MNI and Talairach information will be saved. .spm_normalization_file : SPM normalization file (_sn.mat) .FS_right_sphere_file : FreeSurfer sphere file (.sphere.reg.asc) corresponding to the right hemisphere of the source model. .FS_left_sphere_file : FreeSurfer sphere file (.sphere.reg.asc) corresponding to the left hemisphere of the source model. .FS_sphere_key : <<optional>> default: 'sphere.reg' A registration key to Cortical model file. Sphere coordinate value can be loaded as below. vb_load_cortex(brain_file, FS_sphere_key); disp_flag : =true : plot result. [default] =false : Do not plot result. case1: If you want to use SPM normalization file to transform coordinate system, please specify .spm_normalization_file. case2: If you want to use FreeSurfer sphere file to transform coordinate system, please specify .FS_right_sphere_file. and .FS_right_sphere_file. [OUT] none [example] <<spm case>> proj_root = '/home/foo/brain'; brain_parm.brain_file = 'foo.brain.mat'; % target: /home/foo/brain/foo.brain.mat brain_parm.spm_normalization_file = '/home/foo/foo_sn.mat'; vb_job_brain_add_mni_tal_coord(proj_root, brain_parm); <<FS sphere file case>> proj_root = '/home/foo/brain'; brain_parm.brain_file = 'foo.brain.mat'; % target: /home/foo/brain/foo.brain.mat brain_parm.FS_right_sphere_file = '/home/foo/FS/bem/rh.sphere.reg.asc'; brain_parm.FS_left_sphere_file = '/home/foo/FS/bem/lh.sphere.reg.asc'; brain_parm.FS_sphere_key = 'sphere.reg'; vb_job_brain_add_mni_tal_coord(proj_root, brain_parm); [HISTORY] 2013-01-04 rhayashi Initial version. Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function vb_job_brain_add_mni_tal_coord(proj_root, brain_parm, disp_flag) 0002 % Add MNI and Talairach coordinate value to Cortical model file. 0003 % [USAGE] 0004 % vb_job_brain_add_mni_tal_coord(proj_root, brain_parm[,disp_flag]); 0005 % [IN] 0006 % proj_root : VBMEG project root directory. 0007 % brain_parm : <<struct>> parameters for add. 0008 % .brain_file : Cortical surface model file (.brain.mat) 0009 % relative path from proj_root. 0010 % MNI and Talairach information will be saved. 0011 % 0012 % .spm_normalization_file : SPM normalization file (_sn.mat) 0013 % 0014 % .FS_right_sphere_file : FreeSurfer sphere file (.sphere.reg.asc) 0015 % corresponding to the right hemisphere of 0016 % the source model. 0017 % .FS_left_sphere_file : FreeSurfer sphere file (.sphere.reg.asc) 0018 % corresponding to the left hemisphere of 0019 % the source model. 0020 % .FS_sphere_key : <<optional>> default: 'sphere.reg' 0021 % A registration key to Cortical model file. 0022 % Sphere coordinate value can be loaded as below. 0023 % vb_load_cortex(brain_file, FS_sphere_key); 0024 % disp_flag : =true : plot result. [default] 0025 % =false : Do not plot result. 0026 % 0027 % case1: If you want to use SPM normalization file to transform coordinate system, 0028 % please specify .spm_normalization_file. 0029 % case2: If you want to use FreeSurfer sphere file to transform coordinate system, 0030 % please specify .FS_right_sphere_file. and .FS_right_sphere_file. 0031 % 0032 % [OUT] 0033 % none 0034 % 0035 % [example] 0036 % <<spm case>> 0037 % proj_root = '/home/foo/brain'; 0038 % brain_parm.brain_file = 'foo.brain.mat'; % target: /home/foo/brain/foo.brain.mat 0039 % brain_parm.spm_normalization_file = '/home/foo/foo_sn.mat'; 0040 % vb_job_brain_add_mni_tal_coord(proj_root, brain_parm); 0041 % 0042 % <<FS sphere file case>> 0043 % proj_root = '/home/foo/brain'; 0044 % brain_parm.brain_file = 'foo.brain.mat'; % target: /home/foo/brain/foo.brain.mat 0045 % brain_parm.FS_right_sphere_file = '/home/foo/FS/bem/rh.sphere.reg.asc'; 0046 % brain_parm.FS_left_sphere_file = '/home/foo/FS/bem/lh.sphere.reg.asc'; 0047 % brain_parm.FS_sphere_key = 'sphere.reg'; 0048 % vb_job_brain_add_mni_tal_coord(proj_root, brain_parm); 0049 % 0050 % [HISTORY] 0051 % 2013-01-04 rhayashi Initial version. 0052 % 0053 % Copyright (C) 2011, ATR All Rights Reserved. 0054 % License : New BSD License(see VBMEG_LICENSE.txt) 0055 0056 % 0057 % --- Previous check 0058 % 0059 if ~exist('proj_root', 'var') 0060 error('proj_root is a required parameter.'); 0061 end 0062 if ~exist('brain_parm', 'var') 0063 error('brain_parm is a required parameter.'); 0064 end 0065 if ~exist('disp_flag', 'var') 0066 disp_flag = true; 0067 end 0068 0069 % field check 0070 case_num = 0; 0071 if isfield(brain_parm, 'spm_normalization_file') && ~isempty(brain_parm.spm_normalization_file) 0072 vb_disp('Extract MNI coordinate value using SPM normalise result.'); 0073 case_num = 1; 0074 elseif isfield(brain_parm, 'FS_right_sphere_file') && isfield(brain_parm, 'FS_left_sphere_file') 0075 vb_disp('Extract MNI coordinate value using FreeSurfer sphere registration file.'); 0076 case_num = 2; 0077 else 0078 error('Please specify appropriate field(s).'); 0079 end 0080 0081 % 0082 % --- Main Procedure 0083 % 0084 proj_root = vb_rm_trailing_slash(proj_root); 0085 0086 switch(case_num) 0087 case 1 0088 inner_spm_case(proj_root, brain_parm); 0089 case 2 0090 inner_FS_case(proj_root, brain_parm); 0091 otherwise 0092 error('Unknown method was specified.'); 0093 end 0094 if disp_flag 0095 vb_check_mni_coregistration(fullfile(proj_root, brain_parm.brain_file)); 0096 end 0097 0098 function inner_spm_case(proj_root, brain_parm) 0099 % Calculate MNI and Talairach coordinate from SPM normalization file 0100 % and save them into Cortical surface model file(.brain.mat). 0101 % [USAGE] 0102 % inner_spm_case(proj_root, brain_parm); 0103 % [IN] 0104 % proj_root : VBMEG project root directory. 0105 % brain_parm : <<struct>> parameters for add. 0106 % .brain_file : Cortical surface model file (.brain.mat) 0107 % relative path from proj_root. 0108 % MNI and Talairach information will be saved. 0109 % 0110 % .spm_normalization_file : SPM normalization file (_sn.mat) 0111 % 0112 const = vb_define_verbose; 0113 VERBOSE_LEVEL_NOTICE = const.VERBOSE_LEVEL_NOTICE; 0114 global vbmeg_inst; 0115 0116 %% MNI coordinate 0117 tic 0118 vb_disp(sprintf('-- Computing MNI and Talairach coordinate '), ... 0119 VERBOSE_LEVEL_NOTICE); 0120 0121 brain_file = fullfile(proj_root, brain_parm.brain_file); 0122 brain_file = strrep(brain_file, '\', '/'); 0123 0124 mniparm.mask_file = vbmeg_inst.const.FILE_MNI_BETMASK_IMG; % fixed 0125 mniparm.brainfile = brain_file; 0126 mniparm.snfile = brain_parm.spm_normalization_file; 0127 0128 [Vmni, Vtal, derr, IMGinfo, pXYZmni0] = vb_calc_mni_coord(mniparm); 0129 0130 vb_save(brain_file, 'Vmni','Vtal','derr'); 0131 vb_disp_nonl(sprintf('Done...%f[sec]\n\n',toc), VERBOSE_LEVEL_NOTICE); 0132 0133 function inner_FS_case(proj_root, brain_parm) 0134 % Calculate MNI and Talairach coordinate from FS spherefile 0135 % and save them into Cortical surface model file(.brain.mat). 0136 % [USAGE] 0137 % inner_FS_case(proj_root, brain_parm); 0138 % [IN] 0139 % proj_root : VBMEG project root directory. 0140 % brain_parm : <<struct>> parameters for add. 0141 % .brain_file : Cortical surface model file (.brain.mat) 0142 % relative path from proj_root. 0143 % MNI and Talairach information will be saved. 0144 % .FS_right_sphere_file : FreeSurfer sphere file (.sphere.reg.asc) 0145 % corresponding to the right hemisphere of 0146 % the source model. 0147 % .FS_left_sphere_file : FreeSurfer sphere file (.sphere.reg.asc) 0148 % corresponding to the left hemisphere of 0149 % the source model. 0150 % .FS_sphere_key : A registration key to Cortical model file. 0151 % Sphere coordinate value can be loaded as below. 0152 % vb_load_cortex(brain_file, FS_sphere_key); 0153 % 0154 const = vb_define_verbose; 0155 VERBOSE_LEVEL_NOTICE = const.VERBOSE_LEVEL_NOTICE; 0156 tic 0157 vb_disp(sprintf('-- Computing MNI and Talairach coordinate '), ... 0158 VERBOSE_LEVEL_NOTICE); 0159 0160 brain_file = fullfile(proj_root, brain_parm.brain_file); 0161 brain_file = strrep(brain_file, '\', '/'); 0162 0163 mniparm.brain_file = brain_file; 0164 mniparm.FS_right_sphere_file = brain_parm.FS_right_sphere_file; 0165 mniparm.FS_left_sphere_file = brain_parm.FS_left_sphere_file; 0166 if ~isfield(mniparm, 'FS_sphere_key') || isempty(mniparm.FS_sphere_key) 0167 mniparm.FS_sphere_key = 'sphere.reg'; 0168 end 0169 [Vmni, Vtal] = vb_calc_mni_coord_fs(mniparm); 0170 0171 vb_save(brain_file, 'Vmni','Vtal'); 0172 vb_disp_nonl(sprintf('Done...%f[sec]\n\n',toc), VERBOSE_LEVEL_NOTICE);