feeb21e9909e70f1f74fbbf4b68c761502b17e17
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;
Christoph Budziszewski first plot button. not work...

Christoph Budziszewski authored 15 years ago

17) timeline.frameShiftStart = header.frameShift.frameShiftStart;
18) timeline.frameShiftEnd   = header.frameShift.frameShiftEnd;
19) timeline.decodeDuration  = header.frameShift.decodeDuration;
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

20) 
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

21) % TimePointMatrix
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

31) end
32) 
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

34) timeLineStart   = timeline.frameShiftStart;
35) timeLineEnd     = timeline.frameShiftEnd;
36) 
Christoph Budziszewski nSubject-fold cross validat...

Christoph Budziszewski authored 15 years ago

37) 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

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

44)         svm_train_label = [];
45)         svm_train_data  = [];
46)         svm_validation_label = [];
47)         svm_validation_data  = [];
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

70)     end
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

72)     
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

74) 
75) disp('decode done');