git.schokokeks.org
Repositories
Help
Report an Issue
SVMCrossVal.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
2233507
Branches
Tags
master
SVMCrossVal.git
private
plotDecodePerformance.m
begin SOM implementation
Christoph Budziszewski
commited
2233507
at 2009-03-16 21:53:24
plotDecodePerformance.m
Blame
History
Raw
function plotDecodePerformance(type,decode,subjectData) header = decode.header; timeline = header.timeline; frameshift = header.frameShift; psthStart = timeline.psthStart; psthEnd = timeline.psthEnd; frameStart = frameshift.frameShiftStart; frameEnd = frameshift.frameShiftEnd; nClasses = numel(header.classDef.labelCells); decodePerformance = decode.decodePerformance; psth = decode.rawTimeCourse; SubjectID = subjectData; nSubjects = size(SubjectID,2); f = figure; subplot(2,1,1); plotPSTH(psth,psthStart,psthEnd); % plot performance timeline 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 type case 'simple' plotDecodePerformanceWithSE(frameStart,frameEnd,decodePerformance) case 'class performance' plotClassPerformance(frameStart,frameEnd,decodePerformance,nClasses) case 'x-subject-val' for c = 1:nSubjects plot(frameStart:frameEnd, decodePerformance(:,c) ,[colorChooser(mod(c,nSubjects)+3) '-']); end plotDecodePerformanceWithSE(frameStart,frameEnd,decodePerformance) end hold off; % setTitle(f,header,decode,subjectData); end function setTitle(f,header,decode,subjectData) 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 = SubjectID{1}.name; 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 plotClassPerformance(frameStart,frameEnd,decodePerformance,nClasses) 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 function plotDecodePerformanceWithSE(frameStart,frameEnd,decodePerformance) 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:'); end function plotPSTH(psth,psthStart,psthEnd) PSTH_AXIS_MIN = -2; PSTH_AXIS_MAX = 2; hold on; if (size(psth) > 0) 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 end axis([psthStart psthEnd PSTH_AXIS_MIN PSTH_AXIS_MAX]) xlabel('time [sec]'); ylabel('fMRI-signal change [%]'); hold off 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