Browse code

X-SOM finished!

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@173 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on 07/04/2009 15:54:26
Showing 5 changed files
... ...
@@ -135,8 +135,8 @@ switch task
135 135
         display('SOM');
136 136
         disp('not implemented')
137 137
 
138
-    case 'X-SOM'
139
-        display('X-SOM');
138
+    case 'XSOM'
139
+        display('XSOM');
140 140
         somopts.size = [3 3];
141 141
         somopts.lattice = 'rect';
142 142
         decode = som_xsubject_performance(header,data,somopts);
... ...
@@ -1,6 +1,21 @@
1
-function decode = som_decode(sD, sM, svm_validation_data,svm_validation_label)
1
+function decode = som_decode(sM, svm_validation_data,svm_validation_label)
2 2
 % the number of hits in each map-unit.
3 3
 
4
-sValD = som_data_struct(svm_validation_data,'label',num2str(svm_validation_label));
5
-h   = som_hits(sM,sValD);
6
-bmu = som_bmus(sM, sValD, 'best');
7 4
\ No newline at end of file
5
+sValD = som_data_struct(svm_validation_data,'labels',num2str(svm_validation_label));
6
+% h   = som_hits(sM,sValD);
7
+bmu = som_bmus(sM, sValD, 'best');
8
+
9
+correct = 0;
10
+nElements = length(svm_validation_label);
11
+nBMUs = length(bmu);
12
+
13
+for i = 1:nBMUs
14
+    if isnan(bmu(i))
15
+        nElements = nElements - 1;
16
+    elseif ( cell2mat(sM.labels(bmu(i))) == cell2mat(sValD.labels(i)) )
17
+        correct = correct + 1;
18
+    end
19
+end
20
+    
21
+decode = correct/nElements*100;
22
+end
8 23
\ No newline at end of file
... ...
@@ -3,15 +3,10 @@ function [sD sM] = som_train(svmlabel, svmdata, somOptions)
3 3
 som_size = somOptions.size;
4 4
 som_lattice = somOptions.lattice;
5 5
 
6
-display('SOM TRAINING');
7 6
 addpath 'somtoolbox2';
8
-sD = som_data_struct(svmdata,'label',num2str(svmlabel));
9
-assignin('base','sD',sD);
10
-sM = som_make(sD,'msize', som_size,'lattice', som_lattice);
7
+sD = som_data_struct(svmdata,'labels',num2str(svmlabel));
11 8
 
9
+sM = som_make(sD,'msize', som_size,'lattice', som_lattice);
12 10
 sM = som_autolabel(sM,sD,'vote');
13 11
 
14
-assignin('base','sD',sD);
15
-assignin('base','sM',sM);
16
-display('type ''figure'' before visualisation');
17 12
 end
18 13
\ No newline at end of file
... ...
@@ -67,7 +67,7 @@ for timeIndex = 1:timeLineEnd-timeLineStart+1
67 67
 
68 68
         [sD sM] = som_train(svm_train_label, svm_train_data, somOpts);
69 69
 
70
-        performance = som_decode(sD, sM, svm_validation_data,svm_validation_label);
70
+        performance = som_decode(sM, svm_validation_data,svm_validation_label);
71 71
         
72 72
         cross_value = [cross_value performance];
73 73
     end
74 74
deleted file mode 100644
... ...
@@ -1,17 +0,0 @@
1
-function [sD sM] = train_som(svmlabel, svmdata, somOptions)
2
-
3
-som_size = somOptions.size;
4
-som_lattice = somOptions.lattice;
5
-
6
-display('SOM TRAINING');
7
-addpath 'somtoolbox2';
8
-sD = som_data_struct(svmdata,'label',num2str(svmlabel));
9
-assignin('base','sD',sD);
10
-sM = som_make(sD,'msize', som_size,'lattice', som_lattice);
11
-
12
-sM = som_autolabel(sM,sD,'vote');
13
-
14
-assignin('base','sD',sD);
15
-assignin('base','sM',sM);
16
-display('type ''figure'' before visualisation');
17
-end
18 0
\ No newline at end of file