-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetConfusionMatrixLatexFeldmeyer.m
More file actions
152 lines (118 loc) · 4.91 KB
/
getConfusionMatrixLatexFeldmeyer.m
File metadata and controls
152 lines (118 loc) · 4.91 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
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
% This function just generates the latex code for the confusion
% matrix in the article.
clear all, close all
rng('shuffle')
% Several cells have the same number of branch points, normally
% that is not a problem, but for TRHR there are only 9 cells, 2 of
% which have the same number of branch points (253):
% P40-TRHR-03222012-r2c2-40x.xml
% TRHR-07182012-a1r1-cell1-40x-0.xml
% Odds that in a 5-fold cross validation none of the others are
% picked for four of the folds are:
% (1/5)^6 = 6.4e-5
% When doing 1000 folds we have a 6.4% risk, and well it happened.
r = RGCclass(0);
r.lazyLoad('Feldmeyer');
% featuresUsed = { 'dendriticDensity', ...
% 'somaArea', ...
% 'totalDendriticLength', ...
% 'meanTerminalSegmentLength'};
% featSet = 'Best3Set';
% featSet = 'A12Set';
% featSet = 'ManualUncorrSet';
%featSet = 'Best5';
featSet = 'Feldmeyer';
switch(featSet)
case 'Feldmeyer'
featuresUsed = {'branchAssymetry', 'dendriticDensity', 'numBranchPoints' };
case 'Gulyas'
featuresUsed = {'dendriticField', ...
'fractalDimensionBoxCounting', ...
'meanSegmentLength', ...
'meanSegmentTortuosity', ...
'totalDendriticLength' }
case 'Best3Set'
% Best 3 feature set for classification
featuresUsed = { 'fractalDimensionBoxCounting', ...
'somaArea', ...
'meanTerminalSegmentLength' };
case 'A12Set'
% A good 12 feature set for classification??? Dont remember
featuresUsed = {'branchAssymetry', ...
'dendriticDensity', ...
'dendriticDiameter', ...
'dendriticField', ...
'densityOfBranchPoints', ...
'fractalDimensionBoxCounting', ...
'meanBranchAngle', ...
'meanTerminalSegmentLength', ...
'numBranchPoints', ...
'numSegments', ...
'somaArea', ...
'totalDendriticLength' }
case 'ManualUncorrSet'
% Trying to pick uncorrelated features, using at correlation matrix
featuresUsed = { 'numBranchPoints', ...
'meanSegmentLength', ...
'dendriticField', ...
'totalDendriticLength', ...
'somaArea', ...
'biStratificationDistance', ...
'meanBranchAngle', ...
'meanSegmentTortuosity', ...
'stratificationDepth' };
case 'Best5'
% Best 5 feature set, from exhaustive search
featuresUsed = { 'densityOfBranchPoints', ...
'dendriticField', ...
'fractalDimensionBoxCounting', ...
'meanTerminalSegmentLength', ...
'somaArea' };
case 'Best6'
% Best 6 feature set, from exhaustive search
% Redid it with more iterations (20 vs 5), and then DBP changed to NBP
featuresUsed = { 'numberOfBranchPoints', ...
'dendriticField', ...
'fractalDimensionBoxCounting', ...
'meanSegmentTortuosity', ...
'meanTerminalSegmentLength', ...
'somaArea' };
otherwise
fprintf('Unknown featSet: %s', featSet)
keyboard
end
r.setFeatureMat(featuresUsed);
% [CM,CMsd] = r.confusionMatrixCrossValidation(5,1000);
% disp('\nConfusion matrix with cross validation')
% % strHeader = 'C = \\left[ \\begin{array}{ccccc}\n';
% strLine = ['\\textbf{%s} & $%.2f \\pm %.2f$ & $%.2f \\pm %.2f$ & $%.2f \\pm %.2f$ & $%.2f \\pm %.2f$ & $%.2f \\pm %.2f$\\\\\n'];
% strEnd = '\\end{array} \\right]\n';
% strHeader = ['\\begin{table}\\begin{tabular}{llllll}\n' ...
% '& \\bf{%s} & \\bf{%s} & \\bf{%s} & \\bf{%s} & \\bf{%s}\\\\\n'...
% '\\hline\n'];
% strEnd = '\\end{tabular}\\end{table}\n';
% fprintf(strHeader, ...
% r.RGCtypeName{find(r.RGCtypeID == 1,1)}, ...
% r.RGCtypeName{find(r.RGCtypeID == 2,1)}, ...
% r.RGCtypeName{find(r.RGCtypeID == 3,1)}, ...
% r.RGCtypeName{find(r.RGCtypeID == 4,1)}, ...
% r.RGCtypeName{find(r.RGCtypeID == 5,1)})
% for i = 1:5
% fprintf(strLine, ...
% r.RGCtypeName{find(r.RGCtypeID == i,1)}, ...
% CM(i,1),CMsd(i,1), ...
% CM(i,2),CMsd(i,2), ...
% CM(i,3),CMsd(i,3), ...
% CM(i,4),CMsd(i,4), ...
% CM(i,5),CMsd(i,5))
% end
% fprintf(strEnd)
% truePos = diag(CM)'./sum(CM);
% for i = 1:5
% fprintf('%s: %.1f %%\n', r.RGCtypeName{find(r.RGCtypeID == i,1)}, ...
% truePos(i)*100)
% end
disp('\nConfusion matrix generated with leave one out:')
CM2 = r.confusionMatrixLeaveOneOut();
makeLatexTableHeaders(r.RGCuniqueNames, r.RGCuniqueNames, CM2, ...
'%d','Predicted Class','True Class')