Browse code

add trajectory plot

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@209 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on14/10/2009 14:45:40
Showing1 changed files
... ...
@@ -12,6 +12,7 @@ frameEnd          = frameshift.frameShiftEnd;
12 12
 nClasses          = numel(header.classDef.labelCells);
13 13
 decodePerformance = decode.decodePerformance;
14 14
 psth              = decode.rawTimeCourse;
15
+ert               = psth; % Rename to EventRelatedTimeline
15 16
 SubjectID         = subjectData;
16 17
 
17 18
 nSubjects         = size(SubjectID,2);
... ...
@@ -26,10 +27,18 @@ nTrials           = getNTrials(psth);
26 27
     axis([psthStart psthEnd 0 100])
27 28
     xlabel('time [sec]');
28 29
     ylabel('decode performance [%]');
30
+    
31
+    
29 32
 plottime= tic;
30 33
     switch type
31 34
         case 'psth'
32
-            plotPSTH(psth,psthStart,psthEnd);  
35
+            plotPSTH(ert,psthStart,psthEnd);  
36
+            
37
+        case 'trajectory'
38
+            plotTrajectory(ert,psthStart,psthEnd);
39
+
40
+        case 'trajectory3'
41
+            plotTrajectory3(ert);
33 42
 
34 43
         case 'simple'
35 44
             plotDecodePerformanceWithSE(frameStart,frameEnd,decodePerformance)
... ...
@@ -129,6 +138,115 @@ PSTH_AXIS_MAX = 2;
129 138
 end
130 139
 
131 140
 
141
+function plotTrajectory(psth,psthStart,psthEnd)
142
+% ERTA_AXIS_MAX = 2;
143
+% ERTA_AXIS_MIN = 2;
144
+% ERTB_AXIS_MAX = 2;
145
+% ERTB_AXIS_MIN = 2;
146
+
147
+    if (mod(size(psth,2),2)==0) %% TODO insufficient test!!!
148
+    hold on;
149
+%     grid on;
150
+    for voxel = 1:2:size(psth,2)
151
+        for label = 1:size(psth{voxel},2)
152
+            ertDataA = [];
153
+            for timepoint = 1:size(psth{voxel}{label},2)
154
+                ertDataA = nanmean(psth{voxel}{label}); % mean ueber die trials
155
+            end
156
+%               ERTA_AXIS_MAX = max(ERTA_AXIS_MAX,nanmax(ertDataA));
157
+%               ERTA_AXIS_MIN = min(ERTA_AXIS_MIN,nanmin(ertDataA));
158
+
159
+            voxel2 = voxel+1;
160
+            ertDataB = [];
161
+            for timepoint = 1:size(psth{voxel2}{label},2)
162
+                ertDataB = nanmean(psth{voxel2}{label}); % mean ueber die trials
163
+            end
164
+%               ERTB_AXIS_MAX = max(ERTB_AXIS_MAX,nanmax(ertDataB));
165
+%               ERTB_AXIS_MIN = min(ERTB_AXIS_MIN,nanmin(ertDataB));
166
+              
167
+            plot3(psthStart:psthEnd,ertDataA,ertDataB,['.', colorChooser(label),'-']);
168
+        end
169
+    end
170
+%     axis([psthStart psthEnd ERTA_AXIS_MIN ERTA_AXIS_MAX ERTB_AXIS_MIN ERTB_AXIS_MAX])
171
+    axis tight;
172
+    view(90,0);
173
+    xlabel('time [sec]');
174
+    ylabel('fMRI-signal change [%] A');
175
+    zlabel('fMRI-signal change [%] B');
176
+    
177
+    hold off
178
+    
179
+    
180
+    else 
181
+        display('unsuitable # of voxel/roi!');
182
+    end
183
+
184
+end
185
+
186
+function plotTrajectory3(ert)
187
+    
188
+    if (mod(size(ert,2),3)~=0)
189
+        display('unsuitable # of voxel/roi!');
190
+        return
191
+    end
192
+        
193
+    nSubjects = size(ert,2)/3;
194
+    
195
+%     nLabel = size(ert{1},2);  % this is sane, because the program produces only such things.
196
+    subplot(2,1,1);
197
+    hold on;
198
+%     for label = 1:nLabel 
199
+        ertDataA = ertDataMatrix(ert,1,1,nSubjects);
200
+        ertDataB = ertDataMatrix(ert,1,2,nSubjects);
201
+        ertDataC = ertDataMatrix(ert,1,3,nSubjects);
202
+
203
+        plot3(ertDataA,ertDataB,ertDataC,['.', colorChooser(1),'-']);
204
+
205
+        ertDataA2 = ertDataMatrix(ert,2,1,nSubjects);
206
+        ertDataB2 = ertDataMatrix(ert,2,2,nSubjects);
207
+        ertDataC2 = ertDataMatrix(ert,2,3,nSubjects);
208
+
209
+        plot3(ertDataA2,ertDataB2,ertDataC2,['.', colorChooser(2),'-']);
210
+
211
+        %     end
212
+        
213
+        for a = 1:length(ertDataA)
214
+            line([ertDataA(a) ertDataA2(a)],...
215
+                [ertDataB(a) ertDataB2(a)],...
216
+                [ertDataC(a) ertDataC2(a)],...
217
+                'color',[.8/a 0 1-.8/a]);
218
+            
219
+            d(a) = sqrt( (ertDataA(a)-ertDataA2(a))^2 +...
220
+            (ertDataB(a)-ertDataB2(a))^2 + ...
221
+            (ertDataC(a)-ertDataC2(a))^2);
222
+        end
223
+
224
+    axis tight;
225
+%     view(90,0);
226
+    xlabel('fMRI-signal change [%] A');
227
+    ylabel('fMRI-signal change [%] B');
228
+    zlabel('fMRI-signal change [%] C');
229
+    
230
+    hold off
231
+
232
+    subplot(2,1,2);
233
+        
234
+    plot(d);
235
+    
236
+end
237
+
238
+function ertDataMatrix = ertDataMatrix(ert,label,roiID,nSubjects)
239
+    ertDataMatrix = [];
240
+    for subject = 1:nSubjects
241
+        voxel = roiID*subject;
242
+        for timepoint = 1:size(ert{voxel}{label},2)
243
+            ertDataMatrix = [ertDataMatrix ; nanmean(ert{voxel}{label})]; % mean ueber die trials
244
+        end
245
+    end
246
+    ertDataMatrix = nanmean(ertDataMatrix,1);
247
+end
248
+
249
+
132 250
 function color = colorChooser(n)
