0001 function job_edit_act(brainfile,actfile)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 if nargin<2, actfile = []; end
0023 if nargin<1, brainfile = []; end
0024
0025 inst_id = create_instance;
0026 if isempty(inst_id), return; end;
0027
0028
0029
0030
0031
0032 create_GUI(inst_id,brainfile,actfile);
0033 job_edit_act_update_spatialpattern(inst_id);
0034
0035
0036
0037
0038
0039 function inst_id = create_instance
0040
0041
0042
0043
0044
0045
0046
0047
0048 global vbmeg_inst
0049
0050 if isfield(vbmeg_inst,'editact'),
0051 for inst_id=1:vbmeg_inst.const.EDITACT_MAX
0052 if isempty(vbmeg_inst.editact{inst_id}), return; end;
0053 end
0054 fprintf(['The number of instances of ''job_edit_act''' ...
0055 ' GUIs reaches the maximum number.\n']);
0056 inst_id = [];
0057 elseif isfield(vbmeg_inst,'const'),
0058 vbmeg_inst.editact = cell(vbmeg_inst.const.EDITACT_MAX,1);
0059 inst_id = 1;
0060 else
0061 fprintf(['''vbmeg_inst'' was not correct. You have to invoke' ...
0062 '''vbmeg'' to create an instance of VBMEG.\n']);
0063 inst_id = [];
0064 end
0065
0066 function create_GUI(inst_id,brainfile,actfile)
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077 global vbmeg_inst;
0078
0079
0080
0081
0082
0083
0084
0085 editact.brainfile = [];
0086 editact.V = [];
0087 editact.Vinf = [];
0088 editact.F = [];
0089 editact.inf_C = [];
0090 editact.Vtal = [];
0091 editact.Vmni = [];
0092 editact.nextDD = [];
0093 editact.nextID = [];
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117 editact.actfile = [];
0118 editact.xxP = [];
0119
0120
0121 editact.ix = [];
0122
0123
0124
0125
0126
0127
0128
0129
0130 h_fig = open('job_edit_act.fig');
0131 set(h_fig,'HandleVisibility','on');
0132 drawnow;
0133 set(h_fig,'Pointer','watch');
0134
0135
0136
0137
0138
0139 editact.h_fig = h_fig;
0140 editact.h_space = get_child_handle(h_fig,'axes1');
0141 editact.h_cbar = get_child_handle(h_fig,'colorbar');
0142 editact.ed2 = get_child_handle(h_fig,'radius');
0143 editact.ed4 = get_child_handle(h_fig,'tal_coord');
0144 editact.ed5 = get_child_handle(h_fig,'vertex_index');
0145 editact.ed6 = get_child_handle(h_fig,'color_scale');
0146 editact.lb1 = get_child_handle(h_fig,'activity_map_list');
0147 editact.pb1 = get_child_handle(h_fig,'rotation');
0148 editact.pb2 = get_child_handle(h_fig,'clear');
0149 editact.pb3 = get_child_handle(h_fig,'average');
0150 editact.pb4 = get_child_handle(h_fig,'maximum');
0151 editact.pb5 = get_child_handle(h_fig,'histogram');
0152 editact.pb6 = get_child_handle(h_fig,'gaussian');
0153 editact.pb7 = get_child_handle(h_fig,'step_function');
0154 editact.pb8 = get_child_handle(h_fig,'registration');
0155 editact.pb9 = get_child_handle(h_fig,'delete');
0156 editact.pb11 = get_child_handle(h_fig,'normalize');
0157 editact.pb12 = get_child_handle(h_fig,'undo');
0158 editact.pb13 = get_child_handle(h_fig,'print');
0159 editact.pb14 = get_child_handle(h_fig,'vertex');
0160 editact.pb15 = get_child_handle(h_fig,'replace');
0161 editact.pb16 = get_child_handle(h_fig,'left_button');
0162 editact.pb17 = get_child_handle(h_fig,'right_button');
0163 editact.pb18 = get_child_handle(h_fig,'top_button');
0164 editact.pb19 = get_child_handle(h_fig,'bottom_button');
0165 editact.cb1 = get_child_handle(h_fig,'left_hemi');
0166 editact.cb2 = get_child_handle(h_fig,'right_hemi');
0167 editact.rb1 = get_child_handle(h_fig,'talairach');
0168 editact.rb2 = get_child_handle(h_fig,'mni');
0169 editact.model_type_inflate_rb = get_child_handle(h_fig,'inflate');
0170 editact.model_type_fold_rb = get_child_handle(h_fig,'folded');
0171 editact.load_cortex_menu ...
0172 = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0173 'load_cortex_menu');
0174 editact.load_actmap_menu ...
0175 = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0176 'load_actmap_menu');
0177 editact.loaded_files_menu ...
0178 = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0179 'loaded_files_menu');
0180 editact.close_menu ...
0181 = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0182 'close_menu');
0183
0184 set(editact.ed2,'String','6');
0185 set(editact.lb1,'Value',1);
0186
0187 editact.plot_parm = vb_set_plot_parm;
0188 editact.plot_parm.index = [];
0189 editact.plot_parm.LRflag = 'LR';
0190
0191
0192 set(editact.h_space,'XTick',[],'YTick',[]);
0193 set(editact.h_cbar,'XTick',[],'YTick',[]);
0194
0195
0196
0197
0198
0199 inst_str = num2str(inst_id);
0200 editact_str = ['vbmeg_inst.editact{' inst_str '}'];
0201
0202
0203 command = ['global vbmeg_inst; '...
0204 'vbmeg_inst.editact{' inst_str '}=[];'];
0205 set(h_fig,'DeleteFcn',command);
0206
0207
0208 command = ['job_edit_act_change_radius(' inst_str ');'];
0209 set(editact.ed2,'Callback',command);
0210
0211
0212 command = ['job_edit_act_change_vertex(' inst_str ');'];
0213 set(editact.ed5,'Callback',command);
0214
0215
0216 command = ['job_edit_act_push_rotate_button(' inst_str ');'];
0217 set(editact.pb1,'Callback',command);
0218
0219
0220 command = ['job_edit_act_clear(' inst_str ');'];
0221 set(editact.pb2,'Callback',command);
0222
0223
0224 command = ['job_edit_act_replace(' inst_str ');'];
0225 set(editact.pb15,'Callback',command);
0226
0227
0228 command = ['job_edit_act_average(' inst_str ');'];
0229 set(editact.pb3,'Callback',command);
0230
0231
0232 command = ['job_edit_act_maximum(' inst_str ');'];
0233 set(editact.pb4,'Callback',command);
0234
0235
0236 command = ['job_edit_act_plot_histogram(' inst_str ');'];
0237 set(editact.pb5,'Callback',command);
0238
0239
0240 command = ['job_edit_act_gauss_filter(' inst_str ');'];
0241 set(editact.pb6,'Callback',command);
0242
0243
0244 command = ['job_edit_act_step_filter(' inst_str ');'];
0245 set(editact.pb7,'Callback',command);
0246
0247
0248 command = ['job_edit_act_registration(' inst_str ');'];
0249 set(editact.pb8,'Callback',command);
0250
0251
0252 command = ['job_edit_act_delete(' inst_str ');'];
0253 set(editact.pb9,'Callback',command);
0254
0255
0256 command = ['job_edit_act_normalize(' inst_str ');'];
0257 set(editact.pb11,'Callback',command);
0258
0259
0260 command = ['job_edit_act_undo(' inst_str ');'];
0261 set(editact.pb12,'Callback',command);
0262
0263
0264 command = ['job_edit_act_print_spatialpattern(' inst_str ');'];
0265 set(editact.pb13,'Callback',command);
0266
0267
0268 command = ['job_edit_act_select_vertex(' inst_str ');'];
0269 set(editact.pb14,'Callback',command);
0270
0271
0272 command = ['job_edit_act_change_hemi(' inst_str ');'];
0273 set(editact.cb1,'Callback',command);
0274 set(editact.cb2,'Callback',command);
0275
0276
0277 model_type_group = [editact.model_type_inflate_rb,
0278 editact.model_type_fold_rb];
0279 command = ['job_edit_act_change_modeltype(' inst_str ');'];
0280 set(model_type_group, 'Callback', command);
0281 set(model_type_group, 'Value', 0);
0282 set(editact.model_type_inflate_rb,'Value',1);
0283
0284
0285 command = ['[brain_dir,brain_file] = vb_file_select' ...
0286 '({''.brain.mat''},''Load cortical model'');' ...
0287 'if ~isempty(brain_file), ' ...
0288 'job_edit_act_load_cortex(' inst_str ',' ...
0289 '[brain_dir filesep brain_file{1}]); end'];
0290 set(editact.load_cortex_menu, 'Callback', command);
0291
0292
0293 command = ['[act_dir,act_file] = vb_file_select' ...
0294 '({''.act.mat''},''Load activity map file'');' ...
0295 'if ~isempty(act_file), ' ...
0296 'job_edit_act_load_actfile(' inst_str ',' ...
0297 '[act_dir filesep act_file{1}]); end'];
0298 set(editact.load_actmap_menu, 'Callback', command);
0299
0300
0301
0302
0303 command = ['job_edit_act_show_loaded_files(' inst_str ');'];
0304 set(editact.loaded_files_menu, 'Callback', command);
0305
0306
0307 command = 'close';
0308 set(editact.close_menu,'Callback',command);
0309
0310
0311 command = ['job_edit_act_change_angle(' inst_str ',''left'');'];
0312 set(editact.pb16,'Callback',command);
0313 command = ['job_edit_act_change_angle(' inst_str ',''right'');'];
0314 set(editact.pb17,'Callback',command);
0315 command = ['job_edit_act_change_angle(' inst_str ',''top'');'];
0316 set(editact.pb18,'Callback',command);
0317 command = ['job_edit_act_change_angle(' inst_str ',''bottom'');'];
0318 set(editact.pb19,'Callback',command);
0319
0320
0321 command = ['job_edit_act_change_tal(' inst_str ');'];
0322 set(editact.rb1,'Callback',command);
0323 command = ['job_edit_act_change_mni(' inst_str ');'];
0324 set(editact.rb2,'Callback',command);
0325
0326
0327 command = ['job_edit_act_change_color_scale(' inst_str ');'];
0328 set(editact.ed6,'Callback',command);
0329
0330
0331
0332
0333
0334 set(h_fig,'Renderer','zbuffer');
0335
0336
0337
0338
0339
0340 vbmeg_inst.editact{inst_id} = editact;
0341
0342
0343 set(h_fig,'Pointer','arrow');
0344
0345
0346
0347
0348
0349 if ~isempty(brainfile),
0350 job_edit_act_load_cortex(inst_id,brainfile);
0351 end
0352
0353
0354
0355
0356
0357 if ~isempty(actfile),
0358 job_edit_act_load_actfile(inst_id,actfile);
0359 end