0001 function job_plot_currentmap(brain_file,curr_file,ix_trial,area_file,act_file,filedlg_mode)
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
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131 if nargin<6 , filedlg_mode = 0; end
0132 if nargin<5 , act_file = '' ; end
0133 if nargin<4 , area_file = '' ; end
0134 if nargin<3 | isempty(ix_trial), ix_trial = 1 ; end
0135 if nargin<2 , curr_file = '' ; end
0136 if nargin<1 , brain_file = '' ; end
0137
0138 inst_id = create_instance;
0139 if isempty(inst_id), return; end
0140
0141
0142 if ~exist('model', 'var'), model =0; end
0143 if model ~= 0, model = 1; end
0144
0145
0146 create_GUI(inst_id,brain_file,curr_file,ix_trial,area_file,act_file, ...
0147 model,filedlg_mode);
0148 job_plot_cmap_update_filterradius(inst_id);
0149 job_plot_cmap_update_timecourse(inst_id);
0150 job_plot_cmap_update_spatialpattern(inst_id);
0151
0152 return;
0153
0154
0155 function inst_id = create_instance
0156
0157 global vbmeg_inst
0158
0159 if isfield(vbmeg_inst,'plotcmap'),
0160 for inst_id=1:vbmeg_inst.const.PLOTCMAP_MAX
0161 if isempty(vbmeg_inst.plotcmap{inst_id}), return; end;
0162 end
0163 vb_disp(['The number of instances of ''job_plot_currentmap''' ...
0164 ' GUIs reaches the maximum number.']);
0165 inst_id = [];
0166 elseif isfield(vbmeg_inst,'const'),
0167 vbmeg_inst.plotcmap = cell(vbmeg_inst.const.PLOTCMAP_MAX,1);
0168 inst_id = 1;
0169 else
0170 vb_disp(['''vbmeg_inst'' was not correct. You have to invoke' ...
0171 '''vbmeg'' to create an instance of VBMEG.']);
0172 inst_id = [];
0173 end
0174
0175 return;
0176
0177
0178 function create_GUI(inst_id,brain_file,curr_file,ix_trial,area_file, ...
0179 act_file,model,filedlg_mode)
0180
0181 global vbmeg_inst;
0182
0183
0184
0185 plotcmap.brain_file = '';
0186 plotcmap.V = [];
0187 plotcmap.Vinf = [];
0188 plotcmap.F = [];
0189 plotcmap.inf_C = [];
0190 plotcmap.xxA = [];
0191 plotcmap.Vtal = [];
0192 plotcmap.nextDD = [];
0193 plotcmap.nextIX = [];
0194
0195
0196 Jmin_plot = 0;
0197 Jmax_plot = 1;
0198 plotcmap.curr_file = '';
0199 plotcmap.Jact = [];
0200 plotcmap.Jmax = [];
0201 plotcmap.Jmin = [];
0202 plotcmap.Jmax_plot = Jmax_plot;
0203 plotcmap.Jmin_plot = Jmin_plot;
0204 plotcmap.ix_trial = 1;
0205 plotcmap.ave_mode = true;
0206 plotcmap.toi = [];
0207 plotcmap.foi = [];
0208 plotcmap.Jinfo = [];
0209
0210
0211 plotcmap.tf_file = '';
0212 plotcmap.data = [];
0213 plotcmap.TFinfo = [];
0214 plotcmap.TFmax = [];
0215 plotcmap.TFmin = [];
0216 plotcmap.TFmin_plot = 0;
0217 plotcmap.TFmax_plot = 1;
0218
0219
0220 plotcmap.act_file = '';
0221 plotcmap.xxP = [];
0222
0223
0224 plotcmap.area_file = '';
0225 plotcmap.area_key = [];
0226
0227
0228 plotcmap.plot_parm = vb_set_plot_parm;
0229 plotcmap.plot_parm.index = [];
0230 plotcmap.plot_parm.LRflag = 'LR';
0231 plotcmap.ix_peak = 1;
0232 plotcmap.J_hold = [];
0233
0234
0235
0236 plotcmap.filedlg_mode = filedlg_mode;
0237
0238
0239 plotcmap.Jbck = [];
0240 plotcmap.ix_act = [];
0241 plotcmap.ix_bck = [];
0242 plotcmap.Tstart = [];
0243 plotcmap.T = [];
0244 plotcmap.t = [];
0245 plotcmap.patch_norm = [];
0246
0247
0248 h_fig = open('job_plot_cmap.fig');
0249 set(h_fig,'HandleVisibility','on');
0250 set(h_fig,'Pointer','watch');
0251 drawnow;
0252
0253
0254 plotcmap.model_type = model;
0255
0256
0257 plotcmap.h_fig = h_fig;
0258 plotcmap.h_time = get_child_handle(h_fig,'plot_time');
0259 plotcmap.h_space = get_child_handle(h_fig,'plot_brain');
0260 plotcmap.h_cbar = get_child_handle(h_fig,'colorbar');
0261 plotcmap.h_cbar_tf = get_child_handle(h_fig,'colorbar_tf');
0262 plotcmap.ed1 = get_child_handle(h_fig,'trial_number');
0263 plotcmap.ed2 = get_child_handle(h_fig,'time_window_start');
0264 plotcmap.ed3 = get_child_handle(h_fig,'time_window_end');
0265 plotcmap.ed4 = get_child_handle(h_fig,'ix_peak');
0266 plotcmap.ed5 = get_child_handle(h_fig,'spatial_peak_size');
0267 plotcmap.ed6 = get_child_handle(h_fig,'tal_coord');
0268 plotcmap.ed7 = get_child_handle(h_fig,'temporal_peak_size');
0269 plotcmap.ed8 = get_child_handle(h_fig,'freq_window_min');
0270 plotcmap.ed9 = get_child_handle(h_fig,'freq_window_max');
0271 plotcmap.ed10 = get_child_handle(h_fig,'Jmax_tf_plot_edit');
0272 plotcmap.pb1 = get_child_handle(get_child_handle(h_fig,'save_menu'), ...
0273 'spatial_pattern_menu');
0274 plotcmap.pb2 = get_child_handle(get_child_handle(h_fig,'save_menu'), ...
0275 'temporal_pattern_menu');
0276 plotcmap.pb3 = get_child_handle(h_fig,'rotate');
0277 plotcmap.pb4 = get_child_handle(h_fig,'move_forward');
0278 plotcmap.pb5 = get_child_handle(h_fig,'move_forward_fast');
0279 plotcmap.pb6 = get_child_handle(h_fig,'move_back');
0280 plotcmap.pb7 = get_child_handle(h_fig,'move_back_fast');
0281 plotcmap.pb8 = get_child_handle(h_fig,'search_spatial_peak');
0282 plotcmap.pb9 = get_child_handle(h_fig,'search_temporal_peak');
0283 plotcmap.pb10 = get_child_handle(get_child_handle(h_fig, 'save_menu'), ...
0284 'cortical_activity_map_menu');
0285 plotcmap.pb12 = get_child_handle(get_child_handle(h_fig, 'save_menu'), ...
0286 'cortical_area_menu');
0287 plotcmap.pb13 = get_child_handle(h_fig,'left_button');
0288 plotcmap.pb14 = get_child_handle(h_fig,'right_button');
0289 plotcmap.pb15 = get_child_handle(h_fig,'top_button');
0290 plotcmap.pb16 = get_child_handle(h_fig,'bottom_button');
0291 plotcmap.pb17 = get_child_handle(h_fig,'front_button');
0292 plotcmap.pb18 = get_child_handle(h_fig,'back_button');
0293 plotcmap.rb1 = get_child_handle(h_fig,'talairach');
0294 plotcmap.rb2 = get_child_handle(h_fig,'mni');
0295 plotcmap.cb1 = get_child_handle(h_fig,'fix_colorbar');
0296 plotcmap.cb2 = get_child_handle(h_fig,'left_brain');
0297 plotcmap.cb3 = get_child_handle(h_fig,'right_brain');
0298 plotcmap.cb4 = get_child_handle(h_fig,'hold_on');
0299 plotcmap.cb5 = get_child_handle(h_fig,'show_roi');
0300 plotcmap.cb6 = get_child_handle(h_fig,'fix_colorbar_tf');
0301 plotcmap.cb7 = get_child_handle(h_fig,'show_act_map');
0302 plotcmap.cb8 = get_child_handle(h_fig,'show_cortical_area');
0303 plotcmap.lb1 = get_child_handle(h_fig,'act_key_list');
0304 plotcmap.lb2 = get_child_handle(h_fig,'area_key_list');
0305 plotcmap.lb3 = get_child_handle(h_fig,'cortical_area');
0306 plotcmap.Jmin_plot_edit = get_child_handle(h_fig, 'Jmin_plot_edit');
0307 plotcmap.Jmax_plot_edit = get_child_handle(h_fig, 'Jmax_plot_edit');
0308 plotcmap.model_type_original_rb ...
0309 = get_child_handle(h_fig,'model_type_original_rb');
0310 plotcmap.model_type_inflate_rb ...
0311 = get_child_handle(h_fig,'model_type_inflate_rb');
0312 plotcmap.load_data_menu ...
0313 = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0314 'load_data_menu');
0315 plotcmap.loaded_files_menu ...
0316 = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0317 'loaded_files_menu');
0318 plotcmap.close_menu ...
0319 = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0320 'close_menu');
0321
0322 plotcmap.h_rotate = rotate3d(h_fig);
0323
0324
0325 set(plotcmap.ed1,'String','1');
0326 set(plotcmap.ed1,'Enable','off')
0327
0328
0329 inst_str = num2str(inst_id);
0330 plotcmap_str = ['vbmeg_inst.plotcmap{' inst_str '}'];
0331
0332
0333 command = ['global vbmeg_inst; '...
0334 'vbmeg_inst.plotcmap{' inst_str '}=[];'];
0335 set(h_fig,'DeleteFcn',command);
0336
0337
0338 command = ['job_plot_cmap_push_zoom_button(' inst_str ');'];
0339 set(plotcmap.pb3,'Callback',command);
0340 if vb_matlab_version('>=', '7.6')
0341 set(plotcmap.pb3, 'Visible', 'off');
0342 end
0343
0344
0345 if vb_matlab_version('>=', '7.3');
0346 set(plotcmap.h_rotate, 'ActionPostCallback', @after_rotate_callback);
0347 end
0348
0349
0350 command = ['job_plot_cmap_change_trial(' inst_str ');'];
0351 set(plotcmap.ed1,'Callback',command);
0352
0353
0354 command = ['global vbmeg_inst; ' ...
0355 plotcmap_str '.toi(1)=' ...
0356 'str2num(get(' plotcmap_str '.ed2,''String''));' ...
0357 'job_plot_cmap_update_timecourse(' inst_str ');' ...
0358 'job_plot_cmap_update_spatialpattern(' inst_str ');'];
0359 set(plotcmap.ed2,'Callback',command);
0360 command = ['global vbmeg_inst; ' ...
0361 plotcmap_str '.toi(2)=' ...
0362 'str2num(get(' plotcmap_str '.ed3,''String''));' ...
0363 'job_plot_cmap_update_timecourse(' inst_str ');' ...
0364 'job_plot_cmap_update_spatialpattern(' inst_str ');'];
0365 set(plotcmap.ed3,'Callback',command);
0366
0367
0368 command = ['global vbmeg_inst; ' ...
0369 plotcmap_str '.foi(1)=' ...
0370 'str2num(get(' plotcmap_str '.ed8,''String''));' ...
0371 'job_plot_cmap_update_timecourse(' inst_str ');' ...
0372 'job_plot_cmap_update_spatialpattern(' inst_str ');'];
0373 set(plotcmap.ed8,'Callback',command);
0374 command = ['global vbmeg_inst; ' ...
0375 plotcmap_str '.foi(2)=' ...
0376 'str2num(get(' plotcmap_str '.ed9,''String''));' ...
0377 'job_plot_cmap_update_timecourse(' inst_str ');' ...
0378 'job_plot_cmap_update_spatialpattern(' inst_str ');'];
0379 set(plotcmap.ed9,'Callback',command);
0380
0381
0382 command = ['global vbmeg_inst; '...
0383 'dt = ' plotcmap_str '.toi(2)-' plotcmap_str '.toi(1);' ...
0384 plotcmap_str '.toi=' plotcmap_str '.toi+dt;' ...
0385 'job_plot_cmap_update_timecourse(' inst_str ');' ...
0386 'job_plot_cmap_update_spatialpattern(' inst_str ');'];
0387 set(plotcmap.pb4,'Callback',command);
0388 command = ['global vbmeg_inst; '...
0389 'dt = ' plotcmap_str '.toi(2)-' plotcmap_str '.toi(1);' ...
0390 plotcmap_str '.toi=' plotcmap_str '.toi+5*dt;' ...
0391 'job_plot_cmap_update_timecourse(' inst_str ');' ...
0392 'job_plot_cmap_update_spatialpattern(' inst_str ');'];
0393 set(plotcmap.pb5,'Callback',command);
0394 command = ['global vbmeg_inst; '...
0395 'dt = ' plotcmap_str '.toi(2)-' plotcmap_str '.toi(1);' ...
0396 plotcmap_str '.toi=' plotcmap_str '.toi-dt;' ...
0397 'job_plot_cmap_update_timecourse(' inst_str ');' ...
0398 'job_plot_cmap_update_spatialpattern(' inst_str ');'];
0399 set(plotcmap.pb6,'Callback',command);
0400 command = ['global vbmeg_inst; '...
0401 'dt = ' plotcmap_str '.toi(2)-' plotcmap_str '.toi(1);' ...
0402 plotcmap_str '.toi=' plotcmap_str '.toi-5*dt;' ...
0403 'job_plot_cmap_update_timecourse(' inst_str ');' ...
0404 'job_plot_cmap_update_spatialpattern(' inst_str ');'];
0405 set(plotcmap.pb7,'Callback',command);
0406
0407
0408 command = ['job_plot_cmap_spatial_peak(' inst_str ');'];
0409 set(plotcmap.pb8,'Callback',command);
0410 command = ['job_plot_cmap_temporal_peak(' inst_str ');'];
0411 set(plotcmap.pb9,'Callback',command);
0412
0413
0414 command = ['job_plot_cmap_change_Jplot(' inst_str ');'];
0415 set(plotcmap.Jmin_plot_edit,'Callback',command);
0416 set(plotcmap.Jmax_plot_edit,'Callback',command);
0417 set(plotcmap.Jmin_plot_edit,'String','');
0418 set(plotcmap.Jmax_plot_edit,'String','');
0419
0420
0421 command = ['job_plot_cmap_change_Jplot_tf(' inst_str ');'];
0422 set(plotcmap.ed10,'Callback',command);
0423 set(plotcmap.ed10,'String','');
0424
0425
0426 command = ['job_plot_cmap_print_spatialpattern(' inst_str ');'];
0427 set(plotcmap.pb1,'Callback',command);
0428 command = ['job_plot_cmap_print_temporalpattern(' inst_str ');'];
0429 set(plotcmap.pb2,'Callback',command);
0430
0431
0432 command = ['global vbmeg_inst;' ...
0433 plotcmap_str '.ix_peak = ' ...
0434 'str2num(get(' plotcmap_str '.ed4,''String''));' ...
0435 'job_plot_cmap_update_timecourse(' inst_str ');' ...
0436 'job_plot_cmap_update_spatialpattern(' inst_str ');'];
0437 set(plotcmap.ed4,'Callback',command);
0438
0439
0440 command = ['global vbmeg_inst;' ...
0441 'job_plot_cmap_change_talcoord(' inst_str ');'];
0442 set(plotcmap.ed6,'Callback',command);
0443
0444
0445 command = ['job_plot_cmap_update_filterradius(' inst_str ');' ...
0446 'job_plot_cmap_update_spatialpattern(' inst_str ');' ...
0447 'job_plot_cmap_update_timecourse(' inst_str ');'];
0448 set(plotcmap.ed5,'Callback',command);
0449
0450
0451 command = ['job_plot_cmap_register_activity(' inst_str ');'];
0452 set(plotcmap.pb10,'Callback',command);
0453
0454
0455 command = ['job_plot_cmap_register_area(' inst_str ');'];
0456 set(plotcmap.pb12,'Callback',command);
0457
0458
0459 command = ['job_plot_cmap_change_rb1(' inst_str ');'];
0460 set(plotcmap.rb1,'Callback',command);
0461 command = ['job_plot_cmap_change_rb2(' inst_str ');'];
0462 set(plotcmap.rb2,'Callback',command);
0463
0464
0465 command = ['job_plot_cmap_holdon(' inst_str ');'];
0466 set(plotcmap.cb4,'Callback',command);
0467
0468
0469 command = ['job_plot_cmap_show_roi(' inst_str ');'];
0470 set(plotcmap.cb5,'Callback',command);
0471
0472
0473 command = ['job_plot_cmap_update_colorbarscale(' inst_str ');'];
0474 set(plotcmap.cb1,'Callback',command);
0475 set(plotcmap.cb6,'Callback',command);
0476
0477
0478 command = ['job_plot_cmap_update_spatialpattern(' inst_str ');'];
0479 set(plotcmap.cb2,'Callback',command);
0480 set(plotcmap.cb3,'Callback',command);
0481
0482
0483 command = ['job_plot_cmap_update_colorbarscale(' inst_str ');' ...
0484 'job_plot_cmap_update_spatialpattern(' inst_str ');'];
0485 set(plotcmap.cb7,'Callback',command);
0486
0487
0488
0489
0490 command = ['job_plot_cmap_update_spatialpattern(' inst_str ');'];
0491 set(plotcmap.cb8,'Callback',command);
0492
0493
0494 command = ['global vbmeg_inst; '...
0495 'job_plot_cmap_update_xxP(' inst_str ');' ...
0496 'job_plot_cmap_update_colorbarscale(' inst_str ');' ...
0497 'job_plot_cmap_update_spatialpattern(' inst_str ');'];
0498 set(plotcmap.lb1,'Callback',command);
0499
0500
0501 command = ['global vbmeg_inst; '...
0502 'job_plot_cmap_update_area(' inst_str ');' ...
0503 'job_plot_cmap_update_spatialpattern(' inst_str ');'];
0504 set(plotcmap.lb2,'Callback',command);
0505
0506
0507 model_type_group = [plotcmap.model_type_inflate_rb,
0508 plotcmap.model_type_original_rb];
0509 command = ['job_plot_cmap_change_modeltype(' inst_str ');'];
0510 set(model_type_group, 'Callback', command);
0511 set(model_type_group, 'Value', 0);
0512 if model == 0
0513 set(plotcmap.model_type_inflate_rb, 'Value', 1);
0514 else
0515 set(plotcmap.model_type_original_rb, 'Value', 1);
0516 end
0517
0518
0519
0520
0521
0522 command = ['job_plot_cmap_load_data(' inst_str ');'];
0523 set(plotcmap.load_data_menu, 'Callback', command);
0524
0525
0526 command = ['job_plot_cmap_show_loaded_files(' inst_str ');'];
0527 set(plotcmap.loaded_files_menu, 'Callback', command);
0528
0529
0530 command = 'close;';
0531 set(plotcmap.close_menu,'Callback',command);
0532
0533
0534 command = ['job_plot_cmap_change_angle(' inst_str ',''left'');' ...
0535 'job_plot_cmap_update_camera(' inst_str ');'];
0536 set(plotcmap.pb13,'Callback',command);
0537 command = ['job_plot_cmap_change_angle(' inst_str ',''right'');' ...
0538 'job_plot_cmap_update_camera(' inst_str ');'];
0539 set(plotcmap.pb14,'Callback',command);
0540 command = ['job_plot_cmap_change_angle(' inst_str ',''top'');' ...
0541 'job_plot_cmap_update_camera(' inst_str ');'];
0542 set(plotcmap.pb15,'Callback',command);
0543 command = ['job_plot_cmap_change_angle(' inst_str ',''bottom'');' ...
0544 'job_plot_cmap_update_camera(' inst_str ');'];
0545 set(plotcmap.pb16,'Callback',command);
0546 command = ['job_plot_cmap_change_angle(' inst_str ',''front'');' ...
0547 'job_plot_cmap_update_camera(' inst_str ');'];
0548 set(plotcmap.pb17,'Callback',command);
0549 command = ['job_plot_cmap_change_angle(' inst_str ',''back'');' ...
0550 'job_plot_cmap_update_camera(' inst_str ');'];
0551 set(plotcmap.pb18,'Callback',command);
0552
0553
0554 set(h_fig,'Renderer','zbuffer');
0555 set(h_fig,'CurrentAxes',plotcmap.h_space);
0556 axis off;
0557
0558
0559
0560
0561
0562 vbmeg_inst.plotcmap{inst_id} = plotcmap;
0563
0564
0565 set(h_fig,'Pointer','arrow');
0566
0567
0568 parms = [];
0569
0570 if ~isempty(brain_file),
0571 parms.brain_file = brain_file;
0572 end
0573
0574 if ~isempty(curr_file),
0575 [tmp1,tmp2] = fileparts(curr_file);
0576 [tmp1,tmp2,str_ext] = fileparts([tmp1 filesep tmp2]);
0577
0578 switch str_ext
0579 case '.curr',
0580 parms.curr_file = curr_file;
0581 parms.tf_file = [];
0582
0583 case '.tf',
0584 parms.curr_file = [];
0585 parms.tf_file = curr_file;
0586
0587 otherwise,
0588 vb_disp('WARNING',['Invalid extention for curr_file (job_plot_' ...
0589 'currentmap.m)']);
0590 end
0591 end
0592
0593 if ~isempty(ix_trial),
0594 parms.ix_trial = ix_trial;
0595 parms.ave_mode = false;
0596 end
0597
0598 if ~isempty(area_file),
0599 parms.area_file = area_file;
0600 end
0601
0602 if ~isempty(act_file),
0603 parms.act_file = act_file;
0604 end
0605
0606 job_plot_cmap_load_data(inst_id,parms);
0607
0608 return;