133 251
     switch (mod(n,8))
134 252
     case 0
Browse code

fixed FBS basedir fixed confidece interval plot

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@205 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on06/08/2009 18:02:56
Showing1 changed files
... ...
@@ -26,52 +26,64 @@ nTrials           = getNTrials(psth);
26 26
     axis([psthStart psthEnd 0 100])
27 27
     xlabel('time [sec]');
28 28
     ylabel('decode performance [%]');
29
-
29
+plottime= tic;
30 30
     switch type
31 31
         case 'psth'
32 32
             plotPSTH(psth,psthStart,psthEnd);  
33
+
33 34
         case 'simple'
34 35
             plotDecodePerformanceWithSE(frameStart,frameEnd,decodePerformance)
36
+
37
+            plot([psthStart psthEnd],[chanceLevel chanceLevel],'k:');
38
+            plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.05,chanceLevel/100,'--');
39
+            plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.01,chanceLevel/100,'-.');
40
+            plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.001,chanceLevel/100,':');
41
+
35 42
         case 'class performance'
36 43
             plotClassPerformance(frameStart,frameEnd,decodePerformance,nClasses)
44
+
45
+            plot([psthStart psthEnd],[chanceLevel chanceLevel],'k:');
46
+            plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.05,chanceLevel/100,'--');
47
+            plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.01,chanceLevel/100,'-.');
48
+            plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.001,chanceLevel/100,':');
37 49
         case 'x-subject-val'
38 50
             for c = 1:nSubjects
