Browse code

new labels, some cleanup

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

Christoph Budziszewski authored on07/08/2009 17:23:37
Showing1 changed files
... ...
@@ -1,7 +1,6 @@
1
-%% subject loop
2 1
 function decode = som_subject_batch(header,subjectdata,somOpts)
3
-
4
-addpath(fullfile(getTbxPath,'somtoolbox2'));
2
+global NODALYZE_SOMTOOLBOX;
3
+addpath(fullfile(getTbxPath,NODALYZE_SOMTOOLBOX));
5 4
 
6 5
 RANDOMIZE_DATAPOINTS = somOpts.rnd;
7 6
 NAN_AS_ZERO = somOpts.nantozero;
Browse code

spm2 compatibility, start change study

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

Christoph Budziszewski authored on22/05/2009 11:16:41
Showing1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 %% subject loop
2 2
 function decode = som_subject_batch(header,subjectdata,somOpts)
3 3
 
4
-addpath 'somtoolbox2';
4
+addpath(fullfile(getTbxPath,'somtoolbox2'));
5 5
 
6 6
 RANDOMIZE_DATAPOINTS = somOpts.rnd;
7 7
 NAN_AS_ZERO = somOpts.nantozero;
Browse code

added some batch files, workaround for NAN - Bug

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

Christoph Budziszewski authored on23/04/2009 16:48:20
Showing1 changed files
... ...
@@ -3,7 +3,8 @@ function decode = som_subject_batch(header,subjectdata,somOpts)
3 3
 
4 4
 addpath 'somtoolbox2';
5 5
 
6
-RANDOMIZE_DATAPOINTS = 1;
6
+RANDOMIZE_DATAPOINTS = somOpts.rnd;
7
+NAN_AS_ZERO = somOpts.nantozero;
7 8
 
8 9
 decode = struct;
9 10
 decode.decodePerformance = [];
... ...
@@ -62,9 +63,18 @@ for subjectDataID = 1:nSubjects
62 63
             svm_train_label(chunkstart:chunkend) = []; %del test set
63 64
             svm_train_data(chunkstart:chunkend,:) = [];% del test set
64 65
 
65
-            [sD sM] = som_train(svm_train_label, svm_train_data, somOpts);
66
-
67
-            performance = som_decode(sM, svm_validation_data,svm_validation_label);
66
+            if NAN_AS_ZERO
67
+                svm_train_data(isnan(svm_train_data))=0;
68
+                svm_validation_data(isnan(svm_validation_data))=0;
69
+                display('NaN to 0');
70
+            end
71
+            
72
+            if isempty(svm_train_data)
73
+                performance = 0;
74
+            else
75
+                [sD sM] = som_train(svm_train_label, svm_train_data, somOpts);
76
+                performance = som_decode(sM, svm_validation_data,svm_validation_label);
77
+            end
68 78
 
69 79
             cross_value = [cross_value, performance];
70 80
         end
Browse code

all features implemented.

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

Christoph Budziszewski authored on07/04/2009 17:00:53
Showing1 changed files
... ...
@@ -35,7 +35,7 @@ for subjectDataID = 1:nSubjects
35 35
 
36 36
     display(sprintf('%u -fold cross validation for %u timeslices.\n',somOpts.nfold,size(1:timeLineEnd-timeLineStart+1,2)));
37 37
 
38
-
38
+    decode_timeline = [];
39 39
     for timeIndex = 1:timeLineEnd-timeLineStart+1
40 40
         svmstruct = calculateSVMTables(timePointMatrix{subjectDataID},timeIndex);
41 41
         nElements = length(svmstruct.svmlabel);
... ...
@@ -68,8 +68,9 @@ for subjectDataID = 1:nSubjects
68 68
 
69 69
             cross_value = [cross_value, performance];
70 70
         end
71
-        decode.decodePerformance = [decode.decodePerformance; cross_value];
71
+        decode_timeline = [decode_timeline; mean(cross_value)];
72 72
     end
73
+    decode.decodePerformance = [decode.decodePerformance decode_timeline];
73 74
 end
74 75
 display('decode done');
75 76
 end
Browse code

SOM Single run

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

Christoph Budziszewski authored on07/04/2009 16:43:52
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,76 @@
1
+%% subject loop
2
+function decode = som_subject_batch(header,subjectdata,somOpts)
3
+
4
+addpath 'somtoolbox2';
5
+
6
+RANDOMIZE_DATAPOINTS = 1;
7
+
8
+decode = struct;
9
+decode.decodePerformance = [];
10
+decode.rawTimeCourse     = [];
11
+
12
+nSubjects = numel(subjectdata);
13
+disp(sprintf('batch processing %u subjects',nSubjects));
14
+
15
+timeline = header.timeline;
16
+timeline.frameShiftStart = header.frameShift.frameShiftStart;
17
+timeline.frameShiftEnd   = header.frameShift.frameShiftEnd;
18
+timeline.decodeDuration  = header.frameShift.decodeDuration;
19
+
20
+
21
+timeLineStart   = timeline.frameShiftStart;
22
+timeLineEnd     = timeline.frameShiftEnd;
23
+
24
+% TimePointMatrix
25
+for subjectDataID = 1:nSubjects
26
+    currentSubject = subjectdata{subjectDataID};
27
+    timePointArgs.pst           = currentSubject.pst;
28
+    timePointArgs.labelMap      = LabelMap(header.classDef.labelCells,header.classDef.conditionCells);
29
+    timePointArgs.eventList     = header.classDef.eventMatrix;
30
+
31
+    timePointMatrix{subjectDataID} = buildTimePointMatrix(timeline,timePointArgs);
32
+
33
+    decode.rawTimeCourse = [decode.rawTimeCourse currentSubject.pst];
34
+
35
+
36
+    display(sprintf('%u -fold cross validation for %u timeslices.\n',somOpts.nfold,size(1:timeLineEnd-timeLineStart+1,2)));
37
+
38
+
39
+    for timeIndex = 1:timeLineEnd-timeLineStart+1
40
+        svmstruct = calculateSVMTables(timePointMatrix{subjectDataID},timeIndex);
41
+        nElements = length(svmstruct.svmlabel);
42
+
43
+        if RANDOMIZE_DATAPOINTS
44
+            rndindex  = randperm(nElements);
45
+            svmstruct.svmdata   = svmstruct.svmdata(rndindex,:);
46
+            svmstruct.svmlabel  = svmstruct.svmlabel(rndindex);
47
+        end
48
+
49
+        chunksize = nElements / somOpts.nfold;
50
+        
51
+        cross_value = 0;
52
+        for iFold = 1:somOpts.nfold
53
+            chunkstart = (iFold-1)*chunksize+1;
54
+            chunkend   = min(iFold*chunksize,nElements);
55
+
56
+            svm_train_label = svmstruct.svmlabel;
57
+            svm_train_data  = svmstruct.svmdata;
58
+
59
+            svm_validation_label = svmstruct.svmlabel(chunkstart:chunkend);
60
+            svm_validation_data  = svmstruct.svmdata(chunkstart:chunkend,:);
61
+
62
+            svm_train_label(chunkstart:chunkend) = []; %del test set
63
+            svm_train_data(chunkstart:chunkend,:) = [];% del test set
64
+
65
+            [sD sM] = som_train(svm_train_label, svm_train_data, somOpts);
66
+
67
+            performance = som_decode(sM, svm_validation_data,svm_validation_label);
68
+
69
+            cross_value = [cross_value, performance];
70
+        end
71
+        decode.decodePerformance = [decode.decodePerformance; cross_value];
72
+    end
73
+end
74
+display('decode done');
75
+end
76
+