plotDecodePerformance.m
2095645b
 function plotDecodePerformance(varargin)
 % plotDecodePerformance(timeline,decodePerformance,nClasses,rawData)
 
84376774
 PSTH_AXIS_MIN = -2;
 PSTH_AXIS_MAX = 5;
 
 switch nargin
2095645b
     
84376774
     case 1
         inputStruct       = cell2mat(varargin(1));
 
         psthStart         = inputStruct.psthStart;
         psthEnd           = inputStruct.psthEnd;
         nClasses          = inputStruct.nClasses;
         decodePerformance = inputStruct.decodePerformance;
         frameStart        = inputStruct.frameShiftStart;
         frameEnd          = inputStruct.frameShiftEnd;
         psth              = inputStruct.rawTimeCourse;
         SubjectID         = inputStruct.SubjectID;
         smoothed          = inputStruct.smoothed;
 
     otherwise
         error('spmtoolbox:SVMCrossVal:plotDecodePerformance:WrongArgument','Wrong Arguments');
2095645b
 end
 
     f = figure;
     subplot(2,1,1);
     hold on;
       for voxel = 1:size(psth,2)
           for label = 1:size(psth{voxel},2)
               psthData = [];
               for timepoint = 1:size(psth{voxel}{label},2)
                   psthData = nanmean(psth{voxel}{label})+voxel/100;
               end
               plot(psthStart:psthEnd,psthData,[colorChooser(voxel), lineStyleChooser(label)]);
           end
       end
84376774
     axis([psthStart psthEnd PSTH_AXIS_MIN PSTH_AXIS_MAX])
2095645b
     hold off
     
     subplot(2,1,2)    
     hold on;
644333a8
     
2095645b
     chanceLevel = 100/nClasses;
     goodPredictionLevel = chanceLevel*1.5;
     plot([psthStart psthEnd],[chanceLevel chanceLevel],'r');
     plot([psthStart psthEnd],[goodPredictionLevel goodPredictionLevel],'g');
     axis([psthStart psthEnd 0 100])
644333a8
     
84376774
     plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b');
     se = myStdErr(decodePerformance,2);
     plot(frameStart:frameEnd, mean(decodePerformance,2)+se ,'b:');
     plot(frameStart:frameEnd, mean(decodePerformance,2)-se ,'b:');
     
     
2095645b
     hold off;
 
84376774
     title = sprintf('Subject %s, over %g voxel, smoothed %s',SubjectID,size(psth,2),smoothed);
2095645b
     set(f,'Name',title);
     display(sprintf('%s',title));
 
 
 
 end
 
84376774
 
2095645b
 function color = colorChooser(n)
     switch (mod(n,8))
     case 0
         color = 'y';
     case 1
         color = 'r';
     case 2
         color = 'b';
     case 3
         color = 'g';
     otherwise
         color = 'k';
     end
 end
 
 function style = lineStyleChooser(n)
 switch(mod(n,4))
     case 0
       style = '--';
     case 1
         style = '-';
     case 2 
         style = ':';
     case 3
291ee33d
         style = '-.';
2095645b
 end
 end