39 51
                 plot(frameStart:frameEnd, decodePerformance(:,c) ,[colorChooser(mod(c,nSubjects)+3) '-']);
40 52
             end
41 53
             plotDecodePerformanceWithSE(frameStart,frameEnd,decodePerformance)
42
-    end
43
-    
44
-    plot([psthStart psthEnd],[chanceLevel chanceLevel],'k:');
54
+            
55
+            plot([psthStart psthEnd],[chanceLevel chanceLevel],'k:');
56
+            plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.05,chanceLevel/100,'--');
57
+            plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.01,chanceLevel/100,'-.');
58
+            plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.001,chanceLevel/100,':');
45 59
 
46
-    plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.05,chanceLevel/100,'r');
47
-    plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.01,chanceLevel/100,'g');
48
-    
60
+    end
61
+toc(plottime);    
49 62
     hold off;
50 63
     
51
-%     setTitle(f,header,decode,subjectData);
52
-    
53 64
 end
54 65
 
55 66
 function plotBinConfidenceIntervall(pStart,pEnd,nTrials,alpha,limit,color)
56 67
     [pLevel Z] = rev_ki_bin(nTrials,alpha,limit);
57 68
     [lower upper proz] = ki_bin(Z,nTrials,alpha);
58 69
 
59
-    plot([pStart pEnd],[pLevel*100 pLevel*100],[color ':']);
60
-
61
-    plot([pStart pEnd],[lower*100 lower*100],[color '-.']);
62
-    plot([pStart pEnd],[upper*100 upper*100],[color '-.']);
70
+    plot([pStart pEnd],[pLevel*100 pLevel*100],[color 'k']);
71
+%     plot([pStart pEnd],[lower*100 lower*100],[color 'k']);
72
+%     plot([pStart pEnd],[upper*100 upper*100],[color 'k']);
63 73
 end
64 74
 
65 75
 function n = getNTrials(psth)
66
-nSubjects = size(psth,2);
76
+nOverallConditions = size(psth,2);
67 77
 
68 78
 n = 0;
69
-for ns = 1:nSubjects
79
+for ns = 1:nOverallConditions
70 80
     nClasses = size(psth{ns},2);
71 81
     for nc = 1:nClasses
72 82
         n = n + size(psth{ns}{nc},1);
73 83
     end
74 84
 end
85
+n=n/(nOverallConditions/nClasses);
86
+
75 87
 end
76 88
 
77 89
 function plotClassPerformance(frameStart,frameEnd,decodePerformance,nClasses)
... ...
@@ -104,7 +116,9 @@ PSTH_AXIS_MAX = 2;
104 116
                   psthData = nanmean(psth{voxel}{label});
105 117
               end
106 118
               PSTH_AXIS_MAX = max(PSTH_AXIS_MAX,nanmax(psthData));
119
+              PSTH_AXIS_MIN = min(PSTH_AXIS_MIN,nanmin(psthData));
107 120
               plot(psthStart:psthEnd,psthData,[colorChooser(voxel), lineStyleChooser(label)]);
121
+%               plot(psthStart:psthEnd,psthData,[lineStyleChooser(voxel), colorChooser(label)]);
108 122
           end
109 123
       end
110 124
     end
Browse code

preliminary confidence intervall plot data save+load

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@203 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on05/08/2009 14:12:52
Showing1 changed files
... ...
@@ -16,14 +16,13 @@ SubjectID         = subjectData;
16 16
 
17 17
 nSubjects         = size(SubjectID,2);
18 18
 
19
+nTrials           = getNTrials(psth);
19 20
 
20 21
     f = figure;
21 22
   
22 23
     hold on;
23 24
     chanceLevel = 100/nClasses;
24
-    goodPredictionLevel = chanceLevel*1.5;
25
-    plot([psthStart psthEnd],[chanceLevel chanceLevel],'k:');
26
-    plot([psthStart psthEnd],[goodPredictionLevel goodPredictionLevel],'k:');
25
+
27 26
     axis([psthStart psthEnd 0 100])
28 27
     xlabel('time [sec]');
29 28
     ylabel('decode performance [%]');
