6985c69e8d9d17871756db748c1f69df79f2efa4
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 New5 Studie, Var-Name erset...

Christoph Budziszewski authored 15 years ago

8) namehelper      = strcat('s',SubjectID);
9) des             = inputStruct.(namehelper).des;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

10) timeLineStart   = inputStruct.frameShiftStart;
11) timeLineEnd     = inputStruct.frameShiftEnd;
12) decodeDuration  = inputStruct.decodeDuration;
13) svmargs         = inputStruct.svmargs;
14) sessionList     = inputStruct.sessionList;
Christoph Budziszewski New5 Studie, Var-Name erset...

Christoph Budziszewski authored 15 years ago

15) voxelList       = inputStruct.(namehelper).voxelList;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

19) globalStart     = inputStruct.psthStart;
20) globalEnd       = inputStruct.psthEnd;
21) baselineStart   = inputStruct.baselineStart;
22) baselineEnd     = inputStruct.baselineEnd;
23) eventList       = inputStruct.eventList;
Christoph Budziszewski new LabelMap new svm groupi...

Christoph Budziszewski authored 15 years ago

24) labelMap        = inputStruct.labelMap;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

45)                 rawdata=cell2mat({extr.mean}); % Raw Data
46)                 pst{voxel}  = calculatePST(des,globalStart,baselineStart,baselineEnd,globalEnd,eventList,rawdata,sessionList);
47)         end
48) 
49)         decodePerformance = [];
50) 
51)         for timeShift   = timeLineStart:1:timeLineEnd
52)             frameStart  = floor(-globalStart+1+timeShift - 0.5*decodeDuration);
53)             frameEnd    = min(ceil(frameStart+decodeDuration + 0.5*decodeDuration),-globalStart+globalEnd);
54)             
55)             tmp =[];
56)             anyvoxel = 1;
Christoph Budziszewski new LabelMap new svm groupi...

Christoph Budziszewski authored 15 years ago

57)             for pstConditionGroup = 1:size(pst{1,anyvoxel},2) 
58)                 for dp = 1:size(pst{1,anyvoxel}{1,pstConditionGroup},1) % data point
59)                   row = getSVMLabel(labelMap,eventList(pstConditionGroup,1)) 
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

60)                     for voxel = 1:size(pst,2)
Christoph Budziszewski new LabelMap new svm groupi...

Christoph Budziszewski authored 15 years ago

61)                         row = [row, pst{1,voxel}{1,pstConditionGroup}(dp,frameStart:frameEnd)]; % label,value,value
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

62)                     end
63)                 tmp  = [tmp; row];
64)                 end
65)             end 
66)         
67)             svmdata      = tmp(:,2:size(tmp,2));
68)             svmlabel     = tmp(:,1);
69)             performance  = svmtrain(svmlabel, svmdata, svmargs);
70) 
71)             minPerformance = min(minPerformance,performance);
72)             maxPerformance = max(maxPerformance,performance);
73) 
74)             decodePerformance = [decodePerformance; performance];
75)         end
76)         
77)         outputStruct.decodePerformance  = decodePerformance;
78)         outputStruct.svmdata            = svmdata;
79)         outputStruct.svmlabel           = svmlabel;
80)         outputStruct.rawTimeCourse      = pst;
81)         outputStruct.minPerformance     = minPerformance;
82)         outputStruct.maxPerformance     = maxPerformance;
83) 
84) % display(sprintf('Min CrossVal Accuracy: %g%% \t Max CrossVal Accuracy: %g%%',minPerformance,maxPerformance));
85) end
86) 
87) 
Christoph Budziszewski killed unnecessary assignin...

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

98) 
Christoph Budziszewski New5 Studie, Var-Name erset...

Christoph Budziszewski authored 15 years ago

99) if V(1).fname(1)~='D'
100)      for z=1:length(V) % Change Drive Letter!\
101)       	V(z).fname(1) = 'D';
102)      end; 
103) end
104) 
Christoph Budziszewski killed unnecessary assignin...

Christoph Budziszewski authored 15 years ago

105) if (~smoothed)
106)   for z=1:length(V) % Change Drive Letter!\
107)       % D:....SUBJECTID\session\swfanders...
108)       % D:....SUBJECTID\session\wfanders...
109)       tmp = findstr(filesep,V(z).fname);
110)       V(z).fname = strcat(V(z).fname(1:tmp(end)),V(z).fname(tmp(end)+2:end));
111)   end;
112) end
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

113) 
114) % rad = 0; % one voxel
115) % opt = 1; % xyz coordinates [mm]
116) 
117) 
118) vox = voxelList;
119) nRoi = size(vox,1);
120) 
121) nImg = numel(V);
122) 
123) for k=1:nImg
124) 	extr(k) = struct(...
125)         'val',   repmat(NaN, [1 nRoi]),...
126) 		'mean',  repmat(NaN, [1 nRoi]),...
127) 		'sum',   repmat(NaN, [1 nRoi]),...
128) 		'nvx',   repmat(NaN, [1 nRoi]),...
129) 		'posmm', repmat(NaN, [3 nRoi]),...
130) 		'posvx', repmat(NaN, [3 nRoi]));
131) 
132)     roicenter = round(inv(V(k).mat)*[vox, ones(nRoi,1)]');
133) 
134) 	for l = 1:nRoi
135) 
136) %         if rad==0
137)             x = roicenter(1,l);
138)             y = roicenter(2,l);
139)             z = roicenter(3,l);
140) %         else
141) %             tmp = spm_imatrix(V(k).mat);
142) %             vdim = tmp(7:9);
143) %             vxrad = ceil((rad*ones(1,3))./(ones(nRoi,1)*vdim))';
144) %             [x y z] = ndgrid(-vxrad(1,l):sign(vdim(1)):vxrad(1,l), ...
145) %                       -vxrad(2,l):sign(vdim(2)):vxrad(2,l), ...
146) %                       -vxrad(3,l):sign(vdim(3)):vxrad(3,l));
147) %             sel = (x./vxrad(1,l)).^2 + (y./vxrad(2,l)).^2 + ...
148) %                   (z./vxrad(3,l)).^2 <= 1;
149) %             x = roicenter(1,l)+x(sel(:));
150) %             y = roicenter(2,l)+y(sel(:));
151) %             z = roicenter(3,l)+z(sel(:));
152) %         end;
Christoph Budziszewski New5 Studie, Var-Name erset...

Christoph Budziszewski authored 15 years ago

153) 
154)