Christoph Budziszewski commited on 2009-03-16 18:11:30
Zeige 4 geänderte Dateien mit 77 Einfügungen und 61 Löschungen.
git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@155 83ab2cfd-5345-466c-8aeb-2b2739fb922d
... | ... |
@@ -155,7 +155,7 @@ function pst = calculatePST(timeline,pstopts,data) |
155 | 155 |
|
156 | 156 |
%%%%%%%%%%% new 090109 Axel: "Normalization" for SVM |
157 | 157 |
|
158 |
- norm4SVM='minmax'; %Normalization method for SVM |
|
158 |
+ norm4SVM='mean'; %Normalization method for SVM |
|
159 | 159 |
disp(['normalization: ' norm4SVM]); |
160 | 160 |
% none - no normalization |
161 | 161 |
% mean - mean normalization (meanPSTH max at .5, baseline at -.5] |
... | ... |
@@ -85,11 +85,13 @@ switch task |
85 | 85 |
disp('SVM'); |
86 | 86 |
svmopts = getSvmArgs(model,1); |
87 | 87 |
decode = calculateMultiSubjectDecodePerformance(header,data,svmopts); |
88 |
+ decode.header = header; |
|
88 | 89 |
assignin('base','decode',decode); |
89 | 90 |
case 'XSVM' |
90 | 91 |
disp('XSVM') |
91 | 92 |
svmopts = getSvmArgs(model,0); |
92 | 93 |
decode = xsvm_subject_loop(header,data,svmopts); |
94 |
+ decode.header = header; |
|
93 | 95 |
assignin('base','decode',decode); |
94 | 96 |
case 'SOM' |
95 | 97 |
disp('not implemented') |
... | ... |
@@ -104,11 +106,11 @@ end |
104 | 106 |
end |
105 | 107 |
|
106 | 108 |
function decode_plot(model,type) |
107 |
-switch type |
|
108 |
- case 'SIMPLE' |
|
109 |
+decode = evalin('base','decode'); |
|
110 |
+preprocessed = evalin('base','preprocessedData'); |
|
111 |
+plotDecodePerformance(type,decode,preprocessed.subjectdata); |
|
109 | 112 |
|
110 | 113 |
end |
111 |
-end |
|
112 | 114 |
|
113 | 115 |
|
114 | 116 |
|
... | ... |
@@ -1,50 +1,31 @@ |
1 |
-function plotDecodePerformance(header,decode,subjectData) |
|
1 |
+function plotDecodePerformance(type,decode,subjectData) |
|
2 | 2 |
|
3 |
-global SVMCROSSVAL_CROSSVAL_METHOD_DEF; |
|
4 |
- |
|
5 |
-PSTH_AXIS_MIN = -2; |
|
6 |
-PSTH_AXIS_MAX = 2; |
|
3 |
+type |
|
7 | 4 |
|
5 |
+header = decode.header; |
|
8 | 6 |
timeline = header.timeline; |
7 |
+frameshift = header.frameShift; |
|
9 | 8 |
|
10 | 9 |
psthStart = timeline.psthStart; |
11 | 10 |
psthEnd = timeline.psthEnd; |
12 |
-frameStart = timeline.frameShiftStart; |
|
13 |
-frameEnd = timeline.frameShiftEnd; |
|
11 |
+frameStart = frameshift.frameShiftStart; |
|
12 |
+frameEnd = frameshift.frameShiftEnd; |
|
14 | 13 |
|
15 | 14 |
nClasses = numel(header.classDef.labelCells); |
16 | 15 |
decodePerformance = decode.decodePerformance; |
17 | 16 |
psth = decode.rawTimeCourse; |
18 | 17 |
SubjectID = subjectData; |
19 | 18 |
|
20 |
-smoothed = 'yes'; |
|
19 |
+nSubjects = size(SubjectID,2); |
|
21 | 20 |
|
22 |
-PLOT_METHOD = SVMCROSSVAL_CROSSVAL_METHOD_DEF.svmcrossval; |
|
23 |
-PLOT_METHOD = SVMCROSSVAL_CROSSVAL_METHOD_DEF.classPerformance; |
|
24 |
-PLOT_METHOD = 'x-subject-val'; |
|
25 | 21 |
|
26 | 22 |
f = figure; |
27 | 23 |
subplot(2,1,1); |
28 |
- hold on; |
|
29 |
- if (size(psth) > 0) |
|
30 |
- for voxel = 1:size(psth,2) |
|
31 |
- for label = 1:size(psth{voxel},2) |
|
32 |
- psthData = []; |
|
33 |
- for timepoint = 1:size(psth{voxel}{label},2) |
|
34 |
- psthData = nanmean(psth{voxel}{label}); |
|
35 |
- end |
|
36 |
- plot(psthStart:psthEnd,psthData,[colorChooser(voxel), lineStyleChooser(label)]); |
|
37 |
- end |
|
38 |
- end |
|
39 |
- end |
|
40 |
- axis([psthStart psthEnd PSTH_AXIS_MIN PSTH_AXIS_MAX]) |
|
41 |
- xlabel('time [sec]'); |
|
42 |
- ylabel('fMRI-signal change [%]'); |
|
43 |
- hold off |
|
24 |
+ plotPSTH(psth,psthStart,psthEnd); |
|
44 | 25 |
|
26 |
+ % plot performance timeline |
|
45 | 27 |
subplot(2,1,2) |
46 | 28 |
hold on; |
47 |
- |
|
48 | 29 |
chanceLevel = 100/nClasses; |
49 | 30 |
goodPredictionLevel = chanceLevel*1.5; |
50 | 31 |
plot([psthStart psthEnd],[chanceLevel chanceLevel],'k:'); |
... | ... |
@@ -53,39 +34,25 @@ PLOT_METHOD = 'x-subject-val'; |
53 | 34 |
xlabel('time [sec]'); |
54 | 35 |
ylabel('decode performance [%]'); |
55 | 36 |
|
56 |
- |
|
57 |
- |
|
58 |
- switch PLOT_METHOD |
|
59 |
- case SVMCROSSVAL_CROSSVAL_METHOD_DEF.svmcrossval |
|
60 |
- plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b','LineWidth',2); |
|
61 |
- |
|
62 |
- se = myStdErr(decodePerformance,2); |
|
63 |
- plot(frameStart:frameEnd, mean(decodePerformance,2)+se ,'b:'); |
|
64 |
- plot(frameStart:frameEnd, mean(decodePerformance,2)-se ,'b:'); |
|
65 |
- case SVMCROSSVAL_CROSSVAL_METHOD_DEF.classPerformance |
|
66 |
- for c = 1:size(decodePerformance,2) |
|
67 |
- plot(frameStart:frameEnd, decodePerformance(:,c) ,[colorChooser(mod(c,nClasses)+3) '-']); |
|
68 |
- end |
|
69 |
- |
|
70 |
- plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b','LineWidth',2); |
|
71 |
- |
|
37 |
+ switch type |
|
38 |
+ case 'simple' |
|
39 |
+ plotDecodePerformanceWithSE(frameStart,frameEnd,decodePerformance) |
|
40 |
+ case 'class performance' |
|
41 |
+ plotClassPerformance(frameStart,frameEnd,decodePerformance,nClasses) |
|
72 | 42 |
case 'x-subject-val' |
73 |
- nSubjects = size(decodePerformance,2); |
|
74 | 43 |
for c = 1:nSubjects |
75 | 44 |
plot(frameStart:frameEnd, decodePerformance(:,c) ,[colorChooser(mod(c,nSubjects)+3) '-']); |
76 | 45 |
end |
46 |
+ plotDecodePerformanceWithSE(frameStart,frameEnd,decodePerformance) |
|
47 |
+ end |
|
48 |
+ hold off; |
|
77 | 49 |
|
78 |
- plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b','LineWidth',2); |
|
79 |
- se = myStdErr(decodePerformance,2); |
|
80 |
- plot(frameStart:frameEnd, mean(decodePerformance,2)+se ,'b:'); |
|
81 |
- plot(frameStart:frameEnd, mean(decodePerformance,2)-se ,'b:'); |
|
50 |
+% setTitle(f,header,decode,subjectData); |
|
82 | 51 |
|
83 | 52 |
end |
84 | 53 |
|
54 |
+function setTitle(f,header,decode,subjectData) |
|
85 | 55 |
|
86 |
- hold off; |
|
87 |
- |
|
88 |
- nSubjects = size(SubjectID,2); |
|
89 | 56 |
nVoxelPerSubject = size(psth,2)/size(SubjectID,2); |
90 | 57 |
|
91 | 58 |
if strcmp(smoothed,'yes') |
... | ... |
@@ -104,9 +71,45 @@ PLOT_METHOD = 'x-subject-val'; |
104 | 71 |
|
105 | 72 |
set(f,'Name',title); |
106 | 73 |
display(sprintf('%s',title)); |
74 |
+end |
|
75 |
+ |
|
76 |
+function plotClassPerformance(frameStart,frameEnd,decodePerformance,nClasses) |
|
77 |
+for c = 1:size(decodePerformance,2) |
|
78 |
+ plot(frameStart:frameEnd, decodePerformance(:,c) ,[colorChooser(mod(c,nClasses)+3) '-']); |
|
79 |
+end |
|
80 |
+plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b','LineWidth',2); |
|
81 |
+end |
|
82 |
+ |
|
83 |
+function plotDecodePerformanceWithSE(frameStart,frameEnd,decodePerformance) |
|
84 |
+plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b','LineWidth',2); |
|
85 |
+ |
|
86 |
+se = myStdErr(decodePerformance,2); |
|
87 |
+plot(frameStart:frameEnd, mean(decodePerformance,2)+se ,'b:'); |
|
88 |
+plot(frameStart:frameEnd, mean(decodePerformance,2)-se ,'b:'); |
|
89 |
+end |
|
107 | 90 |
|
108 | 91 |
|
92 |
+function plotPSTH(psth,psthStart,psthEnd) |
|
109 | 93 |
|
94 |
+PSTH_AXIS_MIN = -2; |
|
95 |
+PSTH_AXIS_MAX = 2; |
|
96 |
+ |
|
97 |
+ hold on; |
|
98 |
+ if (size(psth) > 0) |
|
99 |
+ for voxel = 1:size(psth,2) |
|
100 |
+ for label = 1:size(psth{voxel},2) |
|
101 |
+ psthData = []; |
|
102 |
+ for timepoint = 1:size(psth{voxel}{label},2) |
|
103 |
+ psthData = nanmean(psth{voxel}{label}); |
|
104 |
+ end |
|
105 |
+ plot(psthStart:psthEnd,psthData,[colorChooser(voxel), lineStyleChooser(label)]); |
|
106 |
+ end |
|
107 |
+ end |
|
108 |
+ end |
|
109 |
+ axis([psthStart psthEnd PSTH_AXIS_MIN PSTH_AXIS_MAX]) |
|
110 |
+ xlabel('time [sec]'); |
|
111 |
+ ylabel('fMRI-signal change [%]'); |
|
112 |
+ hold off |
|
110 | 113 |
end |
111 | 114 |
|
112 | 115 |
|
... | ... |
@@ -352,16 +352,28 @@ pSOM = uipanel(parent,'Units','normalized','Position',[0.5 0.4 0.5 0.4]); |
352 | 352 |
end |
353 | 353 |
|
354 | 354 |
function model = createVisualStepPanel(model,parent,DEFAULT) |
355 |
- pButtonPane = uipanel(parent,'Units','normalized','Position',[0.0 0.5 1 0.5]); |
|
355 |
+ pButtonPane = uipanel(parent,'Units','normalized','Position',[0 0.5 1 0.5]); |
|
356 | 356 |
% set(pButtonPane,'Title','Plot'); |
357 | 357 |
set(pButtonPane,'BackgroundColor','w'); |
358 | 358 |
|
359 |
- btnPlot01 = uicontrol(pButtonPane,'String','plot BBBB',... |
|
359 |
+ btnPlot01 = uicontrol(pButtonPane,'String','plot performance and SE',... |
|
360 | 360 |
'Units','normalized',... |
361 |
- 'Position',[0.0 0.0 1 0.25]); |
|
362 |
- set(btnPlot01,'Callback',{@cbPlot,model,'XSOM'}); % set here, because of model. |
|
361 |
+ 'Position',[0.0 0.0 0.5 0.25]); |
|
362 |
+ set(btnPlot01,'Callback',{@cbPlot,model,'simple'}); |
|
363 | 363 |
set(btnPlot01,'Enable','on'); |
364 | 364 |
|
365 |
+ btnPlot02 = uicontrol(pButtonPane,'String','plot subject performance and mean with SE',... |
|
366 |
+ 'Units','normalized',... |
|
367 |
+ 'Position',[0.5 0.0 0.5 0.25]); |
|
368 |
+ set(btnPlot02,'Callback',{@cbPlot,model,'x-subject-val'}); |
|
369 |
+ set(btnPlot02,'Enable','on'); |
|
370 |
+ |
|
371 |
+% btnPlot03 = uicontrol(pButtonPane,'String','plot class performance and mean',... |
|
372 |
+% 'Units','normalized',... |
|
373 |
+% 'Position',[0.0 0.5 0.5 0.25]); |
|
374 |
+% set(btnPlot03,'Callback',{@cbPlot,model,'class performance'}); |
|
375 |
+% set(btnPlot03,'Enable','on'); |
|
376 |
+ |
|
365 | 377 |
end |
366 | 378 |
|
367 | 379 |
|
... | ... |
@@ -390,7 +402,6 @@ main(model,'decode',task); |
390 | 402 |
end |
391 | 403 |
|
392 | 404 |
function cbPlot(src,evnt,model,type) |
393 |
-display('Not Implemented'); |
|
394 | 405 |
main(model,'plot',type); |
395 | 406 |
end |
396 | 407 |
|
397 | 408 |