-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathScouseTom_ard_compestimatebadelec.m
More file actions
46 lines (31 loc) · 1.17 KB
/
ScouseTom_ard_compestimatebadelec.m
File metadata and controls
46 lines (31 loc) · 1.17 KB
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
function [ BadElecs ] = ScouseTom_ard_compestimatebadelec( BadArray,Protocol )
%SCOUSETOM_ARD_COMPESTIMATEBADELEC Estimate which electodes are bad from
%array of compliance status - from ard_complianceprocess. If an electrode
%is bad every time it is used then it is flagged as bad. There may be
%smarter ways of doing this....
% Detailed explanation goes here
%% Check the inputs here
%i cant remember if the output is a logical or not
BadArray=logical(BadArray);
if ~(any(BadArray))
%return nothing is none are bad
BadElecs =[];
return
end
%Find electrodes used
AllElec=unique(Protocol(:));
ElecCount=histc(Protocol(:),AllElec);
%% Find the injections belonging to bad compliances
%take only the protocol lines with bad compliance
BadProtLines=Protocol(BadArray,:);
%make all onecolumn
BadProtLines=BadProtLines(:);
%find the unique values
PossBadElecs=unique(BadProtLines);
[~,ElecIdx]=ismember(PossBadElecs,AllElec);
%find the number of times
BadCount=histc(BadProtLines,PossBadElecs);
% if the number of times it is bad is three quarters of the number of times it is used then
% it is bad
BadElecs=PossBadElecs((BadCount >= 0.75*ElecCount(ElecIdx)));
end