function plotDecodePerformance(varargin) % plotDecodePerformance(timeline,decodePerformance,nClasses,rawData) if(nargin==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; elseif( nargin == 7) psthStart = cell2mat(varargin(1)); psthEnd = cell2mat(varargin(2)); nClasses = cell2mat(varargin(3)); decodePerformance = cell2mat(varargin(4)); frameStart = cell2mat(varargin(5)); frameEnd = cell2mat(varargin(6)); psth = varargin(7); psth = psth{1}; SubjectID = ''; 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 % axis([psthStart psthEnd 0 0]) hold off subplot(2,1,2) hold on; plot(frameStart:frameEnd, decodePerformance ,'b'); chanceLevel = 100/nClasses; goodPredictionLevel = chanceLevel*1.5; plot([psthStart psthEnd],[chanceLevel chanceLevel],'r'); plot([psthStart psthEnd],[goodPredictionLevel goodPredictionLevel],'g'); axis([psthStart psthEnd 0 100]) hold off; title = sprintf('Subject %s, over %g voxel',SubjectID,size(psth,2)); 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