Home > vbmeg > functions > job > job_plot_meg_dir > job_plot_meg_choose_plot_sensor.m

job_plot_meg_choose_plot_sensor

PURPOSE ^

Choose plot sensor on contourmap.

SYNOPSIS ^

function job_plot_meg_choose_plot_sensor(inst_id, mouse_mode)

DESCRIPTION ^

 Choose plot sensor on contourmap.

 [Usage]
    job_plot_meg_choose_plot_sensor(inst_id, mouse_mode)

 [Input]
       inst_id : instance id
    mouse_mode : 1: mouse down event.
   
 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function job_plot_meg_choose_plot_sensor(inst_id, mouse_mode)
0002 % Choose plot sensor on contourmap.
0003 %
0004 % [Usage]
0005 %    job_plot_meg_choose_plot_sensor(inst_id, mouse_mode)
0006 %
0007 % [Input]
0008 %       inst_id : instance id
0009 %    mouse_mode : 1: mouse down event.
0010 %
0011 % Copyright (C) 2011, ATR All Rights Reserved.
0012 % License : New BSD License(see VBMEG_LICENSE.txt)
0013 
0014 %
0015 % --- Previous check
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 % --- Main Procedure
0026 %
0027 global vbmeg_inst;
0028 h_space = vbmeg_inst.plotmeg{inst_id}.h_space; % contour axes handle
0029 
0030 switch(mouse_mode)
0031     case 1
0032         method = vbmeg_inst.plotmeg{inst_id}.sensor_selection_method;
0033 
0034         %get(gcbf, 'SelectionType');
0035         % show sensor selection method menu by right clicking.
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             % double click
0041             return;
0042         end
0043         % reset selection state
0044         job_plot_meg_choose_plot_sensor(inst_id, 'reset');
0045 
0046         % Get sensor coordinate value on contour map
0047         h_plot = findobj(get(h_space, 'children'), 'Type', 'line');
0048         % Select sensor
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             % Plot marker
0059             job_plot_meg_choose_plot_sensor(inst_id, 'plot');
0060         end
0061 
0062         %
0063         % --- Set selected sensor index to data structure.
0064         %
0065         vbmeg_inst.plotmeg{inst_id}.selected_sensor     = ix;
0066 
0067         %
0068         % --- Plot timecourse
0069         %
0070         define_job_plot_meg_const;
0071         job_plot_meg_update_timecourse(inst_id, FORCE_UPDATE);
0072 
0073     case 'plot'
0074         % Plot marker
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             %disp('All points are deleted.');
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 % Create the UICONTEXTMENU
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

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005