forked from JaneliaSciComp/JRCLUST
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sc_auto.m
80 lines (73 loc) · 2.89 KB
/
sc_auto.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
74
75
76
77
78
79
80
function autoCall = sc_auto( firingRate, cData )
vpp = cData.vpp;
SNR = cData.SNR;
ISIRatio = cData.ISIRatio;
ISIViolations = cData.ISIViolations;
IsoDist = cData.IsoDist;
firing_std = cData.firingStd;
SNR_high_thresh = 6;
SNR_low_thresh = 2.5; %for low > SNR > high, check the isolation distance
%SNR_multi_thresh = 2; %Too little signal to be sure of separation from background, useful if uniform firing
ISIRatio_single_thresh = 0.005; %(max 0.5%)
ISIRatio_ok_thresh = 0.015;
ISIViolations_thresh = 5;
iso_thresh = 100;
firingRate_thresh = 0.05; %in Hz
firing_std_thresh = 0.5;
autoCall = "None";
if firingRate < firingRate_thresh
return;
end
if (SNR >= SNR_high_thresh)
% call a single if ISI conditions are met
% check the ISI
if ( (ISIRatio <= ISIRatio_single_thresh) || (ISIViolations <= ISIViolations_thresh) )
autoCall = "single";
return;
elseif (ISIRatio <= ISIRatio_ok_thresh)
autoCall = "ok";
else
if firing_std < 0.5*firing_std_thresh
autoCall = "multi";
elseif firing_std < firing_std_thresh
autoCall = "multi/None";
end
end
elseif (SNR >= SNR_low_thresh)
% if isolated, can be a single or ok
if (isnan(IsoDist) || IsoDist > iso_thresh )
if ( (ISIRatio <= ISIRatio_single_thresh) || (ISIViolations <= ISIViolations_thresh) )
autoCall = "single/ok"; % whether unit is good enough to be single a function of human judged isolation
return;
elseif (ISIRatio <= ISIRatio_ok_thresh)
autoCall = "ok"; % Ok
else
if firing_std < 0.5*firing_std_thresh
autoCall = "multi";
elseif firing_std < firing_std_thresh
autoCall = "multi/None";
end
end
else
% if not isolated, call as a multi/ok if ISI is low enough
% otherwise call as multi if unniform enough
if ( (ISIRatio <= ISIRatio_ok_thresh) || (ISIViolations <= ISIViolations_thresh))
autoCall = "ok";
else
if firing_std < 0.5*firing_std_thresh
autoCall = "multi";
elseif firing_std < firing_std_thresh
autoCall = "multi/None";
end
end
end
% elseif (SNR >= SNR_multi_thresh)
% % just check for stable firing. If "quite stable" very likely
% % qualifies as a analyzable MUA; otherwise up to curator
% if firing_std < 0.5*firing_std_thresh
% autoCall = "multi";
% elseif firing_std < firing_std_thresh
% autoCall = "multi/None";
% end
end
end