... ...
@@ -41,12 +40,40 @@ nSubjects         = size(SubjectID,2);
41 40
             end
42 41
             plotDecodePerformanceWithSE(frameStart,frameEnd,decodePerformance)
43 42
     end
43
+    
44
+    plot([psthStart psthEnd],[chanceLevel chanceLevel],'k:');
45
+
46
+    plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.05,chanceLevel/100,'r');
47
+    plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.01,chanceLevel/100,'g');
48
+    
44 49
     hold off;
45 50
     
46 51
 %     setTitle(f,header,decode,subjectData);
47 52
     
48 53
 end
49 54
 
55
+function plotBinConfidenceIntervall(pStart,pEnd,nTrials,alpha,limit,color)
56
+    [pLevel Z] = rev_ki_bin(nTrials,alpha,limit);
57
+    [lower upper proz] = ki_bin(Z,nTrials,alpha);
58
+
59
+    plot([pStart pEnd],[pLevel*100 pLevel*100],[color ':']);
60
+
61
+    plot([pStart pEnd],[lower*100 lower*100],[color '-.']);
62
+    plot([pStart pEnd],[upper*100 upper*100],[color '-.']);
63
+end
64
+
65
+function n = getNTrials(psth)
66
+nSubjects = size(psth,2);
67
+
68
+n = 0;
69
+for ns = 1:nSubjects
70
+    nClasses = size(psth{ns},2);
71
+    for nc = 1:nClasses
72
+        n = n + size(psth{ns}{nc},1);
73
+    end
74
+end
75
+end
76
+
50 77
 function plotClassPerformance(frameStart,frameEnd,decodePerformance,nClasses)
51 78
 for c = 1:size(decodePerformance,2)
52 79
     plot(frameStart:frameEnd, decodePerformance(:,c) ,[colorChooser(mod(c,nClasses)+3) '-']);
... ...
@@ -76,6 +103,7 @@ PSTH_AXIS_MAX = 2;
76 103
               for timepoint = 1:size(psth{voxel}{label},2)
77 104
                   psthData = nanmean(psth{voxel}{label});
78 105
               end
106
+              PSTH_AXIS_MAX = max(PSTH_AXIS_MAX,nanmax(psthData));
79 107
               plot(psthStart:psthEnd,psthData,[colorChooser(voxel), lineStyleChooser(label)]);
80 108
           end
81 109
       end
Browse code

extracted psth-plot to extra option

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@177 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on21/04/2009 11:49:06
Showing1 changed files
... ...
@@ -18,11 +18,7 @@ nSubjects         = size(SubjectID,2);
18 18
 
19 19
 
20 20
     f = figure;
21
-    subplot(2,1,1); 
22
-        plotPSTH(psth,psthStart,psthEnd);
23
-    
24
-    % plot performance timeline
25
-    subplot(2,1,2)    
21
+  
26 22
     hold on;
27 23
     chanceLevel = 100/nClasses;
28 24
     goodPredictionLevel = chanceLevel*1.5;
... ...
@@ -33,6 +29,8 @@ nSubjects         = size(SubjectID,2);
33 29
     ylabel('decode performance [%]');
34 30
 
35 31
     switch type
32
+        case 'psth'
33
+            plotPSTH(psth,psthStart,psthEnd);  
36 34
         case 'simple'
37 35
             plotDecodePerformanceWithSE(frameStart,frameEnd,decodePerformance)
38 36
         case 'class performance'
... ...
@@ -49,28 +47,6 @@ nSubjects         = size(SubjectID,2);
49 47
     
50 48
 end
51 49
 
52
-function setTitle(f,header,decode,subjectData)
53
-
54
-    nVoxelPerSubject = size(psth,2)/size(SubjectID,2);
55
-    
56
-    if strcmp(smoothed,'yes')
57
-        smoothedString = 'using smoothed data';
58
-    else
59
-        smoothedString = 'using unsmoothed data';
60
-    end
61
-    
62
-    if nSubjects == 1
63
-        subjectName = SubjectID{1}.name;
64
-        title = sprintf('Subject %s, over %g voxel, %s',subjectName,nVoxelPerSubject,smoothedString);
65
-    else
66
-        title = sprintf('%g Subjects, %g Voxel per Subject, %s',nSubjects,nVoxelPerSubject,smoothedString);
67
-    end
68
-    
69
-
70
-    set(f,'Name',title);
71
-    display(sprintf('%s',title));
72
-end
73
-
74 50
 function plotClassPerformance(frameStart,frameEnd,decodePerformance,nClasses)
