function plotDecodePerformance(varargin) % plotDecodePerformance(timeline,decodePerformance,nClasses,rawData) PSTH_AXIS_MIN = -1; PSTH_AXIS_MAX = 1; switch nargin 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; PLOT_METHOD = inputStruct.CROSSVAL_METHOD; CROSSVAL_METHOD_DEF = inputStruct.CROSSVAL_METHOD_DEF; otherwise error('spmtoolbox:SVMCrossVal:plotDecodePerformance:WrongArgument','Wrong Arguments'); 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}); end plot(psthStart:psthEnd,psthData,[colorChooser(voxel), lineStyleChooser(label)]); end end axis([psthStart psthEnd PSTH_AXIS_MIN PSTH_AXIS_MAX]) hold off subplot(2,1,2) hold on; chanceLevel = 100/nClasses; goodPredictionLevel = chanceLevel*1.5; plot([psthStart psthEnd],[chanceLevel chanceLevel],'k:'); plot([psthStart psthEnd],[goodPredictionLevel goodPredictionLevel],'k:'); axis([psthStart psthEnd 0 100]) switch PLOT_METHOD case 'stderr' || CROSSVAL_METHOD_DEF.svmcrossval 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:'); case 'class performance' for c = 1:size(decodePerformance,2) plot(frameStart:frameEnd, decodePerformance(:,c) ,[colorChooser(mod(c,nClasses)+3) '-']); end plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b','LineWidth',2); end hold off; nvoxel = size(psth,2); title = sprintf('Subject %s, over %g voxel, smoothed %s',SubjectID,nvoxel,smoothed); set(f,'Name',title); display(sprintf('%s',title)); end function color = colorChooser(n) switch (mod(n,8)) case 0 color = 'r'; case 1 color = 'g'; case 2 color = 'b'; case 3 color = 'c'; case 4 color = 'm'; case 5 color = 'y'; otherwise color = 'k'; end end function style = lineStyleChooser(n) switch(mod(n,4)) case 0 style = '--'; case 1 style = '-'; case 2 style = ':'; case 3 style = '-.'; end end