-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDrawMeanChange.m
163 lines (143 loc) · 4.49 KB
/
DrawMeanChange.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
function DrawMeanChange(Organized)
ExpList = GetExperimentList(Organized);
Conditions = Organized.Conditions;
for n = 1:length(Conditions)
Condition = Conditions{n};
if(strcmp(Condition, 'ptx'))
continue;
end
NoZero = 0; %don't exclude zero-frequency from consideration
for SpikesPerBurst = 0:2
%if SpikesPerBurst = 0, analyze everything
%if SpikesPerBurst = 1, analyze only networks with 1 spike per
% burst in either condition
%if SpikesPerBurst > 1, analyze only networks with spikes per
% burst > 1 in both conditions
[FreqControl, FreqMod] = GetAvgFreqs(Organized, ExpList, NoZero, ...
SpikesPerBurst, Condition);
PlotMeanChangeFigure(FreqControl, FreqMod, NoZero, SpikesPerBurst, ...
Condition);
end
end
return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function ExpList = GetExperimentList(Organized)
Nums = Organized.ExpNum;
ExpList = Nums(1);
for n = 2:length(Nums)
if(length(find(ExpList == Nums(n))) == 0)
ExpList = [ExpList, Nums(n)];
end
end
return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [FreqControl, FreqMod] = GetAvgFreqs(Organized, ExpList, ...
ExcludeZeros, ...
SpikesPerBurst, Condition)
FreqControl = zeros(size(ExpList));
FreqMod = zeros(size(ExpList));
NumExp = length(ExpList);
Type_Mod = sprintf('Type_%s', Condition);
SpikesPerBurst_ptx = GetSpikesPerBurst(Organized.Analysis_ptx);
Analysis_mod = Organized.(sprintf('Analysis_%s', Condition));
SpikesPerBurst_mod = GetSpikesPerBurst(Analysis_mod);
for n = 1:NumExp
ExpNum = ExpList(n);
Ind = find(Organized.ExpNum == ExpNum);
FListControl = Organized.Type_ptx(Ind);
FListMod = Organized.(Type_Mod)(Ind);
SPB_ptx = SpikesPerBurst_ptx(Ind);
SPB_mod = SpikesPerBurst_mod(Ind);
if(ExcludeZeros)
ControlInd = find(FListControl ~= 0 & ...
isfinite(FListControl) & ...
isfinite(FListMod));
else
ControlInd = find(isfinite(FListControl) & ...
isfinite(FListMod));
end
switch(SpikesPerBurst)
case 0,
SpikeString = '';
case 1,
SpikeString = ' and One Spike Per Burst';
Ind2 = find(SPB_ptx == 1 | SPB_mod == 1);
ControlInd = intersect(ControlInd, Ind2);
otherwise,
SpikeString = ' and >1 Spike Per Burst';
Ind2 = find(SPB_ptx > 1 & SPB_mod > 1);
ControlInd = intersect(ControlInd, Ind2);
end
ModInd = ControlInd;
FreqControl(n) = sum(FListControl(ControlInd)) / length(ControlInd);
FreqMod(n) = sum(FListMod(ModInd)) / length(ModInd);
end
[TTestVal, PVal] = ttest(FreqControl, FreqMod, .05, 'both');
if(ExcludeZeros)
ExcludeString = 'zeros excluded';
else
ExcludeString = 'zeros not excluded';
end
TestString = sprintf('t-test with %s%s for %s: p-value = %g', ...
ExcludeString, SpikeString, Condition, PVal);
disp(TestString)
return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function PlotMeanChangeFigure(FreqControl, FreqMod, ExcludeZeros, ...
SpikesPerBurst, Condition)
if(ExcludeZeros)
ExcludeString = 'Zeros Excluded';
else
ExcludeString = 'Zeros Not Excluded';
end
switch(SpikesPerBurst)
case 0,
SpikeString = '';
case 1,
SpikeString = ' and One Spike Per Burst';
otherwise,
SpikeString = ' and >1 Spike Per Burst';
end
Title = sprintf('Mean Change for %s with %s%s', Condition, ...
ExcludeString, SpikeString);
h = NamedFigure(Title);
% setting colors
my_colors = colormap(cool(length(FreqControl)));
set(h,'DefaultAxesColorOrder',my_colors);
set(h, 'WindowStyle', 'docked');
xMat = repmat([1 2], length(FreqControl), 1);
yMat = [FreqControl', FreqMod'];
plot(xMat', yMat', '-o');
ylabel('Frequency (Hz)');
axis([0 3 -0.1 1.2]);
title(Title);
Axes_h = get(h, 'CurrentAxes');
set(Axes_h, 'FontName', 'Ariel');
set(Axes_h, 'FontSize', [15]);
return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function SpikesPerBurst = GetSpikesPerBurst(AnalysisList)
Len = length(AnalysisList);
SpikesPerBurst = zeros(Len, 2);
for n=1:Len
Temp = AnalysisList(n);
if(length(Temp.Cell0) == 0 || length(Temp.Cell1) == 0)
continue
end
try
SpikesPerBurst(n,1) = Temp.Cell0.Burst.NumSpikes.Mean;
SpikesPerBurst(n,2) = Temp.Cell1.Burst.NumSpikes.Mean;
if(SpikesPerBurst(n,1) == 0)
SpikesPerBurst(n,1) = 1;
end
if(SpikesPerBurst(n,2) == 0)
SpikesPerBurst(n,2) = 1;
end
catch
Temp
whos
error('poo')
end
end
SpikesPerBurst = max(SpikesPerBurst, [], 2);
return