75 51
 for c = 1:size(decodePerformance,2)
76 52
     plot(frameStart:frameEnd, decodePerformance(:,c) ,[colorChooser(mod(c,nClasses)+3) '-']);
Browse code

begin SOM implementation

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@159 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on16/03/2009 21:53:24
Showing1 changed files
... ...
@@ -18,7 +18,7 @@ nSubjects         = size(SubjectID,2);
18 18
 
19 19
 
20 20
     f = figure;
21
-    subplot(2,1,1);
21
+    subplot(2,1,1); 
22 22
         plotPSTH(psth,psthStart,psthEnd);
23 23
     
24 24
     % plot performance timeline
Browse code

enabled radius. but does not work with r>0 !

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@156 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on16/03/2009 18:55:40
Showing1 changed files
... ...
@@ -1,7 +1,5 @@
1 1
 function plotDecodePerformance(type,decode,subjectData)
2 2
 
3
-type
4
-
5 3
 header = decode.header;
6 4
 timeline = header.timeline;
7 5
 frameshift = header.frameShift;
Browse code

all enabled features working: PRE: roi-image and coord-table CLASS: batch svm and x-subject svm PLOT: raw psth per voxel, subject performance, mean performance and SE

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@155 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on16/03/2009 18:11:30
Showing1 changed files
... ...
@@ -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:');
... ...
@@ -52,40 +33,26 @@ PLOT_METHOD       = 'x-subject-val';
52 33
     axis([psthStart psthEnd 0 100])
53 34
     xlabel('time [sec]');
54 35
     ylabel('decode performance [%]');
55
-    
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 36
 
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
77
-
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:');
82
-
46
+            plotDecodePerformanceWithSE(frameStart,frameEnd,decodePerformance)
83 47
     end
84
-    
85
-    
86 48
     hold off;
87 49
     
88
-    nSubjects = size(SubjectID,2);
50
+%     setTitle(f,header,decode,subjectData);
51
+    
52
+end
53
+
54
+function setTitle(f,header,decode,subjectData)
55
+
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
107 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
108 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
109 90
 
91
+
92
+function plotPSTH(psth,psthStart,psthEnd)
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
 
Browse code

GUI Task Switch: selfmade TabbedPanel

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@152 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on16/03/2009 16:03:31
Showing1 changed files
... ...
@@ -2,8 +2,8 @@ function plotDecodePerformance(header,decode,subjectData)
2 2
 
3 3
 global SVMCROSSVAL_CROSSVAL_METHOD_DEF;
4 4
 
5
-PSTH_AXIS_MIN = -1;
6
-PSTH_AXIS_MAX = 1;
5
+PSTH_AXIS_MIN = -2;
6
+PSTH_AXIS_MAX = 2;
7 7
 
8 8
 timeline = header.timeline;
9 9
 
... ...
@@ -26,7 +26,6 @@ PLOT_METHOD       = 'x-subject-val';
26 26
     f = figure;
27 27
     subplot(2,1,1);
28 28
     hold on;
29
-    size(psth)
30 29
     if (size(psth) > 0)
31 30
       for voxel = 1:size(psth,2)
32 31
           for label = 1:size(psth{voxel},2)
Browse code

moved stuff, fixing plotDecode

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@151 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on16/03/2009 14:41:06
Showing1 changed files
... ...
@@ -7,22 +7,21 @@ PSTH_AXIS_MAX = 1;
7 7
 
8 8
 timeline = header.timeline;
9 9
 
