0001 function [V,F,xx] = vb_job_brain_model_std2sbj(proj_root,brain_parm)
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
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 DEBUG_MODE=0;
0041
0042 proj_root = vb_rm_trailing_slash(proj_root);
0043
0044 std_brain = brain_parm.std_brain;
0045 snfile = brain_parm.spm_normalization_file;
0046 analyze_file = brain_parm.analyze_file;
0047
0048
0049 brain_file = [proj_root filesep brain_parm.brain_file];
0050 area_file = [proj_root filesep brain_parm.area_file ];
0051 act_file = [proj_root filesep brain_parm.act_file ];
0052
0053
0054 [udir, fname] = fileparts(analyze_file);
0055 MRI_ID = fname;
0056
0057 [V,F,xx,Vinfo,Vindx] = vb_get_cortex_surf_from_std(std_brain,snfile);
0058
0059
0060 if DEBUG_MODE==2, return; end;
0061
0062
0063
0064
0065 fprintf('--- Search next-point index and distance ');
0066
0067 [xxD, xxF, xxT] = vb_next_distance( [F.F3L ; F.F3R], V );
0068
0069
0070
0071
0072
0073 [xxA] = vb_calc_patch_area(V, F.F3, xxT);
0074
0075 fprintf(['--- Save brain model \n']);
0076 fprintf(' filename = %s\n', brain_file );
0077
0078
0079 Vmni = vb_load_cortex(std_brain);
0080 Vmni = Vmni(Vindx,:);
0081
0082 Vtal = mni2tal(Vmni);
0083
0084
0085 [Vinflate,Ft,xxt,inf_C]= vb_load_cortex(std_brain, 'Inflate');
0086 Vinflate = Vinflate(Vindx,:);
0087 inf_C = inf_C(Vindx,:);
0088
0089 vb_save([brain_file], 'F','V','xx','xxF','xxD','xxA',...
0090 'Vmni','Vtal','Vinflate','inf_C','Vinfo','MRI_ID');
0091
0092
0093 EXT_brain = '.brain.mat';
0094 std_id = std_brain(1:findstr(std_brain,EXT_brain)-1);
0095
0096 std_act_aal = [std_id '_aal.act.mat'];
0097 std_act_brd = [std_id '_brodmann.act.mat'];
0098 std_area_aal = [std_id '_aal.area.mat'];
0099 std_area_brd = [std_id '_brodmann.area.mat'];
0100
0101 brain_id = brain_file(1:findstr(brain_file,EXT_brain)-1);
0102
0103 save_act_aal = [brain_id '_aal.act.mat'];
0104 save_act_brd = [brain_id '_brodmann.act.mat'];
0105 save_area_aal = [brain_id '_aal.area.mat'];
0106 save_area_brd = [brain_id '_brodmann.area.mat'];
0107
0108 if exist(std_act_aal,'file'), copyfile(std_act_aal,save_act_aal);end;
0109 if exist(std_act_brd,'file'), copyfile(std_act_brd,save_act_brd);end;
0110 if exist(std_area_aal,'file'), copyfile(std_area_aal,save_area_aal);end;
0111 if exist(std_area_brd,'file'), copyfile(std_area_brd,save_area_brd);end;
0112
0113
0114 Ndipole = Vinfo.Ndipole;
0115 Vindx = 1:Ndipole;
0116
0117
0118 act_new.key = 'Uniform';
0119 act_new.xxP = ones(Ndipole,1);
0120 act_new.comment = 'artificial data';
0121
0122 vb_add_act([act_file], act_new, MRI_ID, OFF);
0123
0124
0125 AreaNew.key = 'Cortex';
0126 AreaNew.Iextract = [1:Ndipole]';
0127
0128 vb_add_area([area_file], AreaNew, MRI_ID, OFF);
0129
0130 if DEBUG_MODE==1,
0131 figure;
0132 hist(xxA*1e6, 0:0.25:10);
0133 xlim([0 10])
0134 title('Histgram of patch area')
0135 xlabel('Area')
0136 return;
0137 end;
0138
0139
0140
0141
0142 if isfield(brain_parm,'R_max'),
0143 Rmax = brain_parm.R_max;
0144 else
0145 Rmax = 18e-3;
0146 end
0147 if isfield(brain_parm,'R_max'),
0148 Display = brain_parm.display;
0149 else
0150 Display = 200;
0151 end
0152
0153 [nextIX , nextDD] = vb_find_neighbor_all(Rmax, xxF, xxD, Vindx, Display);
0154
0155 vb_save([brain_file],'nextIX','nextDD');
0156
0157
0158
0159 vb_check_brain_model(proj_root,brain_parm);
0160
0161 figure;
0162 hist(vb_cell_merge(xxD)*1000,100);
0163 title('Histgram of Vertex distance [mm]')
0164
0165 proj_file_save(brain_parm);
0166
0167 return
0168
0169 function proj_file_save(brain_parm)
0170
0171 proj_file = get_project_filename;
0172
0173 if isempty(proj_file)
0174 return;
0175 end
0176
0177 project_file_mgr('load', proj_file);
0178 project_file_mgr('add', 'brain_parm', brain_parm);
0179
0180 return