function plotDecodePerformance(timeline,inputStruct)

global CROSSVAL_METHOD_DEF;

PSTH_AXIS_MIN = -1;
PSTH_AXIS_MAX = 1;

        psthStart         = timeline.psthStart;
        psthEnd           = timeline.psthEnd;
        frameStart        = timeline.frameShiftStart;
        frameEnd          = timeline.frameShiftEnd;

        nClasses          = inputStruct.nClasses;
        decodePerformance = inputStruct.decodePerformance;
        psth              = inputStruct.rawTimeCourse;
        SubjectID         = inputStruct.SubjectID;
        smoothed          = inputStruct.smoothed;
        PLOT_METHOD       = inputStruct.CROSSVAL_METHOD;
%         CROSSVAL_METHOD_DEF = inputStruct.CROSSVAL_METHOD_DEF;


    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])
    xlabel('time [sec]');
    ylabel('fMRI-signal change [%]');
    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])
    xlabel('time [sec]');
    ylabel('decode performance [%]');
    
    
    
    switch PLOT_METHOD
        case CROSSVAL_METHOD_DEF.svmcrossval
            plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b','LineWidth',2);

            se = myStdErr(decodePerformance,2);
            plot(frameStart:frameEnd, mean(decodePerformance,2)+se ,'b:');
            plot(frameStart:frameEnd, mean(decodePerformance,2)-se ,'b:');
        case CROSSVAL_METHOD_DEF.classPerformance
            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;
    
    nSubjects = size(SubjectID,2);
    nVoxelPerSubject = size(psth,2)/size(SubjectID,2);
    
    if strcmp(smoothed,'yes')
        smoothedString = 'using smoothed data';
    else
        smoothedString = 'using unsmoothed data';
    end
    
    if nSubjects == 1
        subjectName = cell2Mat(SubjectID);
        title = sprintf('Subject %s, over %g voxel, %s',subjectName,nVoxelPerSubject,smoothedString);
    else
        title = sprintf('%g Subjects, %g Voxel per Subject, %s',nSubjects,nVoxelPerSubject,smoothedString);
    end
    

    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