manual renamings, better FB...
Christoph Budziszewski authored 15 years ago
|
1) %% subject loop
2) function decode = som_xsubject_performance(header,subjectdata,somOpts)
3)
4) addpath 'somtoolbox2';
5)
6) nSubjects = numel(subjectdata);
7) if(nSubjects < 2)
8) error('SVMCrossVal:somXSubjectPerformance:tooFewSubjects','You need at least 2 Subjects in this Across-Subject analysis!');
9) end
10)
11) RANDOMIZE_DATAPOINTS = 1;
12)
13) decode = struct;
14) decode.decodePerformance = [];
15) decode.rawTimeCourse = [];
16)
17) disp(sprintf('computinig additional datastructs for %u subjects',nSubjects));
18)
19) timeline = header.timeline;
20) timeline.frameShiftStart = header.frameShift.frameShiftStart;
21) timeline.frameShiftEnd = header.frameShift.frameShiftEnd;
22) timeline.decodeDuration = header.frameShift.decodeDuration;
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) end
35)
36) % timeframe x-subject validation
37) timeLineStart = timeline.frameShiftStart;
38) timeLineEnd = timeline.frameShiftEnd;
39)
40) display(sprintf('%u -fold cross validation for %u timeslices.\n',nSubjects,size(1:timeLineEnd-timeLineStart+1,2)));
41) % disp(sprintf('Press ANY-Key to continue.\n Use Retrun if your Keyboard lacks the ANY-Key.'));
42) % pause
43)
44) for timeIndex = 1:timeLineEnd-timeLineStart+1
45) cross_value = [];
46) for validationSubjectID = 1:nSubjects
47) svm_train_label = [];
48) svm_train_data = [];
49) svm_validation_label = [];
50) svm_validation_data = [];
51) for subjectDataID = 1:nSubjects
52) svmstruct = calculateSVMTables(timePointMatrix{subjectDataID},timeIndex);
53) if subjectDataID == validationSubjectID
54) svm_validation_label = svmstruct.svmlabel;
55) svm_validation_data = svmstruct.svmdata;
56) else
57) svm_train_label = [svm_train_label; svmstruct.svmlabel];
58) svm_train_data = [svm_train_data; svmstruct.svmdata];
59) end
60) end
61)
62) if RANDOMIZE_DATAPOINTS
63) rndindex = randperm(length(svm_train_label));
64) svm_train_data = svm_train_data(rndindex,:);
65) svm_train_label = svm_train_label(rndindex);
66) end
67)
68) [sD sM] = som_train(svm_train_label, svm_train_data, somOpts);
69)
|