10
-        psthStart         = timeline.psthStart;
11
-        psthEnd           = timeline.psthEnd;
12
-        frameStart        = timeline.frameShiftStart;
13
-        frameEnd          = timeline.frameShiftEnd;
10
+psthStart         = timeline.psthStart;
11
+psthEnd           = timeline.psthEnd;
12
+frameStart        = timeline.frameShiftStart;
13
+frameEnd          = timeline.frameShiftEnd;
14 14
 
15
-        nClasses          = numel(header.classDef.labelCells);
16
-        decodePerformance = decode.decodePerformance;
17
-        psth              = decode.rawTimeCourse;
18
-        SubjectID         = subjectData;
15
+nClasses          = numel(header.classDef.labelCells);
16
+decodePerformance = decode.decodePerformance;
17
+psth              = decode.rawTimeCourse;
18
+SubjectID         = subjectData;
19 19
 
20
-        smoothed          = 'yes';
21
-        
22
-        PLOT_METHOD       = SVMCROSSVAL_CROSSVAL_METHOD_DEF.svmcrossval;
23
-        PLOT_METHOD       = SVMCROSSVAL_CROSSVAL_METHOD_DEF.classPerformance;
24
-%         CROSSVAL_METHOD_DEF = inputStruct.CROSSVAL_METHOD_DEF;
20
+smoothed          = 'yes';
25 21
 
22
+PLOT_METHOD       = SVMCROSSVAL_CROSSVAL_METHOD_DEF.svmcrossval;
23
+PLOT_METHOD       = SVMCROSSVAL_CROSSVAL_METHOD_DEF.classPerformance;
24
+PLOT_METHOD       = 'x-subject-val';
26 25
 
27 26
     f = figure;
28 27
     subplot(2,1,1);
... ...
@@ -70,6 +69,17 @@ timeline = header.timeline;
70 69
             end
71 70
 
72 71
             plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b','LineWidth',2);
72
+            
73
+        case 'x-subject-val'
74
+            nSubjects = size(decodePerformance,2);
75
+            for c = 1:nSubjects
76
+                plot(frameStart:frameEnd, decodePerformance(:,c) ,[colorChooser(mod(c,nSubjects)+3) '-']);
77
+            end
78
+
79
+            plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b','LineWidth',2);
80
+            se = myStdErr(decodePerformance,2);
81
+            plot(frameStart:frameEnd, mean(decodePerformance,2)+se ,'b:');
82
+            plot(frameStart:frameEnd, mean(decodePerformance,2)-se ,'b:');
73 83
 
74 84
     end
75 85
     
Browse code

nSubject-fold cross validation. visualization still missing.

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@150 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on16/03/2009 13:50:49
Showing1 changed files
... ...
@@ -20,12 +20,15 @@ timeline = header.timeline;
20 20
         smoothed          = 'yes';
21 21
         
22 22
         PLOT_METHOD       = SVMCROSSVAL_CROSSVAL_METHOD_DEF.svmcrossval;
23
+        PLOT_METHOD       = SVMCROSSVAL_CROSSVAL_METHOD_DEF.classPerformance;
23 24
 %         CROSSVAL_METHOD_DEF = inputStruct.CROSSVAL_METHOD_DEF;
24 25
 
25 26
 
26 27
     f = figure;
27 28
     subplot(2,1,1);
28 29
     hold on;
30
+    size(psth)
31
+    if (size(psth) > 0)
29 32
       for voxel = 1:size(psth,2)
30 33
           for label = 1:size(psth{voxel},2)
31 34
               psthData = [];
... ...
@@ -35,6 +38,7 @@ timeline = header.timeline;
35 38
               plot(psthStart:psthEnd,psthData,[colorChooser(voxel), lineStyleChooser(label)]);
36 39
           end
37 40
       end
41
+    end
38 42
     axis([psthStart psthEnd PSTH_AXIS_MIN PSTH_AXIS_MAX])
39 43
     xlabel('time [sec]');
40 44
     ylabel('fMRI-signal change [%]');
Browse code

single subject -> svm classification -> plotDecodePerformance working!

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@145 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on06/03/2009 13:17:25
Showing1 changed files
... ...
@@ -1,21 +1,25 @@
1
-function plotDecodePerformance(timeline,inputStruct)
1
+function plotDecodePerformance(header,decode,subjectData)
2 2
 
