-
Notifications
You must be signed in to change notification settings - Fork 12
/
brush_color_number.m
74 lines (65 loc) · 2.27 KB
/
brush_color_number.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
function [zFD,zID] = brush_color_number(hFig,cc,zFD,zID,colorTab,t)
% brush_color.m
% Get brushed data from figure and based on specified color code modify data
% Inputs
% hFig - Figure handle
%
% cc - Keyboard shortcut label
% A string with a keyboard shortcut to label data as:
% 'Number' - Type ID signal
%
% zID - An [N x 2] matrix of detection labeled as ID detections, where
% 1st column contains the detection times and 2nd column an ID
% number associated with the colorTab
%
% colorTab - Color code for classification - ID signal types
% [191, 191, 0] type 1 green
% [191, 0, 191] type 2 purple
% [ 0, 127, 0] type 3 dark-green
% [ 0, 191, 191] type 4 light-blue
% [ 20, 43, 140] type 5 dark-blue
% [218, 179, 255] type 6 pale-purple
% [255, 214, 0] type 7 yellow
% [222, 125, 0] type 8 orange
% [255, 153, 199] type 9 pink
% [153, 51, 0] type 10 brown
%
% t - An [N x 1] vector of detection times from current window session.
%
%
%
% Output:
%
% yell - An [N x 1] vector of indices of highlighted detection times,
% where N is the number of detections.
%
% zFD - An [N x 1] vector of detection times labeled as false detections,
% where N is the number of detections.
%
% zID - An [N x 2] matrix of detection labeled as ID detections, where
% 1st column contains the detection times and 2nd column an ID
% number associated with the colorTab
global dPARAMS
[brushDate, ~, ~] = get_brushed(hFig);
if ~isempty(brushDate)
% Find color code to assign ID signal type
% Write to ID file
disp(['Number of ID Detections = ',num2str(length(brushDate))])
[newIDtimes,~] = intersect(t, brushDate);
% check if already brushed
if ~isempty(zID)
[~,oldIDtimes] = intersect(zID(:,1), newIDtimes);
if ~isempty(oldIDtimes)
% remove any old labels for these times
zID(oldIDtimes, :) = [];
end
end
spLabels = ones(size(newIDtimes)).*cc;
newID = [newIDtimes,spLabels];
zID = [zID;newID];
end
% Remove any ID from FD
if ~isempty(zID)
[~,zFDkeep2] = setdiff(zFD,zID(:,1));
zFD = zFD(zFDkeep2,:);
end