-
Notifications
You must be signed in to change notification settings - Fork 1
/
posterCNS.m
173 lines (142 loc) · 7.82 KB
/
posterCNS.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
164
165
166
167
168
169
170
171
172
173
% posterCNS prints and displays everything for the poster for CNS
function [participants, cData, mData, measures] = posterCNS()
addpath import;
[cData, mData, participants, measures] = importTwo(pathFor('leg'), pathFor('arm'));
% Calculate my missing recovery @2ms
addpath missing;
cData(99, 29); % Delete my recov @2ms because it shouldn't be there.
[completeIndices, missIndices] = getCompleteIndices(cData, ~isnan(cData), 1);
missingX = cData(missIndices, :);
completeX = cData(completeIndices, :);
filledX = fillIterate(missingX, completeX, ~isnan(missingX), struct('method', @fillRegr, 'handleNaN', 'mean', 'iterations', 20, 'args', struct()));
myVal = filledX(end, 29);
% Now delete missing data rows
[participants, cData, mData] = deleteNaN(participants, cData, mData);
rmpath import;
greenColor = [0.03529411764705882353, 0.38039215686274509804, 0.2];
redColor = [1 0.1490196078431372549 0];
yellowColor = [0.98039215686274509804 0.8509803921568627451 0.25882352941176470588];
x = cData(:, 29);
y = cData(:, 26);
plotLinearRegression();
plotMeanImputation();
plotPCA();
plotMyRecoveryCycle(myVal);
plotMyTE();
% Now define functions in this function because I'm too lazy to deal with scope.
function plotLinearRegression()
setPlotOptions();
ft = polyfit(x, y, 1);
predictPoint = 93;
fillPoint = polyval(ft, predictPoint);
plot(polyval(ft, [0:140]), 'Color', greenColor, 'LineWidth', 3);
scatter(x, y, 300, '.k');
line([predictPoint predictPoint], [0 fillPoint], 'Color', yellowColor, 'LineStyle', '--', 'LineWidth', 2);
line([0 predictPoint], [fillPoint fillPoint], 'Color', yellowColor, 'LineWidth', 2);
end
function plotMeanImputation(ind)
setPlotOptions();
startPoint = 27;
maxPlot = startPoint + 30;
numMissing = 6;
lastMissing = startPoint + numMissing - 1;
mVal = mean(x(lastMissing+1:maxPlot));
ft = polyfit(x(startPoint:maxPlot), y(startPoint:maxPlot), 1);
plot(polyval(ft, [0:140]), 'Color', greenColor, 'LineWidth', 3);
scatter(x(startPoint:maxPlot), y(startPoint:maxPlot), 300, '.', 'MarkerEdgeColor', greenColor);
scatter(x(startPoint:lastMissing), y(startPoint:lastMissing), 100, '.', 'MarkerEdgeColor', redColor);
mn = ones(numMissing, 1) * mVal;
scatter(mn, y(startPoint:lastMissing), 300, '.', 'MarkerEdgeColor', greenColor);
scatter(mn, y(startPoint:lastMissing), 100, '.', 'MarkerEdgeColor', yellowColor);
filledX = [mn; x(lastMissing+1:maxPlot)];
filledFt = polyfit(filledX, y(startPoint:maxPlot), 1);
plot(polyval(filledFt, [0:140]), 'Color', yellowColor, 'LineWidth', 3);
for i = [1:numMissing]
ptX = x(startPoint + i - 1);
ptY = y(startPoint + i - 1);
line([mVal ptX], [ptY ptY], 'Color', yellowColor, 'LineStyle', '--', 'LineWidth', 1);
end
end
function plotPCA(ind)
setPlotOptions();
set(gcf, 'Position', [100, 100, 600, 400]);
scatter(x, y, 300, '.', 'MarkerEdgeColor', greenColor);
[coeff, score, latent] = pca([x y]);
latent = latent/6.3;
line1XStart = 20;
shiftFactor1 = [line1XStart 0];
scaleFactor1 = latent(1);
arrow(shiftFactor1 + [0 0], shiftFactor1 + scaleFactor1*[coeff(1, 1) coeff(2, 1)], 'Color', [0 0 0], 'LineWidth', 5);
line2XStart = 80;
shiftFactor2 = shiftFactor1 + [line2XStart-line1XStart (line2XStart-line1XStart)*coeff(2, 1)/coeff(1, 1)];
scaleFactor2 = latent(2);
arrow(shiftFactor2 + [0 0], shiftFactor2 + scaleFactor2*[coeff(1, 2) coeff(2, 2)], 'Color', [0 0 0], 'LineWidth', 2, 'Length', 5);
end
function setPlotOptions()
setGlobalPlotOptions();
ylim([0 80]);
xlim([20 140]);
ylabel('Refractoriness at 2.5ms (%)', 'Color', greenColor);
xlabel('Refractoriness at 2ms (%)', 'Color', greenColor);
end
end
function plotMyRecoveryCycle(myVal)
greenColor = [0.03529411764705882353, 0.38039215686274509804, 0.2];
redColor = [1 0.1490196078431372549 0];
yellowColor = [0.98039215686274509804 0.8509803921568627451 0.25882352941176470588];
recovX = [2.5, 3.200000048, 4, 5, 6.300000191, 7.900000095, 10, 13, 18, 24, 32, 42, 56, 75, 100, 140, 200];
recovY = [27.81999969, -9.039999962, -20.84000015, -25.81999969, -24.79999924, -22.45000076, -17.72999954, -14.42000008, -0.180000007, 5.429999828, 9.789999962, 12.85999966, 14.10000038, 12.10999966, 6.75, 4.269999981, 1.460000038];
missX = [2.0];
missY = [myVal];
A = [recovX(9), recovY(9)];
B = [recovX(10), recovY(10)];
xIntercept2 = A(1)-A(2)*(A(1)-B(1))/(A(2)-B(2));
A = [recovX(1), recovY(1)];
B = [recovX(2), recovY(2)];
xIntercept1 = A(1)-A(2)*(A(1)-B(1))/(A(2)-B(2));
setGlobalPlotOptions();
set(gcf, 'Position', [100, 100, 800, 400]);
set(gca, 'XScale', 'log')
line([.5 200], [0 0], 'LineWidth', .25, 'Color', greenColor); % y==0 line
line([1.5 1.5], [-100 100], 'LineStyle', '--', 'LineWidth', 2, 'Color', yellowColor);
line([xIntercept1 xIntercept1], [-100 100], 'LineStyle', '--', 'LineWidth', 2, 'Color', yellowColor);
line([xIntercept2 xIntercept2], [-100 100], 'LineStyle', '--', 'LineWidth', 2, 'Color', yellowColor);
plot(recovX, recovY, '.-', 'Color', greenColor, 'MarkerSize', 30);
line([A(1) missX], [A(2) missY], 'LineStyle', '--', 'LineWidth', 1.5, 'Color', greenColor);
plot(missX, missY, 'o', 'Color', greenColor, 'MarkerSize', 10, 'MarkerFaceColor', yellowColor);
ylim([-30 80]);
xlim([.5 200]);
ylabel('Threshold Change (%)', 'Color', greenColor);
xlabel('Delay (ms)', 'Color', greenColor);
end
function plotMyTE()
greenColor = [0.03529411764705882353, 0.38039215686274509804, 0.2];
redColor = [1 0.1490196078431372549 0];
yellowColor = [0.98039215686274509804 0.8509803921568627451 0.25882352941176470588];
teX1 = [0, 9, 10, 11, 15, 20, 26, 33, 41, 50, 60, 70, 80, 90, 100, 109, 110, 111, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210];
teX2 = [0, 9, 10, 11, 20, 30, 40, 50, 60, 70, 80, 90, 100, 109, 110, 111, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210];
ted40Y = [0, 0, 40.27999878, 44.43999863, 53.09999847, 58.97999954, 64.16999817, 65.26000214, 62.36000061, 55.93000031, 51.11000061, 46.13000107, 44.59000015, 44.08000183, 46, 45.04000092, 3.089999914, 3.640000105, -8.869999886, -13.26000023, -14.96000004, -15.05000019, -13.56000042, -10.59000015, -7.420000076, -6.070000172, -4.300000191, -3.039999962];
teh40Y = [0, 0, -41.93999863, -44.04999924, -60.29999924, -78.79000092, -91.47000122, -99.44000244, -106.8499985, -111.0800018, -119.0899963, -126.1900024, -128.6000061, -130.3300018, -90.25, -87.90000153, -66.83000183, -48.31999969, -32.90999985, -18.21999931, -9.43999958, -1.929999948, 5.199999809, 7.75, 8.970000267, 8.600000381];
ted20Y = [0, 0, 18.57999992, 22.54999924, 30.81999969, 36.13999939, 36.52000046, 38.54000092, 37.20000076, 33.15999985, 30.87999916, 28.86000061, 27.53000069, 27.95000076, 8.199999809, 6.760000229, 0.600000024, -5.519999981, -6.860000134, -8.119999886, -6.489999771, -6.769999981, -5.989999771, -2.950000048, -3.190000057, -1.620000005];
teh20Y = [0, 0, -20.52000046, -22.34000015, -29.12000084, -39.36000061, -43.22000122, -48.13999939, -48.45999908, -49.93999863, -49.79999924, -50.70000076, -50.59999847, -51.54999924, -31.44000053, -30.94000053, -18.30999947, -8.029999733, -1.879999995, 2.75, 6.409999847, 6.5, 6.369999886, 5.860000134, 3.49000001, 2.799999952];
setGlobalPlotOptions();
set(gcf, 'Position', [100, 100, 800, 400]);
line([0 210], [0 0], 'LineWidth', .25, 'Color', greenColor); % y==0 line
plot(teX1, ted40Y, '.-', 'Color', greenColor, 'MarkerSize', 20);
plot(teX2, teh40Y, '.-', 'Color', greenColor, 'MarkerSize', 20);
plot(teX2, ted20Y, '.-', 'Color', greenColor, 'MarkerSize', 20);
plot(teX2, teh20Y, '.-', 'Color', greenColor, 'MarkerSize', 20);
ylim([-150 80]);
xlim([0 210]);
ylabel('Threshold Reduction (%)', 'Color', greenColor);
xlabel('Delay (ms)', 'Color', greenColor);
end
function setGlobalPlotOptions()
greenColor = [0.03529411764705882353, 0.38039215686274509804, 0.2];
figure;
ax = gca;
ax.YColor = greenColor;
ax.XColor = greenColor;
set(gca, 'FontSize', 18);
hold on;
end