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; 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],'r'); plot([psthStart psthEnd],[goodPredictionLevel goodPredictionLevel],'g'); axis([psthStart psthEnd 0 100]) plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b'); PLOT_STD_ERR = 1; PLOT_CLASS_PERFORMANCE = 1; if PLOT_STD_ERR se = myStdErr(decodePerformance,2); plot(frameStart:frameEnd, mean(decodePerformance,2)+se ,'b:'); plot(frameStart:frameEnd, mean(decodePerformance,2)-se ,'b:'); end if PLOT_CLASS_PERFORMANCE for c = 1:nClasses plot(frameStart:frameEnd, decodePerformance() ,[colorChooser(c+2) '-']); end end hold off; title = sprintf('Subject %s, over %g voxel, smoothed %s',SubjectID,size(psth,2),smoothed); set(f,'Name',title); display(sprintf('%s',title)); end 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 style = '-.'; end end