extracted psth-plot to extra option
Christoph Budziszewski

Christoph Budziszewski commited on 2009-04-21 11:49:06
Zeige 3 geänderte Dateien mit 28 Einfügungen und 39 Löschungen.


git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@177 83ab2cfd-5345-466c-8aeb-2b2739fb922d
... ...
@@ -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 21
   
24
-    % plot performance timeline
25
-    subplot(2,1,2)    
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) '-']);
... ...
@@ -109,6 +109,8 @@ for s = 1:nSubjects
109 109
     labelMap        = timePointArgs.labelMap;
110 110
     eventList       = pstopts.eventList;
111 111
     
112
+    res             = timeline.tr*timeline.trFactor;
113
+    
112 114
     % tmp = spm_imatrix(V(kImage).mat); %
113 115
     % vdim = tmp(7:9); % Voxel-Size
114 116
     
... ...
@@ -123,10 +125,11 @@ for s = 1:nSubjects
123 125
 
124 126
     display(sprintf('starting timesliceing'));
125 127
     
126
-    for timeShift = 1:timeLineEnd-timeLineStart+1
128
+    nSamplePoints = ((timeLineEnd-timeLineStart)/res) +1;
129
+    for timeShiftIdx = 1:nSamplePoints
127 130
     % center timepoint && relative shift
128
-    frameStart  = floor(-globalStart+1+timeShift - 0.5*decodeDuration);
129
-    frameEnd    = min(ceil(frameStart+decodeDuration + 0.5*decodeDuration),-globalStart+globalEnd);
131
+    frameStartIdx  = floor(-globalStart+1+timeShiftIdx - 0.5*decodeDuration);
132
+    frameEndIdx    = min(ceil(frameStart+decodeDuration + 0.5*decodeDuration),-globalStart+globalEnd);
130 133
 
131 134
         img3D = zeros(size(mask_image)); %output image prepare
132 135
 
... ...
@@ -143,7 +146,7 @@ for s = 1:nSubjects
143 146
                     svmlabel = [svmlabel; lm_getSVMLabel(labelMap,eventList(pstConditionGroup,1))];
144 147
                     row = [];
145 148
                     for voxel = 1:size(sphere,2)
146
-                        row = [row, pst{1,voxel}{1,pstConditionGroup}(dp,frameStart:frameEnd)]; % label,[value,value,...],[value,value,...]...
149
+                        row = [row, pst{1,voxel}{1,pstConditionGroup}(dp,frameStartIdx:frameEndIdx)]; % label,[value,value,...],[value,value,...]...
147 150
                     end
148 151
                     svmdata  = [svmdata; row];
149 152
                 end
... ...
@@ -168,8 +170,7 @@ for s = 1:nSubjects
168 170
         end  %for each voxel
169 171
 
170 172
         nii = make_nii(img3D,vdim,mask_image.hdr.hist.originator(1:3),16,sprintf('decode performance, time relative to onset: %g to %g sec',frameStart,frameEnd));
171
-        save_nii(nii,fullfile(savePath,sprintf('%s-%03g',subjects{s}.name,timeShift)));
172
-    
173
+        save_nii(nii,fullfile(savePath,sprintf('%s-%03g',subjects{s}.name,timeShiftIdx)));
173 174
     end %for each timeslice
174 175
     display('rastering done');
175 176
     display(sprintf('result images saved to %s',savePath));
... ...
@@ -378,27 +378,38 @@ pSearchlight = uipanel(parent,'Units','normalized','Position',[0.0 0.1 1 0.3]);
378 378
 end
379 379
 
380 380
 function model = createVisualStepPanel(model,parent,DEFAULT)
381
+
382
+    grid_h = 0.25;
383
+    grid_w = 0.5;
384
+    plot_grid = cell([3 3]);
385
+    plot_grid{1,1} = [0.0 0.63 grid_w grid_h];
386
+    plot_grid{1,2} = [0.0 0.33 grid_w grid_h];
387
+    plot_grid{1,3} = [0.0 0.03 grid_w grid_h];
388
+    plot_grid{2,1} = [0.5 0.63 grid_w grid_h];
389
+    plot_grid{2,2} = [0.5 0.33 grid_w grid_h];
390
+    plot_grid{2,3} = [0.5 0.03 grid_w grid_h];
391
+
381 392
     pButtonPane = uipanel(parent,'Units','normalized','Position',[0 0.5 1 0.5]);
382 393
 %     set(pButtonPane,'Title','Plot');
383 394
     set(pButtonPane,'BackgroundColor','w');
384 395
 
385 396
     btnPlot01 = uicontrol(pButtonPane,'String','plot performance and SE',...
386 397
         'Units','normalized',...
387
-        'Position',[0.0 0.0 0.5 0.25]);
398
+        'Position',cell2mat(plot_grid(1,3)));
388 399
     set(btnPlot01,'Callback',{@cbPlot,model,'simple'});
389 400
     set(btnPlot01,'Enable','on');
390 401
     
391 402
     btnPlot02 = uicontrol(pButtonPane,'String','plot subject performance and mean with SE',...
392 403
         'Units','normalized',...
393
-        'Position',[0.5 0.0 0.5 0.25]);
404
+        'Position',cell2mat(plot_grid(2,3)));
394 405
     set(btnPlot02,'Callback',{@cbPlot,model,'x-subject-val'});
395 406
     set(btnPlot02,'Enable','on');
396 407
 
397
-%     btnPlot03 = uicontrol(pButtonPane,'String','plot class performance and mean',...
398
-%         'Units','normalized',...
399
-%         'Position',[0.0 0.5 0.5 0.25]);
400
-%     set(btnPlot03,'Callback',{@cbPlot,model,'class performance'}); 
401
-%     set(btnPlot03,'Enable','on');
408
+    btnPlot03 = uicontrol(pButtonPane,'String','plot PSTH',...
409
+        'Units','normalized',...
410
+        'Position',cell2mat(plot_grid(1,2)));
411
+    set(btnPlot03,'Callback',{@cbPlot,model,'psth'}); 
412
+    set(btnPlot03,'Enable','on');
402 413
     
403 414
 end
404 415
 
405 416