3
-global CROSSVAL_METHOD_DEF;
3
+global SVMCROSSVAL_CROSSVAL_METHOD_DEF;
4 4
 
5 5
 PSTH_AXIS_MIN = -1;
6 6
 PSTH_AXIS_MAX = 1;
7 7
 
8
+timeline = header.timeline;
9
+
8 10
         psthStart         = timeline.psthStart;
9 11
         psthEnd           = timeline.psthEnd;
10 12
         frameStart        = timeline.frameShiftStart;
11 13
         frameEnd          = timeline.frameShiftEnd;
12 14
 
13
-        nClasses          = inputStruct.nClasses;
14
-        decodePerformance = inputStruct.decodePerformance;
15
-        psth              = inputStruct.rawTimeCourse;
16
-        SubjectID         = inputStruct.SubjectID;
17
-        smoothed          = inputStruct.smoothed;
18
-        PLOT_METHOD       = inputStruct.CROSSVAL_METHOD;
15
+        nClasses          = numel(header.classDef.labelCells);
16
+        decodePerformance = decode.decodePerformance;
17
+        psth              = decode.rawTimeCourse;
18
+        SubjectID         = subjectData;
19
+
20
+        smoothed          = 'yes';
21
+        
22
+        PLOT_METHOD       = SVMCROSSVAL_CROSSVAL_METHOD_DEF.svmcrossval;
19 23
 %         CROSSVAL_METHOD_DEF = inputStruct.CROSSVAL_METHOD_DEF;
20 24
 
21 25
 
... ...
@@ -50,13 +54,13 @@ PSTH_AXIS_MAX = 1;
50 54
     
51 55
     
52 56
     switch PLOT_METHOD
53
-        case CROSSVAL_METHOD_DEF.svmcrossval
57
+        case SVMCROSSVAL_CROSSVAL_METHOD_DEF.svmcrossval
54 58
             plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b','LineWidth',2);
55 59
 
56 60
             se = myStdErr(decodePerformance,2);
57 61
             plot(frameStart:frameEnd, mean(decodePerformance,2)+se ,'b:');
58 62
             plot(frameStart:frameEnd, mean(decodePerformance,2)-se ,'b:');
59
-        case CROSSVAL_METHOD_DEF.classPerformance
63
+        case SVMCROSSVAL_CROSSVAL_METHOD_DEF.classPerformance
60 64
             for c = 1:size(decodePerformance,2)
61 65
                 plot(frameStart:frameEnd, decodePerformance(:,c) ,[colorChooser(mod(c,nClasses)+3) '-']);
62 66
             end
... ...
@@ -78,7 +82,7 @@ PSTH_AXIS_MAX = 1;
78 82
     end
79 83
     
80 84
     if nSubjects == 1
81
-        subjectName = cell2Mat(SubjectID);
85
+        subjectName = SubjectID{1}.name;
82 86
         title = sprintf('Subject %s, over %g voxel, %s',subjectName,nVoxelPerSubject,smoothedString);
83 87
     else
84 88
         title = sprintf('%g Subjects, %g Voxel per Subject, %s',nSubjects,nVoxelPerSubject,smoothedString);
Browse code

