0001 function job_edit_area(brainfile, areafile)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 inst_id = create_instance;
0022 if isempty(inst_id), return; end;
0023 create_GUI(inst_id,areafile,brainfile);
0024 job_edit_area_update_spatialpattern(inst_id);
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 function inst_id = create_instance
0035
0036 global vbmeg_inst
0037
0038 if isfield(vbmeg_inst,'editarea'),
0039 for inst_id=1:vbmeg_inst.const.EDITAREA_MAX
0040 if isempty(vbmeg_inst.editarea{inst_id}), return; end;
0041 end
0042 fprintf(['The number of instances of ''job_edit_area''' ...
0043 ' GUIs reaches the maximum number.\n']);
0044 inst_id = [];
0045 elseif isfield(vbmeg_inst,'const'),
0046 vbmeg_inst.editarea = cell(vbmeg_inst.const.EDITAREA_MAX,1);
0047 inst_id = 1;
0048 else
0049 fprintf(['''vbmeg_inst'' was not correct. You have to invoke' ...
0050 '''vbmeg'' to create an instance of VBMEG.\n']);
0051 inst_id = [];
0052 end
0053
0054
0055
0056
0057 function create_GUI(inst_id,areafile,brainfile)
0058
0059 global vbmeg_inst;
0060
0061
0062 h_fig = open('job_edit_area.fig');
0063 set(h_fig,'HandleVisibility','on');
0064 drawnow;
0065 set(h_fig,'Pointer','watch');
0066
0067
0068 [V,F] = vb_load_cortex(brainfile);
0069 editarea.V0 = V;
0070 editarea.F0 = F;
0071 [V,F,xx,inf_C] = vb_load_cortex(brainfile,'Inflate');
0072 editarea.V = V;
0073 editarea.F = F;
0074 editarea.inf_C = inf_C;
0075
0076
0077 [nextDD,nextIX] = vb_load_cortex_neighbour(brainfile);
0078 editarea.nextDD = nextDD;
0079 editarea.nextIX = nextIX;
0080
0081
0082 editarea.areafile = areafile;
0083
0084
0085 editarea.Iextract = cell(30,1);
0086
0087
0088 editarea.h_fig = h_fig;
0089 editarea.h_space = get_child_handle(h_fig,'plot_brain');
0090 editarea.ed1 = get_child_handle(h_fig,'dilation_radius');
0091 editarea.ed2 = get_child_handle(h_fig,'erosion_radius');
0092 editarea.ed3 = get_child_handle(h_fig,'vertex_number');
0093 editarea.ed4 = get_child_handle(h_fig,'area_file');
0094 editarea.lb1 = get_child_handle(h_fig,'area_list');
0095 editarea.pb1 = get_child_handle(h_fig,'dilation');
0096 editarea.pb2 = get_child_handle(h_fig,'erosion');
0097 editarea.pb4 = get_child_handle(h_fig,'clear');
0098 editarea.pb5 = get_child_handle(h_fig,'delete');
0099 editarea.pb6 = get_child_handle(h_fig,'overwrite');
0100 editarea.pb7 = get_child_handle(h_fig,'registration');
0101 editarea.pb8 = get_child_handle(h_fig,'undo');
0102 editarea.pb9 = get_child_handle(h_fig,'reverse');
0103 editarea.pb10 = get_child_handle(h_fig,'remove_corpus');
0104 editarea.zt = get_child_handle(h_fig, 'zoom_toggle');
0105 editarea.operation_text = get_child_handle(h_fig, 'operation_text');
0106
0107
0108 set(editarea.ed1,'String','6');
0109 set(editarea.ed2,'String','6');
0110 set(editarea.ed3,'String','0');
0111 set(editarea.ed4,'String',areafile);
0112
0113
0114 keyset = vb_get_keyset_area(areafile);
0115 set(editarea.lb1,'String',keyset);
0116 set(editarea.lb1,'Value',1);
0117
0118
0119 editarea.plot_parm = vb_set_plot_parm;
0120 editarea.plot_parm.index = [];
0121 editarea.plot_parm.LRflag = 'LR';
0122
0123
0124
0125
0126 inst_str = num2str(inst_id);
0127 editarea_str = ['vbmeg_inst.editarea{' inst_str '}'];
0128
0129
0130 command = ['job_edit_area_change_radius(' inst_str ');'];
0131 set(editarea.ed1,'Callback',command);
0132 set(editarea.ed2,'Callback',command);
0133
0134
0135 command = ['job_edit_area_dilation(' inst_str ');'];
0136 set(editarea.pb1,'Callback',command);
0137
0138
0139 command = ['job_edit_area_erosion(' inst_str ');'];
0140 set(editarea.pb2,'Callback',command);
0141
0142
0143 command = ['job_edit_area_clear(' inst_str ');'];
0144 set(editarea.pb4,'Callback',command);
0145
0146
0147 command = ['job_edit_area_delete(' inst_str ');'];
0148 set(editarea.pb5,'Callback',command);
0149
0150
0151 command = ['job_edit_area_overwrite(' inst_str ');'];
0152 set(editarea.pb6,'Callback',command);
0153
0154
0155 command = ['job_edit_area_registration(' inst_str ');'];
0156 set(editarea.pb7,'Callback',command);
0157
0158
0159 command = ['job_edit_area_undo(' inst_str ');'];
0160 set(editarea.pb8,'Callback',command);
0161
0162
0163 command = ['job_edit_area_reverse(' inst_str ');'];
0164 set(editarea.pb9,'Callback',command);
0165
0166
0167 command = ['job_edit_area_remove_corpus(' inst_str ');'];
0168 set(editarea.pb10,'Callback',command);
0169
0170
0171 command = ['global vbmeg_inst; '...
0172 'vbmeg_inst.editarea{' inst_str '}=[];'];
0173 set(h_fig,'DeleteFcn',command);
0174
0175
0176 command = ['job_edit_area_change_zoom(' inst_str ');'];
0177 set(editarea.zt, 'Callback', command);
0178 if vb_matlab_version('<=', '7.5.0')
0179 set(editarea.zt, 'Visible', 'on');
0180 else
0181 str = get(editarea.operation_text, 'String');
0182 zoom_help = ' Zoom: mouse wheel';
0183 set(editarea.operation_text, 'String', [str, zoom_help]);
0184 set(editarea.zt, 'Visible', 'off');
0185 end
0186
0187
0188
0189 set(h_fig,'Renderer','zbuffer');
0190 set(h_fig,'CurrentAxes',editarea.h_space);
0191 axis off;
0192
0193
0194
0195
0196
0197 vbmeg_inst.editarea{inst_id} = editarea;
0198
0199
0200 set(h_fig,'Pointer','arrow');
0201
0202
0203 warning('off', 'MATLAB:colorbar:DeprecatedV6Argument');