% function [decodePerformance rawTimecourse ] = calculateDecodePerformance(des,timeLineStart, timeLineEnd, decodeDuration, svmargs, conditionList, sessionList, voxelList, classList, labelMap,normalize) function outputStruct = calculateDecodePerformance(inputStruct,SubjectID) addpath 'libsvm-mat-2.88-1'; SINGLE = 1; outputStruct = struct; namehelper = strcat('s',SubjectID); des = inputStruct.(namehelper).des; timeLineStart = inputStruct.frameShiftStart; timeLineEnd = inputStruct.frameShiftEnd; decodeDuration = inputStruct.decodeDuration; svmargs = inputStruct.svmargs; sessionList = inputStruct.sessionList; voxelList = inputStruct.(namehelper).voxelList; % classList = inputStruct.classList; % labelMap = inputStruct.labelMap; smoothed = inputStruct.smoothed; globalStart = inputStruct.psthStart; globalEnd = inputStruct.psthEnd; baselineStart = inputStruct.baselineStart; baselineEnd = inputStruct.baselineEnd; eventList = inputStruct.eventList; labelMap = inputStruct.labelMap; minPerformance = inf; maxPerformance = -inf; %Pro Voxel PSTH TIMELINE berechnen. % timeshift mit pst-timeline durchführen. % psth-timeline -25 bis +15 zu RES Onset. % eventList = [9,11,13;10,12,14]; % globalStart = -25; % globalEnd = 15; % baselineStart = -22; % baselineEnd = -20; for voxel = 1:size(voxelList,1) % [[x;x],[y;y],[z;z]] extr = calculateImageData(voxelList(voxel,:),des,smoothed); rawdata=cell2mat({extr.mean}); % Raw Data pst{voxel} = calculatePST(des,globalStart,baselineStart,baselineEnd,globalEnd,eventList,rawdata,sessionList); end decodePerformance = []; for timeShift = timeLineStart:1:timeLineEnd frameStart = floor(-globalStart+1+timeShift - 0.5*decodeDuration); frameEnd = min(ceil(frameStart+decodeDuration + 0.5*decodeDuration),-globalStart+globalEnd); tmp =[]; anyvoxel = 1; for pstConditionGroup = 1:size(pst{1,anyvoxel},2) for dp = 1:size(pst{1,anyvoxel}{1,pstConditionGroup},1) % data point row = getSVMLabel(labelMap,eventList(pstConditionGroup,1)); for voxel = 1:size(pst,2) row = [row, pst{1,voxel}{1,pstConditionGroup}(dp,frameStart:frameEnd)]; % label,value,value end tmp = [tmp; row]; end end svmdata = tmp(:,2:size(tmp,2)); svmlabel = tmp(:,1); % rndindex = randperm(length(svmlabel)); % svmdata = svmdata(rndindex,:); % svmlabel = svmlabel(rndindex); if SINGLE performance = svmtrain(svmlabel, svmdata, svmargs); minPerformance = min(minPerformance,performance); maxPerformance = max(maxPerformance,performance); decodePerformance = [decodePerformance; performance]; end end outputStruct.decodePerformance = decodePerformance; outputStruct.svmdata = svmdata; outputStruct.svmlabel = svmlabel; outputStruct.rawTimeCourse = pst; outputStruct.minPerformance = minPerformance; outputStruct.maxPerformance = maxPerformance; end