moved things

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@127 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on09/02/2009 16:44:50
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,127 @@
1
+function plotDecodePerformance(timeline,inputStruct)
2
+
3
+global CROSSVAL_METHOD_DEF;
4
+
5
+PSTH_AXIS_MIN = -1;
6
+PSTH_AXIS_MAX = 1;
7
+
8
+        psthStart         = timeline.psthStart;
9
+        psthEnd           = timeline.psthEnd;
10
+        frameStart        = timeline.frameShiftStart;
11
+        frameEnd          = timeline.frameShiftEnd;
12
+
13
+        nClasses          = inputStruct.nClasses;
14
+        decodePerformance = inputStruct.decodePerformance;
15
+        psth              = inputStruct.rawTimeCourse;
16
+        SubjectID         = inputStruct.SubjectID;
17
+        smoothed          = inputStruct.smoothed;
18
+        PLOT_METHOD       = inputStruct.CROSSVAL_METHOD;
19
+%         CROSSVAL_METHOD_DEF = inputStruct.CROSSVAL_METHOD_DEF;
20
+
21
+
22
+    f = figure;
23
+    subplot(2,1,1);
24
+    hold on;
25
+      for voxel = 1:size(psth,2)
26
+          for label = 1:size(psth{voxel},2)
27
+              psthData = [];
28
+              for timepoint = 1:size(psth{voxel}{label},2)
29
+                  psthData = nanmean(psth{voxel}{label});
30
+              end
31
+              plot(psthStart:psthEnd,psthData,[colorChooser(voxel), lineStyleChooser(label)]);
32
+          end
33
+      end
34
+    axis([psthStart psthEnd PSTH_AXIS_MIN PSTH_AXIS_MAX])
35
+    xlabel('time [sec]');
36
+    ylabel('fMRI-signal change [%]');
37
+    hold off
38
+    
39
+    subplot(2,1,2)    
40
+    hold on;
41
+    
42
+    chanceLevel = 100/nClasses;
43
+    goodPredictionLevel = chanceLevel*1.5;
44
+    plot([psthStart psthEnd],[chanceLevel chanceLevel],'k:');
45
+    plot([psthStart psthEnd],[goodPredictionLevel goodPredictionLevel],'k:');
46
+    axis([psthStart psthEnd 0 100])
47
+    xlabel('time [sec]');
48
+    ylabel('decode performance [%]');
49
+    
50
+    
51
+    
52
+    switch PLOT_METHOD
53
+        case CROSSVAL_METHOD_DEF.svmcrossval
54
+            plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b','LineWidth',2);
55
+
56
+            se = myStdErr(decodePerformance,2);
57
+            plot(frameStart:frameEnd, mean(decodePerformance,2)+se ,'b:');
58
+            plot(frameStart:frameEnd, mean(decodePerformance,2)-se ,'b:');
59
+        case CROSSVAL_METHOD_DEF.classPerformance
60
+            for c = 1:size(decodePerformance,2)
61
+                plot(frameStart:frameEnd, decodePerformance(:,c) ,[colorChooser(mod(c,nClasses)+3) '-']);
62
+            end
63
+
64
+            plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b','LineWidth',2);
65
+
66
+    end
67
+    
68
+    
69
+    hold off;
70
+    
71
+    nSubjects = size(SubjectID,2);
72
+    nVoxelPerSubject = size(psth,2)/size(SubjectID,2);
73
+    
74
+    if strcmp(smoothed,'yes')
75
+        smoothedString = 'using smoothed data';
76
+    else
77
+        smoothedString = 'using unsmoothed data';
78
+    end
79
+    
80
+    if nSubjects == 1
81
+        subjectName = cell2Mat(SubjectID);
82
+        title = sprintf('Subject %s, over %g voxel, %s',subjectName,nVoxelPerSubject,smoothedString);
83
+    else
84
+        title = sprintf('%g Subjects, %g Voxel per Subject, %s',nSubjects,nVoxelPerSubject,smoothedString);
85
+    end
86
+    
87
+
88
+    set(f,'Name',title);
89
+    display(sprintf('%s',title));
90
+
91
+
92
+
93
+end
94
+
95
+
96
+function color = colorChooser(n)
97
+    switch (mod(n,8))
98
+    case 0
99
+        color = 'r';
100
+    case 1
101
+        color = 'g';
102
+    case 2
103
+        color = 'b';
104
+    case 3
105
+        color = 'c';
106
+    case 4
107
+        color = 'm';
108
+    case 5
109
+        color = 'y';
110
+    otherwise
111
+        color = 'k';
112
+    end
113
+end
114
+
115
+function style = lineStyleChooser(n)
116
+switch(mod(n,4))
117
+    case 0
118
+      style = '--';
119
+    case 1
120
+        style = '-';
121
+    case 2 
122
+        style = ':';
123
+    case 3
124
+        style = '-.';
125
+end
126
+end
127
+