48fb182782d63149237a1f80eb93701e8bcc2f43
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

1) %% subject loop
2) function decode = xsvm_subject_loop(header,subjectdata,svmopts)
Christoph Budziszewski new labels, some cleanup

Christoph Budziszewski authored 14 years ago

3) global NODALYZE_LIBSVM;
4) addpath(fullfile(getTbxPath,NODALYZE_LIBSVM));
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

5) 
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

6) nSubjects = numel(subjectdata);
Christoph Budziszewski task-models implementet.

Christoph Budziszewski authored 15 years ago

7) if(nSubjects < 2) 
8)     error('SVMCrossVal:xsvmSubjectLoop:tooFewSubjects','You need at least 2 Subjects in this Across-Subject analysis!');
9) end
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

10) 
Christoph Budziszewski added some batch files, wor...

Christoph Budziszewski authored 14 years ago

11) RANDOMIZE_DATAPOINTS = header.svmrnd;
12) NAN_AS_ZERO = header.nantozero;
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

13) 
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

14) decode = struct;
15) decode.decodePerformance = [];
16) decode.rawTimeCourse     = [];
17) 
Christoph Budziszewski nSubject-fold cross validat...

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

19) 
20) timeline = header.timeline;
Christoph Budziszewski first plot button. not work...

Christoph Budziszewski authored 15 years ago

21) timeline.frameShiftStart = header.frameShift.frameShiftStart;
22) timeline.frameShiftEnd   = header.frameShift.frameShiftEnd;
23) timeline.decodeDuration  = header.frameShift.decodeDuration;
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

24) 
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

25) % TimePointMatrix
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

35) end
36) 
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

38) timeLineStart   = timeline.frameShiftStart;
39) timeLineEnd     = timeline.frameShiftEnd;
40) 
Christoph Budziszewski nSubject-fold cross validat...

Christoph Budziszewski authored 15 years ago

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

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

48)         svm_train_label = [];
49)         svm_train_data  = [];
50)         svm_validation_label = [];
51)         svm_validation_data  = [];
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

63)         if RANDOMIZE_DATAPOINTS
64)             rndindex  = randperm(length(svm_train_label));
65)             svm_train_data   = svm_train_data(rndindex,:);
66)             svm_train_label  = svm_train_label(rndindex);
67)         end
Christoph Budziszewski added some batch files, wor...

Christoph Budziszewski authored 14 years ago

68)         
69)         if NAN_AS_ZERO
70)             svm_train_data(isnan(svm_train_data))=0;
71)         end
72)         
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

73) 
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

79)     end
Christoph Budziszewski moved stuff, fixing plotDecode

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

81)     
Christoph Budziszewski more x-svm classification

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

83) 
84) disp('decode done');