843767743284585643d14019ffb949a0fa84952e
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

1) % function [decodePerformance rawTimecourse ] = calculateDecodePerformance(des,timeLineStart, timeLineEnd, decodeDuration, svmargs, conditionList, sessionList, voxelList, classList, labelMap,normalize)
Christoph Budziszewski multi-subject support

Christoph Budziszewski authored 15 years ago

2) function outputStruct = calculateDecodePerformance(inputStruct,SubjectID)
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

3) 
4) addpath 'libsvm-mat-2.88-1';
5) 
6) outputStruct = struct;
7) 
Christoph Budziszewski multi-subject support

Christoph Budziszewski authored 15 years ago

8) des             = inputStruct.(SubjectID).des;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

9) timeLineStart   = inputStruct.frameShiftStart;
10) timeLineEnd     = inputStruct.frameShiftEnd;
11) decodeDuration  = inputStruct.decodeDuration;
12) svmargs         = inputStruct.svmargs;
13) sessionList     = inputStruct.sessionList;
Christoph Budziszewski multi-subject support

Christoph Budziszewski authored 15 years ago

14) voxelList       = inputStruct.(SubjectID).voxelList;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

15) % classList       = inputStruct.classList;
16) % labelMap        = inputStruct.labelMap;
Christoph Budziszewski killed unnecessary assignin...

Christoph Budziszewski authored 15 years ago

17) smoothed       = inputStruct.smoothed;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

18) globalStart     = inputStruct.psthStart;
19) globalEnd       = inputStruct.psthEnd;
20) baselineStart   = inputStruct.baselineStart;
21) baselineEnd     = inputStruct.baselineEnd;
22) eventList       = inputStruct.eventList;
23) 
24) 
25) minPerformance = inf;
26) maxPerformance = -inf;
27) 
28) 
29)         
30)         %Pro Voxel PSTH TIMELINE berechnen.
31)         %   timeshift mit pst-timeline durchf�hren.
32)         % psth-timeline -25 bis +15 zu RES Onset.
33)         
34) %         eventList       = [9,11,13;10,12,14];
35) %         globalStart     = -25;
36) %         globalEnd       = 15;
37) %         baselineStart   = -22;
38) %         baselineEnd     = -20;
39)         
40)         
41)         for voxel = 1:size(voxelList,1)  % [[x;x],[y;y],[z;z]]
Christoph Budziszewski killed unnecessary assignin...

Christoph Budziszewski authored 15 years ago

42)                 extr  = calculateImageData(voxelList(voxel,:),des,smoothed);
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

43)                 rawdata=cell2mat({extr.mean}); % Raw Data
44)                 pst{voxel}  = calculatePST(des,globalStart,baselineStart,baselineEnd,globalEnd,eventList,rawdata,sessionList);
45)         end
46) 
47)         decodePerformance = [];
48) 
49)         for timeShift   = timeLineStart:1:timeLineEnd
50)             frameStart  = floor(-globalStart+1+timeShift - 0.5*decodeDuration);
51)             frameEnd    = min(ceil(frameStart+decodeDuration + 0.5*decodeDuration),-globalStart+globalEnd);
52)             
53)             tmp =[];
54)             anyvoxel = 1;
55)             for label = 1:size(pst{1,anyvoxel},2) 
56)                 for dp = 1:size(pst{1,anyvoxel}{1,label},1) % data point
57)                 row = label;
58)                     for voxel = 1:size(pst,2)
59)                         row = [row, pst{1,voxel}{1,label}(dp,frameStart:frameEnd)]; % label,value,value
60)                     end
61)                 tmp  = [tmp; row];
62)                 end
63)             end 
64)         
65)             svmdata      = tmp(:,2:size(tmp,2));
66)             svmlabel     = tmp(:,1);
67)             performance  = svmtrain(svmlabel, svmdata, svmargs);
68) 
69)             minPerformance = min(minPerformance,performance);
70)             maxPerformance = max(maxPerformance,performance);
71) 
72)             decodePerformance = [decodePerformance; performance];
73)         end
74)         
75)         outputStruct.decodePerformance  = decodePerformance;
76)         outputStruct.svmdata            = svmdata;
77)         outputStruct.svmlabel           = svmlabel;
78)         outputStruct.rawTimeCourse      = pst;
79)         outputStruct.minPerformance     = minPerformance;
80)         outputStruct.maxPerformance     = maxPerformance;
81) 
82) % display(sprintf('Min CrossVal Accuracy: %g%% \t Max CrossVal Accuracy: %g%%',minPerformance,maxPerformance));
83) end
84) 
85) 
Christoph Budziszewski killed unnecessary assignin...

Christoph Budziszewski authored 15 years ago

86) function extr = calculateImageData(voxelList,des,smoothed)
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

87) 
88) dtype='PSTH';
89) 
90) switch dtype 
91)     case 'PSTH'
92)         V=des.xY.VY;
93)     case 'betas'
94)         V=des.Vbeta;
95) end;
Christoph Budziszewski killed unnecessary assignin...

Christoph Budziszewski authored 15 years ago

96) 
97) if (~smoothed)
98)   for z=1:length(V) % Change Drive Letter!\
99)       % D:....SUBJECTID\session\swfanders...
100)       % D:....SUBJECTID\session\wfanders...
101)       tmp = findstr(filesep,V(z).fname);
102)       V(z).fname = strcat(V(z).fname(1:tmp(end)),V(z).fname(tmp(end)+2:end));
103)   end;
104) end