0001 function job_view_cortex_callback( key )
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 if ~strcmp( get( gcf, 'Tag'), 'job_view_cortex main' )
0012 return;
0013 end
0014
0015 H = get( gcf, 'UserData' );
0016
0017 if isempty(H)
0018 return;
0019 end
0020
0021 if isfield(H, 'fig')
0022 set( H.fig, 'Pointer', 'watch' );
0023 end
0024
0025
0026 switch key
0027
0028
0029
0030
0031
0032
0033 case 'brain load file button'
0034 err = job_view_cortex_file( 'load', 'brain', '' );
0035 if ~err
0036 job_view_cortex_aftereffect( 'file load brain' );
0037 job_view_cortex_plot( 'brain' );
0038 end
0039
0040
0041
0042
0043
0044
0045
0046 case 'act load file button'
0047 err = job_view_cortex_file( 'load', 'act', '' );
0048 if ~err
0049 job_view_cortex_aftereffect( 'file load act' );
0050 job_view_cortex_plot( 'act' );
0051 end
0052
0053
0054 case 'act list select'
0055 job_view_cortex_aftereffect( 'list act candidate select' );
0056
0057
0058 case 'act plotted list select'
0059 job_view_cortex_aftereffect( 'list act plotted select' );
0060 job_view_cortex_plot( 'highlight act' );
0061
0062
0063 case 'act add to plotted list button'
0064 selected = get( H.activation_list, 'Value' );
0065 err = job_view_cortex_list( 'add', 'act', 'plotted', selected );
0066 if ~err
0067 job_view_cortex_aftereffect( 'list act plotted add' );
0068 job_view_cortex_plot( 'act' );
0069 end
0070
0071
0072 case 'act delete from plotted list button'
0073 selected = get( H.activation_plotted_list, 'Value' );
0074 err = job_view_cortex_list( 'delete', 'act', 'plotted', selected );
0075 if ~err
0076 job_view_cortex_aftereffect( 'list act plotted delete' );
0077 job_view_cortex_plot( 'act' );
0078 end
0079
0080
0081 case 'act clear plotted list button'
0082 err = job_view_cortex_list( 'clear', 'act', 'plotted', [] );
0083 if ~err
0084 job_view_cortex_aftereffect( 'list act plotted delete' );
0085 job_view_cortex_plot( 'act' );
0086 end
0087
0088
0089
0090
0091
0092
0093
0094 case 'area load file button'
0095 err = job_view_cortex_file( 'load', 'area', '' );
0096 if ~err
0097 job_view_cortex_aftereffect( 'file load area' );
0098 job_view_cortex_plot( 'brain' );
0099 end
0100
0101
0102 case 'area save file button'
0103 err = job_view_cortex_file( 'save', 'area', '' );
0104 if ~err
0105 job_view_cortex_aftereffect( 'file save area' );
0106 end
0107
0108
0109 case 'area list select'
0110 job_view_cortex_aftereffect( 'list area candidate select' );
0111
0112
0113 case 'area list delete button'
0114 data = get( H.areadata, 'UserData' );
0115 selected = get( H.area_list, 'Value' );
0116 keys = get( H.area_list, 'String' );
0117 delkey = []; for i = selected; delkey = [ delkey, ' ', keys{i} ]; end;
0118 deletep = questdlg( [ 'Are you sure to delete', delkey, '?' ] );
0119 if strcmp( deletep, 'Yes' )
0120 err = job_view_cortex_list( 'delete', 'area', 'candidate', selected );
0121 if ~err
0122 job_view_cortex_aftereffect( 'list area candidate delete' );
0123 job_view_cortex_plot( 'brain' );
0124 end
0125 end
0126
0127
0128 case 'area plotted list select'
0129 job_view_cortex_aftereffect( 'list area plotted select' );
0130 job_view_cortex_plot( 'highlight area' );
0131
0132
0133 case 'area masking list select'
0134 job_view_cortex_aftereffect( 'list area masking select' );
0135
0136
0137 case 'area add to plotted list button'
0138 selected = get( H.area_list, 'Value' );
0139 err = job_view_cortex_list( 'add', 'area', 'plotted', selected );
0140 if ~err
0141 job_view_cortex_aftereffect( 'list area plotted add' );
0142 job_view_cortex_plot( 'area' );
0143 end
0144
0145
0146 case 'area delete from plotted list button'
0147 selected = get( H.area_plotted_list, 'Value' );
0148 err = job_view_cortex_list( 'delete', 'area', 'plotted', selected );
0149 if ~err
0150 job_view_cortex_aftereffect( 'list area plotted delete' );
0151 job_view_cortex_plot( 'area' );
0152 end
0153
0154
0155 case 'area clear plotted list button'
0156 err = job_view_cortex_list( 'clear', 'area', 'plotted', [] );
0157 if ~err
0158 job_view_cortex_aftereffect( 'list area plotted delete' );
0159 job_view_cortex_plot( 'area' );
0160 end
0161
0162
0163 case 'area add to masking list button'
0164 selected = get( H.area_list, 'Value' );
0165 err = job_view_cortex_list( 'add', 'area', 'masking', selected );
0166 if ~err
0167 job_view_cortex_aftereffect( 'list area masking add' );
0168 job_view_cortex_plot( 'brain' );
0169 end
0170
0171
0172 case 'area delete from masking list button'
0173 selected = get( H.area_masking_list, 'Value' );
0174 err = job_view_cortex_list( 'delete', 'area', 'masking', selected );
0175 if ~err
0176 job_view_cortex_aftereffect( 'list area masking delete' );
0177 job_view_cortex_plot( 'brain' );
0178 end
0179
0180
0181 case 'area clear masking list button'
0182 err = job_view_cortex_list( 'clear', 'area', 'masking', [] );
0183 if ~err
0184 job_view_cortex_aftereffect( 'list area masking delete' );
0185 job_view_cortex_plot( 'brain' );
0186 end
0187
0188
0189
0190
0191
0192
0193
0194 case 'selection add intersect act button'
0195 err = job_view_cortex_selection( 'add', 'act', 'intersect' );
0196 if ~err
0197 job_view_cortex_aftereffect( 'selection add' );
0198 job_view_cortex_plot( 'selection' );
0199 end
0200
0201
0202 case 'selection delete intersect act button'
0203 err = job_view_cortex_selection( 'delete', 'act', 'intersect' );
0204 if ~err
0205 job_view_cortex_aftereffect( 'selection delete' );
0206 job_view_cortex_plot( 'selection' );
0207 end
0208
0209
0210 case 'selection add union act button'
0211 err = job_view_cortex_selection( 'add', 'act', 'union' );
0212 if ~err
0213 job_view_cortex_aftereffect( 'selection add' );
0214 job_view_cortex_plot( 'selection' );
0215 end
0216
0217
0218 case 'selection delete union act button'
0219 err = job_view_cortex_selection( 'delete', 'act', 'union' );
0220 if ~err
0221 job_view_cortex_aftereffect( 'selection delete' );
0222 job_view_cortex_plot( 'selection' );
0223 end
0224
0225
0226 case 'selection add intersect area button'
0227 err = job_view_cortex_selection( 'add', 'area', 'intersect' );
0228 if ~err
0229 job_view_cortex_aftereffect( 'selection add' );
0230 job_view_cortex_plot( 'selection' );
0231 end
0232
0233
0234 case 'selection delete intersect area button'
0235 err = job_view_cortex_selection( 'delete', 'area', 'intersect' );
0236 if ~err
0237 job_view_cortex_aftereffect( 'selection delete' );
0238 job_view_cortex_plot( 'selection' );
0239 end
0240
0241
0242 case 'selection add union area button'
0243 err = job_view_cortex_selection( 'add', 'area', 'union' );
0244 if ~err
0245 job_view_cortex_aftereffect( 'selection add' );
0246 job_view_cortex_plot( 'selection' );
0247 end
0248
0249
0250 case 'selection delete union area button'
0251 err = job_view_cortex_selection( 'delete', 'area', 'union' );
0252 if ~err
0253 job_view_cortex_aftereffect( 'selection delete' );
0254 job_view_cortex_plot( 'selection' );
0255 end
0256
0257
0258 case 'selection undo button'
0259 err = job_view_cortex_selection( 'undo' );
0260 if ~err
0261 job_view_cortex_aftereffect( 'selection undo' );
0262 job_view_cortex_plot( 'selection' );
0263 end
0264
0265
0266 case 'selection clear button'
0267 err = job_view_cortex_selection( 'clear' );
0268 if ~err
0269 job_view_cortex_aftereffect( 'selection delete' );
0270 job_view_cortex_plot( 'selection' );
0271 end
0272
0273
0274 case 'selection dilation button'
0275 err = job_view_cortex_selection( 'add', 'dilation' );
0276 if ~err
0277 job_view_cortex_aftereffect( 'selection add' );
0278 job_view_cortex_plot( 'selection' );
0279 end
0280
0281
0282 case 'selection erosion button'
0283 err = job_view_cortex_selection( 'delete', 'erosion' );
0284 if ~err
0285 job_view_cortex_aftereffect( 'selection delete' );
0286 job_view_cortex_plot( 'selection' );
0287 end
0288
0289
0290 case 'selection register button'
0291 err = job_view_cortex_selection( 'register', 'area' );
0292 if ~err
0293 job_view_cortex_aftereffect( 'selection register' );
0294 end
0295
0296
0297 case 'selection add mouse'
0298 err = job_view_cortex_selection( 'add', 'mouse' );
0299 if ~err
0300 job_view_cortex_aftereffect( 'selection add' );
0301 job_view_cortex_plot( 'selection' );
0302 end
0303
0304
0305 case 'selection delete mouse'
0306 err = job_view_cortex_selection( 'delete', 'mouse' );
0307 if ~err
0308 job_view_cortex_aftereffect( 'selection delete' );
0309 job_view_cortex_plot( 'selection' );
0310 end
0311
0312
0313
0314
0315
0316
0317
0318
0319 case 'mouse func'
0320 if get( H.mouse_func_radioZ, 'Value' ) == 1
0321 job_view_cortex_callback( 'mouse func Z' );
0322 end
0323 if get( H.mouse_func_radioR, 'Value' ) == 1
0324 job_view_cortex_callback( 'mouse func R' );
0325 end
0326 if get( H.mouse_func_radioS, 'Value' ) == 1
0327 job_view_cortex_callback( 'mouse func S' );
0328 end
0329 if get( H.mouse_func_radioU, 'Value' ) == 1
0330 job_view_cortex_callback( 'mouse func U' );
0331 end
0332
0333 case 'mouse func Z'
0334 set( H.mouse_func_radioZ, 'Value', 1 );
0335 set( H.mouse_func_radioR, 'Value', 0 );
0336 set( H.mouse_func_radioS, 'Value', 0 );
0337 set( H.mouse_func_radioU, 'Value', 0 );
0338 zoom on;
0339 rotate3d off;
0340 set( findobj( H.plot_axes, 'Tag', 'brain' ), 'ButtonDownFcn', '' );
0341 if ~isempty(which('setAxes3DPanAndZoomStyle'))
0342 setAxes3DPanAndZoomStyle(zoom(H.plot_axes), H.plot_axes, 'camera')
0343 set(H.plot_axes, 'CameraViewAngleMode', 'auto');
0344 end
0345
0346 case 'mouse func R'
0347 set( H.mouse_func_radioZ, 'Value', 0 );
0348 set( H.mouse_func_radioR, 'Value', 1 );
0349 set( H.mouse_func_radioS, 'Value', 0 );
0350 set( H.mouse_func_radioU, 'Value', 0 );
0351 zoom off;
0352 rotate3d on;
0353 set( findobj( H.plot_axes, 'Tag', 'brain' ), 'ButtonDownFcn', '' );
0354
0355 case 'mouse func S'
0356 set( H.mouse_func_radioZ, 'Value', 0 );
0357 set( H.mouse_func_radioR, 'Value', 0 );
0358 set( H.mouse_func_radioS, 'Value', 1 );
0359 set( H.mouse_func_radioU, 'Value', 0 );
0360 zoom off;
0361 rotate3d off;
0362 set( findobj( H.plot_axes, 'Tag', 'brain' ), 'ButtonDownFcn',...
0363 'job_view_cortex_callback(''selection add mouse'');' );
0364
0365 case 'mouse func U'
0366 set( H.mouse_func_radioZ, 'Value', 0 );
0367 set( H.mouse_func_radioR, 'Value', 0 );
0368 set( H.mouse_func_radioS, 'Value', 0 );
0369 set( H.mouse_func_radioU, 'Value', 1 );
0370 zoom off;
0371 rotate3d off;
0372 set( findobj( H.plot_axes, 'Tag', 'brain' ), 'ButtonDownFcn',...
0373 'job_view_cortex_callback(''selection delete mouse'');' );
0374
0375
0376
0377
0378
0379
0380
0381
0382 case 'list unselect'
0383 set( H.activation_plotted_list, 'Value', [] );
0384 set( H.area_plotted_list, 'Value', [] );
0385 set( H.area_masking_list, 'Value', [] );
0386 job_view_cortex_aftereffect( 'list act plotted unselect' );
0387 job_view_cortex_aftereffect( 'list area plotted unselect' );
0388 job_view_cortex_aftereffect( 'list area maksing unselect' );
0389 job_view_cortex_plot( 'highlight act' );
0390 job_view_cortex_plot( 'highlight area' );
0391
0392
0393 case 'print'
0394 h = figure;
0395 set(h, 'Units', 'normalized');
0396 ax_h = copyobj(H.plot_axes, h);
0397 set(ax_h, 'Units', 'normalized');
0398 set(ax_h, 'Position', [0.2, 0.11, 0.75, 0.85]);
0399 box off;
0400 axis equal;
0401 axis tight;
0402 set(h, 'Units', 'pixels');
0403 vb_epsfig(h,0.5,15);
0404 axis off;
0405
0406 H.file_dialog.save_mode = 1;
0407 H.file_dialog.file_extensions = { '.eps' };
0408 [ pname fname ] = visible(H.file_dialog);
0409 if length(pname)
0410 print( h, '-depsc2', fullfile( pname, fname{1} ) );
0411 end
0412 delete(h);
0413
0414 case 'close'
0415 closep = questdlg( 'Are you sure to close window ?', 'Close Window' );
0416 if strcmp( closep, 'Yes' );
0417 delete( H.fig );
0418 end
0419
0420 case 'set param'
0421 param = get( H.paramdata, 'UserData' );
0422 param = job_view_cortex_param( param );
0423 if ~isempty(param)
0424 set( H.paramdata, 'UserData', param );
0425 job_view_cortex_aftereffect( 'param' );
0426 job_view_cortex_plot( 'brain' );
0427 end
0428
0429
0430 case 'mouse move'
0431 pntpos = get( 0, 'PointerLocation' );
0432 winpos = get( H.fig, 'Position' );
0433 axspos = get( H.plot_axes, 'Position' );
0434 pntpos = pntpos - winpos(1:2);
0435 if all( axspos(1:2) < pntpos & axspos(1:2) + axspos(3:4) > pntpos )
0436 else
0437 set( H.fig, 'Pointer', 'arrow' )
0438 end
0439
0440
0441 [a, e] = view(H.plot_axes);
0442 [ae] = get(H.plot_axes, 'UserData');
0443 if ~isequal([a, e], ae)
0444 axes_children = get(H.plot_axes, 'Children');
0445 for k=1:length(axes_children)
0446 if strcmp(get(axes_children(k),'Type'),'light'),
0447 light = axes_children(k);
0448 light_num = get(axes_children(k), 'UserData');
0449 if strcmpi(light_num, 'light1')
0450 camlight(light, 0, 0);
0451 elseif strcmpi(light_num, 'light2')
0452 camlight(light, 0, 180);
0453 end
0454 end
0455 end
0456 end
0457 set(H.plot_axes, 'UserData', [a, e]);
0458 end
0459
0460 if ishandle( H.fig )
0461 set( H.fig, 'Pointer', 'arrow' );
0462 end