Skip to content

Commit

Permalink
Right click on a graph can now be used for manual QC. It differs from…
Browse files Browse the repository at this point in the history
… the left click in that instead of highlighting what is included in the box, it highlights what is outside the box.
  • Loading branch information
ggalibert committed Nov 6, 2017
1 parent ee83f35 commit 0ec9dd3
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 38 deletions.
49 changes: 47 additions & 2 deletions Graph/DepthProfile/highlightDepthProfileGeneric.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
% data. If no data points lie within the highlight region,
% an empty matrix is returned.
%
% Author: Paul McCarthy <[email protected]>
% Author: Paul McCarthy <[email protected]>
% Contributor: Guillaume Galibert <[email protected]>
%

%
Expand All @@ -39,4 +40,48 @@
% along with this program.
% If not, see <https://www.gnu.org/licenses/gpl-3.0.en.html>.
%
highlight = highlightTimeSeriesGeneric(region, data, variable, type);
narginchk(4, 4);

if ~isnumeric(region) || ~isvector(region) || length(region) ~= 4
error('region must be a numeric vector of length 4');
end

if ~ishandle(data), error('data must be a graphics handle'); end
if ~isstruct(variable), error('variable must be a struct'); end
if ~ischar(type), error('type must be a string'); end

xdata = get(data(1), 'XData'); % data(1) retrieves the current graphic handles only, in case extra sample is selected
ydata = get(data(1), 'YData');

if iscell(xdata)
xdata = cell2mat(xdata)';
ydata = cell2mat(ydata)';
end

if strcmp(type, 'alt') % right click
% figure out indices of all data points outside the X range but within
% the Y range
xidx = (xdata < region(1)) | (xdata > region(3));
yidx = (ydata >= region(2)) & (ydata <= region(4));
else
% figure out indices of all data points within the X and Y range
xidx = (xdata >= region(1)) & (xdata <= region(3));
yidx = (ydata >= region(2)) & (ydata <= region(4));
end

% figure out indices of all the points to be highlighted
idx = xidx & yidx;

if ~any(idx)
% return nothing if no points to plot
highlight = [];
else
% create the highlight
highlight = line(xdata(idx),ydata(idx), ...
'UserData', idx, ...
'Parent', gca, ...
'LineStyle', 'none', ...
'Marker', 'o', ...
'MarkerEdgeColor', 'white', ...
'MarkerFaceColor', 'white');
end
20 changes: 8 additions & 12 deletions Graph/TimeSeries/highlightTimeSeriesGeneric.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,16 @@
ydata = cell2mat(ydata)';
end

% on right click highlight, only highlight
% unflagged data points in the region
if strcmp(type, 'alt')
f = variable.flags;
f = f == 0;

xdata = xdata(f);
ydata = ydata(f);
if strcmp(type, 'alt') % right click
% figure out indices of all data points within the X range but outside the Y range
xidx = (xdata >= region(1)) & (xdata <= region(3));
yidx = (ydata < region(2)) | (ydata > region(4));
else
% figure out indices of all data points within the X and Y range
xidx = (xdata >= region(1)) & (xdata <= region(3));
yidx = (ydata >= region(2)) & (ydata <= region(4));
end

% figure out indices of all data points within the range
xidx = (xdata >= region(1) & xdata <= region(3));
yidx = (ydata >= region(2) & ydata <= region(4));

% figure out indices of all the points to be highlighted
idx = xidx & yidx;

Expand Down
21 changes: 9 additions & 12 deletions Graph/TimeSeries/highlightTimeSeriesTimeDepth.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,18 @@
Ydata = repmat(ydata', [size(xdata), 1]);
clear xdata ydata;

% figure out indices of all data points within the range
X = ((Xdata >= region(1)) & (Xdata <= region(3)));
Y = ((Ydata >= region(2)) & (Ydata <= region(4)));
if strcmp(type, 'alt') % right click
% figure out indices of all data points within the X range but outside the Y range
X = (Xdata >= region(1)) & (Xdata <= region(3));
Y = (Ydata < region(2)) | (Ydata > region(4));
else
% figure out indices of all data points within the X and Y range
X = (Xdata >= region(1)) & (Xdata <= region(3));
Y = (Ydata >= region(2)) & (Ydata <= region(4));
end
idx = X & Y;
clear X Y;

% on right click, only highlight unflagged points
if strcmp(type, 'alt')

% see if any points in the region haven't been flagged
idx = (variable.flags == 0) & idx;
if ~any(any(variable.flags)), return; end

end

if ~any(any(idx))
highlight = [];
else
Expand Down
21 changes: 9 additions & 12 deletions Graph/TimeSeries/highlightTimeSeriesTimeFrequencyDirection.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,18 @@
Xdata = get(data, 'XData');
Ydata = get(data, 'YData');

% figure out indices of all data points within the range
X = ((Xdata >= region(1)) & (Xdata <= region(3)));
Y = ((Ydata >= region(2)) & (Ydata <= region(4)));
if strcmp(type, 'alt') % right click
% figure out indices of all data points outside the X and Y range
X = ((Xdata < region(1)) | (Xdata > region(3)));
Y = ((Ydata < region(2)) | (Ydata > region(4)));
else
% figure out indices of all data points within the X and Y range
X = (Xdata >= region(1)) & (Xdata <= region(3));
Y = (Ydata >= region(2)) & (Ydata <= region(4));
end
idx = X & Y;
clear X Y;

% on right click, only highlight unflagged points
if strcmp(type, 'alt')

% see if any points in the region haven't been flagged
idx = (variable.flags == 0) & idx;
if ~any(any(variable.flags)), return; end

end

if ~any(any(idx))
highlight = [];
else
Expand Down

0 comments on commit 0ec9dd3

Please sign in to comment.