forked from MarineBioAcousticsRC/DetEdit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_brushed.m
34 lines (25 loc) · 841 Bytes
/
get_brushed.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function [brushDate, brushColor, bFlag] = get_brushed(hFig)
brushDate = [];
brushColor = [];
% Find brushed axes
hBrushAll = get(hFig,'Children');
selLine = arrayfun(@(x) hBrushAll(x).Marker == '.', 1:length(hBrushAll), 'UniformOutput', false);
if iscell(selLine)
lenAx = cell2mat(cellfun(@length,selLine,'UniformOutput',false));
selLine(lenAx > 1) = {false};
selLine = cell2mat(selLine);
end
brushedLine = find(selLine,1,'last');
hBrush = hBrushAll(brushedLine);
% Get indices of brushed data
brushID = find(get(hBrush, 'BrushData'));
bFlag = 0;
if ~isempty(brushID)
bFlag = 1;
% Get color info from brush
h = get(brush);
brushColor = round(h.Color*100)./100;
% Get vector of dates associated with these points
markerDates = hBrush.UserData;
brushDate = markerDates(brushID);
end