-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalcEfficacies.m
73 lines (69 loc) · 1.82 KB
/
CalcEfficacies.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 [Mx, Mc, details] = CalcEfficacies(C, varargin)
%E= CalcEfficacies(C, varargin) Calc Efficacy for all pairs in a Cluster/Expt set
%E= CalcEfficacies(Expts,) works on expt set - these should he different
%cells,same expt
%E= CalcEfficacies(Expts,'adjacent') does only adjacent pais
adjacentonly = 0;
verbose = 1;
j = 1;
while j <= length(varargin)
if strncmpi(varargin{j},'adjacent',5)
adjacentonly = 1;
elseif strncmpi(varargin{j},'verbose',5)
adjacentonly = 1;
end
j = j+1;
end
nc = 0;
if iscell(C) && isfield(C{1},'Trials') %expt list
E = C;
C = expt.spktimes(E);
elseif isfield(C,'Spikes') && iscell(C.Spikes) %AllExpt struct
E = All2Expt(C,'all');
C = expt.spktimes(E);
end
for j = 1:length(C)
if isnumeric(C{j}) %cell array of timee
nc = nc+1;
spkt{nc} = C{j};
else
if isfield(C{j},'times')
nc = nc+1;
spkt{nc} = C{j}.times;
end
for c = 1:length(C{j}.next)
if isfield(C{j}.next{c},'times') && ~isempty(C{j}.next{c}.times)
nc = nc+1;
spkt{nc} = C{j}.next{c}.times;
end
end
end
end
if adjacentonly
for j = 1:length(spkt)-1
e = CalcEfficacy(spkt{j},spkt{j+1});
Mx(j,1) = e(1);
Mx(j,2) = e(2);
end
else
for j = 1:length(spkt)
if verbose
fprintf('Cell %d %s\n',GetCellNumber(E{j}),datestr(now));
end
for k = 1:j-1
[e, edetails] = CalcEfficacy(spkt{j},spkt{k},varargin{:});
if ~isempty(edetails)
details(j,k) = edetails;
end
if length(e) > 5
Mx(j,k) = e(5);
Mx(k,j) = e(6);
else
Mx(j,k) = e(1);
Mx(k,j) = e(2);
end
Mc(j,k) = e(3);
Mc(k,j) = e(4);
end
end
end