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 editact.actfile = [];
0097 editact.xxP = [];
0098
0099
0100 editact.ix = [];
0101
0102
0103
0104
0105
0106
0107
0108
0109 h_fig = open('job_edit_act.fig');
0110 set(h_fig,'HandleVisibility','on');
0111 drawnow;
0112 set(h_fig,'Pointer','watch');
0113
0114
0115
0116
0117
0118 editact.h_fig = h_fig;
0119 editact.h_space = get_child_handle(h_fig,'axes1');
0120 editact.h_cbar = get_child_handle(h_fig,'colorbar');
0121 editact.ed2 = get_child_handle(h_fig,'radius');
0122 editact.ed4 = get_child_handle(h_fig,'tal_coord');
0123 editact.ed5 = get_child_handle(h_fig,'vertex_index');
0124 editact.ed6 = get_child_handle(h_fig,'color_scale');
0125 editact.lb1 = get_child_handle(h_fig,'activity_map_list');
0126 editact.pb2 = get_child_handle(h_fig,'clear');
0127 editact.pb3 = get_child_handle(h_fig,'average');
0128 editact.pb4 = get_child_handle(h_fig,'maximum');
0129 editact.pb5 = get_child_handle(h_fig,'histogram');
0130 editact.pb6 = get_child_handle(h_fig,'gaussian');
0131 editact.pb7 = get_child_handle(h_fig,'step_function');
0132 editact.pb8 = get_child_handle(h_fig,'registration');
0133 editact.pb9 = get_child_handle(h_fig,'delete');
0134 editact.pb11 = get_child_handle(h_fig,'normalize');
0135 editact.pb12 = get_child_handle(h_fig,'undo');
0136 editact.pb13 = get_child_handle(h_fig,'print');
0137 editact.pb15 = get_child_handle(h_fig,'replace');
0138 editact.pb16 = get_child_handle(h_fig,'left_button');
0139 editact.pb17 = get_child_handle(h_fig,'right_button');
0140 editact.pb18 = get_child_handle(h_fig,'top_button');
0141 editact.pb19 = get_child_handle(h_fig,'bottom_button');
0142 editact.cb1 = get_child_handle(h_fig,'left_hemi');
0143 editact.cb2 = get_child_handle(h_fig,'right_hemi');
0144 editact.rb1 = get_child_handle(h_fig,'talairach');
0145 editact.rb2 = get_child_handle(h_fig,'mni');
0146 editact.operation_text = get_child_handle(h_fig,'operation_text');
0147 editact.zt = get_child_handle(h_fig,'zoom_toggle');
0148 editact.model_type_inflate_rb = get_child_handle(h_fig,'inflate');
0149 editact.model_type_fold_rb = get_child_handle(h_fig,'folded');
0150 editact.load_cortex_menu ...
0151 = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0152 'load_cortex_menu');
0153 editact.load_actmap_menu ...
0154 = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0155 'load_actmap_menu');
0156 editact.loaded_files_menu ...
0157 = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0158 'loaded_files_menu');
0159 editact.close_menu ...
0160 = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0161 'close_menu');
0162 editact.manual_menu ...
0163 = get_child_handle(get_child_handle(h_fig,'help_menu'), ...
0164 'manual');
0165
0166
0167 set(editact.ed2,'String','6');
0168 set(editact.lb1,'Value',1);
0169
0170 editact.plot_parm = vb_set_plot_parm;
0171 editact.plot_parm.index = [];
0172 editact.plot_parm.LRflag = 'LR';
0173
0174
0175 set(editact.h_space,'XTick',[],'YTick',[]);
0176 set(editact.h_cbar,'XTick',[],'YTick',[]);
0177
0178
0179
0180
0181
0182 inst_str = num2str(inst_id);
0183 editact_str = ['vbmeg_inst.editact{' inst_str '}'];
0184
0185
0186 command = ['global vbmeg_inst; '...
0187 'vbmeg_inst.editact{' inst_str '}=[];'];
0188 set(h_fig,'DeleteFcn',command);
0189
0190
0191 command = ['job_edit_act_change_radius(' inst_str ');'];
0192 set(editact.ed2,'Callback',command);
0193
0194
0195 command = ['job_edit_act_change_vertex(' inst_str ');'];
0196 set(editact.ed5,'Callback',command);
0197
0198
0199 command = ['job_edit_act_clear(' inst_str ');'];
0200 set(editact.pb2,'Callback',command);
0201
0202
0203 command = ['job_edit_act_replace(' inst_str ');'];
0204 set(editact.pb15,'Callback',command);
0205
0206
0207 command = ['job_edit_act_average(' inst_str ');'];
0208 set(editact.pb3,'Callback',command);
0209
0210
0211 command = ['job_edit_act_maximum(' inst_str ');'];
0212 set(editact.pb4,'Callback',command);
0213
0214
0215 command = ['job_edit_act_plot_histogram(' inst_str ');'];
0216 set(editact.pb5,'Callback',command);
0217
0218
0219 command = ['job_edit_act_gauss_filter(' inst_str ');'];
0220 set(editact.pb6,'Callback',command);
0221
0222
0223 command = ['job_edit_act_step_filter(' inst_str ');'];
0224 set(editact.pb7,'Callback',command);
0225
0226
0227 command = ['job_edit_act_registration(' inst_str ');'];
0228 set(editact.pb8,'Callback',command);
0229
0230
0231 command = ['job_edit_act_delete(' inst_str ');'];
0232 set(editact.pb9,'Callback',command);
0233
0234
0235 command = ['job_edit_act_normalize(' inst_str ');'];
0236 set(editact.pb11,'Callback',command);
0237
0238
0239 command = ['job_edit_act_undo(' inst_str ');'];
0240 set(editact.pb12,'Callback',command);
0241
0242
0243 command = ['job_edit_act_print_spatialpattern(' inst_str ');'];
0244 set(editact.pb13,'Callback',command);
0245
0246
0247 command = ['job_edit_act_change_zoom(' inst_str ');'];
0248 set(editact.zt, 'Callback', command);
0249 if vb_matlab_version('<=', '7.5.0')
0250 set(editact.zt, 'Visible', 'on');
0251 else
0252 str = get(editact.operation_text, 'String');
0253 zoom_help = ' Zoom: mouse wheel';
0254 set(editact.operation_text, 'String', [str, zoom_help]);
0255 set(editact.zt, 'Visible', 'off');
0256 end
0257
0258
0259 command = ['job_edit_act_change_hemi(' inst_str ');'];
0260 set(editact.cb1,'Callback',command);
0261 set(editact.cb2,'Callback',command);
0262
0263
0264 model_type_group = [editact.model_type_inflate_rb,
0265 editact.model_type_fold_rb];
0266 command = ['job_edit_act_change_modeltype(' inst_str ');'];
0267 set(model_type_group, 'Callback', command);
0268 set(model_type_group, 'Value', 0);
0269 set(editact.model_type_inflate_rb,'Value',1);
0270
0271
0272 command = ['[brain_dir,brain_file] = vb_file_select' ...
0273 '({''.brain.mat''},''Load cortical model'');' ...
0274 'if ~isempty(brain_file), ' ...
0275 'job_edit_act_load_cortex(' inst_str ',' ...
0276 '[brain_dir filesep brain_file{1}]); end'];
0277 set(editact.load_cortex_menu, 'Callback', command);
0278
0279 command = ['vb_browser_show(''' which('job_edit_act.html') ''');'];
0280 set(editact.manual_menu, 'Callback', command);
0281
0282
0283 command = ['[act_dir,act_file] = vb_file_select' ...
0284 '({''.act.mat''},''Load activity map file'');' ...
0285 'if ~isempty(act_file), ' ...
0286 'job_edit_act_load_actfile(' inst_str ',' ...
0287 '[act_dir filesep act_file{1}]); end'];
0288 set(editact.load_actmap_menu, 'Callback', command);
0289
0290
0291
0292
0293 command = ['job_edit_act_show_loaded_files(' inst_str ');'];
0294 set(editact.loaded_files_menu, 'Callback', command);
0295
0296
0297 command = 'close';
0298 set(editact.close_menu,'Callback',command);
0299
0300
0301 command = ['job_edit_act_change_angle(' inst_str ',''left'');'];
0302 set(editact.pb16,'Callback',command);
0303 command = ['job_edit_act_change_angle(' inst_str ',''right'');'];
0304 set(editact.pb17,'Callback',command);
0305 command = ['job_edit_act_change_angle(' inst_str ',''top'');'];
0306 set(editact.pb18,'Callback',command);
0307 command = ['job_edit_act_change_angle(' inst_str ',''bottom'');'];
0308 set(editact.pb19,'Callback',command);
0309
0310
0311 command = ['job_edit_act_change_tal(' inst_str ');'];
0312 set(editact.rb1,'Callback',command);
0313 command = ['job_edit_act_change_mni(' inst_str ');'];
0314 set(editact.rb2,'Callback',command);
0315
0316
0317 command = ['job_edit_act_change_color_scale(' inst_str ');'];
0318 set(editact.ed6,'Callback',command);
0319
0320
0321
0322
0323
0324 set(h_fig,'Renderer','zbuffer');
0325
0326
0327
0328
0329
0330 vbmeg_inst.editact{inst_id} = editact;
0331
0332
0333 set(h_fig,'Pointer','arrow');
0334
0335
0336 warning('off', 'MATLAB:colorbar:DeprecatedV6Argument');
0337
0338
0339
0340
0341
0342 if ~isempty(brainfile),
0343 job_edit_act_load_cortex(inst_id,brainfile);
0344 end
0345
0346
0347
0348
0349
0350 if ~isempty(actfile),
0351 job_edit_act_load_actfile(inst_id,actfile);
0352 end