2de68580da57ab65d0ef35a9dc1e821e797d861d
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

1) %% subject loop
2) function decode = xsvm_subject_loop(header,subjectdata,svmopts)
3) 
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

4) addpath 'libsvm-mat-2.88-1';
5) 
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

6) nSubjects = numel(subjectdata);
7) 
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

8) RANDOMIZE_DATAPOINTS = 0;
9) 
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

10) decode = struct;
11) decode.decodePerformance = [];
12) decode.rawTimeCourse     = [];
13) 
Christoph Budziszewski nSubject-fold cross validat...

Christoph Budziszewski authored 15 years ago

14) disp(sprintf('computinig additional datastructs for %u subjects',nSubjects));
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

15) 
16) timeline = header.timeline;
17) 
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

18) % TimePointMatrix
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

19) for subjectDataID = 1:nSubjects
20)     currentSubject = subjectdata{subjectDataID};
21)     timePointArgs.pst           = currentSubject.pst;
22)     timePointArgs.labelMap      = LabelMap(header.classDef.labelCells,header.classDef.conditionCells);
23)     timePointArgs.eventList     = header.classDef.eventMatrix;
24) 
25)     timePointMatrix{subjectDataID} = buildTimePointMatrix(timeline,timePointArgs);
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

26)     
27)     decode.rawTimeCourse = [decode.rawTimeCourse currentSubject.pst];
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

28) end
29) 
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

30) % timeframe x-subject validation
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

31) timeLineStart   = timeline.frameShiftStart;
32) timeLineEnd     = timeline.frameShiftEnd;
33) 
Christoph Budziszewski nSubject-fold cross validat...

Christoph Budziszewski authored 15 years ago

34) display(sprintf('%u -fold cross validation for %u timeslices.\n',nSubjects,size(1:timeLineEnd-timeLineStart+1,2)));
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

35) % disp(sprintf('Press ANY-Key to continue.\n Use Retrun if your Keyboard lacks the ANY-Key.'));
36) % pause
37) 
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

38) for timeIndex = 1:timeLineEnd-timeLineStart+1
Christoph Budziszewski nSubject-fold cross validat...

Christoph Budziszewski authored 15 years ago

39)     cross_value = [];
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

40)     for validationSubjectID = 1:nSubjects
Christoph Budziszewski nSubject-fold cross validat...

Christoph Budziszewski authored 15 years ago

41)         svm_train_label = [];
42)         svm_train_data  = [];
43)         svm_validation_label = [];
44)         svm_validation_data  = [];
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

45)         for subjectDataID = 1:nSubjects
46)             svmstruct = calculateSVMTables(timePointMatrix{subjectDataID},timeIndex);
47)             if subjectDataID == validationSubjectID
48)                 svm_validation_label = svmstruct.svmlabel;
49)                 svm_validation_data  = svmstruct.svmdata;
50)             else
51)                 svm_train_label = [svm_train_label; svmstruct.svmlabel];
52)                 svm_train_data  = [svm_train_data;  svmstruct.svmdata];
53)             end
54)         end
55)         
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

56)         if RANDOMIZE_DATAPOINTS
57)             rndindex  = randperm(length(svm_train_label));
58)             svm_train_data   = svm_train_data(rndindex,:);
59)             svm_train_label  = svm_train_label(rndindex);
60)         end
61) 
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

62)         svmmodel = svmtrain(svm_train_label,svm_train_data,svmopts);
63)         
64)         [plabel accuracy dvalue] = svmpredict(svm_validation_label,svm_validation_data,svmmodel,'');
Christoph Budziszewski nSubject-fold cross validat...

Christoph Budziszewski authored 15 years ago

65)         cross_value = [cross_value accuracy(1)];
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

66)         
Christoph Budziszewski nSubject-fold cross validat...

Christoph Budziszewski authored 15 years ago

67)     end
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

68)     decode.decodePerformance = [decode.decodePerformance; cross_value];
Christoph Budziszewski nSubject-fold cross validat...

Christoph Budziszewski authored 15 years ago

69)     
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

70) end
Christoph Budziszewski GUI Task Switch: selfmade T...

Christoph Budziszewski authored 15 years ago

71) 
72) disp('decode done');