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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

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

Christoph Budziszewski authored 15 years ago

152) 
153)