0001 function job_edit_area(areafile,brainfile)
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.pb3 = get_child_handle(h_fig,'rotation');
0098 editarea.pb4 = get_child_handle(h_fig,'clear');
0099 editarea.pb5 = get_child_handle(h_fig,'delete');
0100 editarea.pb6 = get_child_handle(h_fig,'overwrite');
0101 editarea.pb7 = get_child_handle(h_fig,'registration');
0102 editarea.pb8 = get_child_handle(h_fig,'undo');
0103 editarea.pb9 = get_child_handle(h_fig,'reverse');
0104 editarea.pb10 = get_child_handle(h_fig,'remove_corpus');
0105
0106
0107 set(editarea.ed1,'String','6');
0108 set(editarea.ed2,'String','6');
0109 set(editarea.ed3,'String','0');
0110 set(editarea.ed4,'String',areafile);
0111
0112
0113 keyset = vb_get_keyset_area(areafile);
0114 set(editarea.lb1,'String',keyset);
0115 set(editarea.lb1,'Value',1);
0116
0117
0118 editarea.plot_parm = vb_set_plot_parm;
0119 editarea.plot_parm.index = [];
0120 editarea.plot_parm.LRflag = 'LR';
0121
0122
0123
0124
0125 inst_str = num2str(inst_id);
0126 editarea_str = ['vbmeg_inst.editarea{' inst_str '}'];
0127
0128
0129 command = ['job_edit_area_change_radius(' inst_str ');'];
0130 set(editarea.ed1,'Callback',command);
0131 set(editarea.ed2,'Callback',command);
0132
0133
0134 command = ['job_edit_area_dilation(' inst_str ');'];
0135 set(editarea.pb1,'Callback',command);
0136
0137
0138 command = ['job_edit_area_erosion(' inst_str ');'];
0139 set(editarea.pb2,'Callback',command);
0140
0141
0142 command = ['global vbmeg_inst;' ...
0143 'h_space = ' editarea_str '.h_space;' ...
0144 'rotate3d(h_space);'];
0145 set(editarea.pb3,'Callback',command);
0146
0147
0148 command = ['job_edit_area_clear(' inst_str ');'];
0149 set(editarea.pb4,'Callback',command);
0150
0151
0152 command = ['job_edit_area_delete(' inst_str ');'];
0153 set(editarea.pb5,'Callback',command);
0154
0155
0156 command = ['job_edit_area_overwrite(' inst_str ');'];
0157 set(editarea.pb6,'Callback',command);
0158
0159
0160 command = ['job_edit_area_registration(' inst_str ');'];
0161 set(editarea.pb7,'Callback',command);
0162
0163
0164 command = ['job_edit_area_undo(' inst_str ');'];
0165 set(editarea.pb8,'Callback',command);
0166
0167
0168 command = ['job_edit_area_reverse(' inst_str ');'];
0169 set(editarea.pb9,'Callback',command);
0170
0171
0172 command = ['job_edit_area_remove_corpus(' inst_str ');'];
0173 set(editarea.pb10,'Callback',command);
0174
0175
0176 command = ['global vbmeg_inst; '...
0177 'vbmeg_inst.editarea{' inst_str '}=[];'];
0178 set(h_fig,'DeleteFcn',command);
0179
0180
0181
0182 set(h_fig,'Renderer','zbuffer');
0183 set(h_fig,'CurrentAxes',editarea.h_space);
0184 axis off;
0185
0186
0187
0188
0189
0190 vbmeg_inst.editarea{inst_id} = editarea;
0191
0192
0193 set(h_fig,'Pointer','arrow');