0001 function job_plot_meg_choose_plot_sensor(inst_id, mouse_mode)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 if ~exist('inst_id', 'var')
0018 error('inst_id is a required parameter.');
0019 end
0020 if ~exist('mouse_mode', 'var')
0021 error('mouse_mode is a required parameter.');
0022 end
0023
0024
0025
0026
0027 global vbmeg_inst;
0028 h_space = vbmeg_inst.plotmeg{inst_id}.h_space;
0029
0030 switch(mouse_mode)
0031 case 1
0032 method = vbmeg_inst.plotmeg{inst_id}.sensor_selection_method;
0033
0034
0035
0036 if strcmp(get(gcbf, 'SelectionType'), 'alt')
0037 inner_selection_method_change(inst_id, method);
0038 return;
0039 elseif strcmp(get(gcbf, 'SelectionType'), 'open')
0040
0041 return;
0042 end
0043
0044 job_plot_meg_choose_plot_sensor(inst_id, 'reset');
0045
0046
0047 h_plot = findobj(get(h_space, 'children'), 'Type', 'line');
0048
0049 method = vbmeg_inst.plotmeg{inst_id}.sensor_selection_method;
0050 [ix, Xdata, Ydata] = vb_data_pick_tool('sel', method, ...
0051 'Target', h_plot, ...
0052 'Axes', h_space, ...
0053 'FlagColor', 'k', ...
0054 'FlagEdgeColor', 'w');
0055 if ~isempty(ix)
0056 vbmeg_inst.plotmeg{inst_id}.selected_sensor_XY = [Xdata, Ydata];
0057
0058
0059 job_plot_meg_choose_plot_sensor(inst_id, 'plot');
0060 end
0061
0062
0063
0064
0065 vbmeg_inst.plotmeg{inst_id}.selected_sensor = ix;
0066
0067
0068
0069
0070 define_job_plot_meg_const;
0071 job_plot_meg_update_timecourse(inst_id, FORCE_UPDATE);
0072
0073 case 'plot'
0074
0075 XYdata = vbmeg_inst.plotmeg{inst_id}.selected_sensor_XY;
0076 if ~isempty(XYdata)
0077 hold on;
0078 vbmeg_inst.plotmeg{inst_id}.selected_sensor_plot = ...
0079 plot(XYdata(:,1), XYdata(:,2), 'wo', 'MarkerFaceColor', 'k');
0080 end
0081 case 'reset'
0082 inner_remove_selected_point(inst_id);
0083 vbmeg_inst.plotmeg{inst_id}.selected_sensor_name= cell(0);
0084 vbmeg_inst.plotmeg{inst_id}.selected_sensor = [];
0085 vbmeg_inst.plotmeg{inst_id}.selected_sensor_XY = [];
0086 vbmeg_inst.plotmeg{inst_id}.selected_sensor_plot= [];
0087 otherwise
0088 error('Unknown mouse operation was detected.');
0089 end
0090
0091 function inner_remove_selected_point(inst_id)
0092
0093 global vbmeg_inst;
0094 if ~isfield(vbmeg_inst.plotmeg{inst_id}, 'selected_sensor_plot')
0095 return;
0096 end
0097 objects = vbmeg_inst.plotmeg{inst_id}.selected_sensor_plot;
0098 if ~isempty(objects)
0099 for k=1:length(objects)
0100 if ishandle(objects(k)) && ~isempty(ishandle(objects(k)))
0101
0102 delete(objects(k));
0103 end
0104 end
0105 end
0106 vbmeg_inst.plotmeg{inst_id}.selected_sensor_plot = [];
0107
0108 function inner_selection_method_change(inst_id, current_method)
0109
0110
0111 cmenu = uicontextmenu;
0112 sel_menu = uimenu(cmenu,'label','Sensor selection method');
0113
0114 callback = ['global vbmeg_inst; vbmeg_inst.plotmeg{' num2str(inst_id), ...
0115 '}.sensor_selection_method = '];
0116
0117 h1 = uimenu(sel_menu, 'Label','Brush', 'Callback', [callback, '''Brush'';']);
0118 h2 = uimenu(sel_menu, 'Label','Lasso', 'Callback', [callback, '''Lasso'';']);
0119 h3 = uimenu(sel_menu, 'Label','Rect', 'Callback', [callback, '''Rect'';']);
0120
0121 switch(current_method)
0122 case 'Brush'
0123 set(h1, 'Checked', 'on');
0124 case 'Lasso'
0125 set(h2, 'Checked', 'on');
0126 case 'Rect'
0127 set(h3, 'Checked', 'on');
0128 end
0129 set(gca, 'UIContextMenu', cmenu);
0130
0131