0001 function [V,F,xx,brain_parm] = vb_job_brain_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
0041 DEBUG_MODE=0;
0042
0043 proj_root = vb_rm_trailing_slash(proj_root);
0044 subj_mask = [proj_root filesep brain_parm.subj_mask];
0045 analyze_file = brain_parm.analyze_file;
0046
0047
0048 brain_file = [proj_root filesep brain_parm.brain_file];
0049 area_file = [proj_root filesep brain_parm.area_file ];
0050 act_file = [proj_root filesep brain_parm.act_file ];
0051
0052 [V, F, xx, Xcenter] = vb_make_smooth_cortex_surf(subj_mask,analyze_file,brain_parm);
0053
0054 msg = {'Cortical surface is plotted'; 'Is this OK ?'};
0055 str = questdlg(msg,'Check result','Yes', 'No','Yes');
0056 if strcmp(str,'No'), return; end;
0057
0058
0059 if DEBUG_MODE==2, return; end;
0060
0061
0062 [udir, fname] = fileparts(analyze_file);
0063 MRI_ID = fname;
0064
0065 [V,F,xx,Vinfo] = vb_get_cortex_info(V, F, xx, Xcenter);
0066
0067
0068
0069
0070 tic;
0071 fprintf('--- Search next-point index and distance ');
0072
0073 [xxD, xxF, xxT] = vb_next_distance( [F.F3L ; F.F3R], V );
0074
0075 fprintf('%f[sec]\n',toc);
0076
0077
0078
0079
0080 tic
0081
0082 [xxA] = vb_calc_patch_area(V, F.F3, xxT);
0083
0084 fprintf('%f[sec]\n',toc);
0085
0086 fprintf(['--- Save brain model \n']);
0087 fprintf(' filename = %s\n', brain_file );
0088
0089 vb_save([brain_file], 'F','V','xx','xxF','xxD','xxA',...
0090 'Vinfo','MRI_ID');
0091
0092
0093 Ndipole = Vinfo.Ndipole;
0094 Vindx = 1:Ndipole;
0095
0096
0097 act_new.key = 'Uniform';
0098 act_new.xxP = ones(Ndipole,1);
0099 act_new.comment = 'artificial data';
0100
0101 vb_add_act([act_file], act_new, MRI_ID, OFF);
0102
0103
0104 AreaNew.key = 'Cortex';
0105 AreaNew.Iextract = [1:Ndipole]';
0106
0107 vb_add_area([area_file], AreaNew, MRI_ID, OFF);
0108
0109 if DEBUG_MODE==1,
0110 figure;
0111 hist(xxA*1e6, 0:0.25:10);
0112 xlim([0 10])
0113 title('Histgram of patch area')
0114 xlabel('Area')
0115 return;
0116 end;
0117
0118
0119
0120
0121 if isfield(brain_parm,'R_max'),
0122 Rmax = brain_parm.R_max;
0123 else
0124 Rmax = 18e-3;
0125 end
0126 if isfield(brain_parm,'R_max'),
0127 Display = brain_parm.display;
0128 else
0129 Display = 200;
0130 end
0131
0132 [nextIX , nextDD] = vb_find_neighbor_all(Rmax, xxF, xxD, Vindx, Display);
0133
0134 vb_save([brain_file],'nextIX','nextDD');
0135
0136
0137
0138 vb_check_brain_model(proj_root,brain_parm);
0139
0140 figure;
0141 hist(vb_cell_merge(xxD)*1000,100);
0142 title('Histgram of Vertex distance [mm]')
0143
0144 proj_file_save(brain_parm);
0145
0146 return
0147
0148 function proj_file_save(brain_parm)
0149
0150 proj_file = get_project_filename;
0151
0152 if isempty(proj_file)
0153 return;
0154 end
0155
0156 project_file_mgr('load', proj_file);
0157 project_file_mgr('add', 'brain_parm', brain_parm);
0158
0159 return