function classify(varargin) switch nargin case 0 action = 'decode'; SubjectID = 'JZ006'; case 1 action = 'decode'; paramModel = varargin{1}; otherwise error('spmtoolbox:SVMCrossVal:arginError','Please Specify action and parameter model'); end switch(action) case 'clear' evalin('base','clear map lm SPM classList dataTimeLine decodeTable labelTimeLine svmopts trialProtocol voxelList xTimeEnd xTimeStart xTimeWindow'); case 'decode' tmp_sidx = get(paramModel.subjectSelector,'Value'); tmp_cellList = getSubjectCellList(paramModel.subjectMap); SubjectID = cell2mat(tmp_cellList(tmp_sidx)); display('loading SPM.mat'); % SubjectID = 'JZ006'; % SubjectID = 'AI020'; % SubjectID = 'HG027'; spm = load(fullfile('D:\Analyze\Choice\24pilot',SubjectID,'results\SPM.mat')); display('done.'); map = SubjectRoiMapping; voxelList = [... getCoordinate(map,SubjectID,'SPL l')+[0,0,0];... getCoordinate(map,SubjectID,'SPL l')+[1,0,0];... getCoordinate(map,SubjectID,'SPL l')+[-1,0,0];... getCoordinate(map,SubjectID,'SPL l')+[0,1,0];... getCoordinate(map,SubjectID,'SPL l')+[0,-1,0];... getCoordinate(map,SubjectID,'SPL l')+[0,0,1];... getCoordinate(map,SubjectID,'SPL l')+[0,0,-1];... getCoordinate(map,SubjectID,'SPL r')+[0,0,0];... getCoordinate(map,SubjectID,'SPL r')+[1,0,0];... getCoordinate(map,SubjectID,'SPL r')+[-1,0,0];... getCoordinate(map,SubjectID,'SPL r')+[0,1,0];... getCoordinate(map,SubjectID,'SPL r')+[0,-1,0];... getCoordinate(map,SubjectID,'SPL r')+[0,0,1];... getCoordinate(map,SubjectID,'SPL r')+[0,0,-1];... getCoordinate(map,SubjectID,'M1 r')+[0,0,0];... getCoordinate(map,SubjectID,'M1 l')+[0,0,0];... ]; params = struct; params.nClasses = 2; assignin('base','params',params); %% calculate display('calculating cross-validation performance time-shift'); calculateParams = struct; calculateParams.des = spm.SPM; calculateParams.frameShiftStart = -20; calculateParams.frameShiftEnd = 15; calculateParams.decodeDuration = 0; calculateParams.svmargs = '-t 0 -s 0 -v 6'; calculateParams.sessionList = 1:3; calculateParams.voxelList = voxelList; calculateParams.classList = {'<','>'}; calculateParams.labelMap = LabelMap({'<','>','<+<','>+>','<+>','>+<'},{-2,-1,1,2,3,4}); calculateParams.psthStart = -25; calculateParams.psthEnd = 20; calculateParams.baselineStart = -22; calculateParams.baselineEnd = -20; calculateParams.eventList = [9,11,13; 10,12,14]; assignin('base','calculateParams',calculateParams); % [decodeTable rawTimeCourse] = calculateDecodePerformance(spm,params.frameShiftStart,params.frameShiftEnd,params.xTimeWindow,params.svmopts,1:4,params.sessionList,params.voxelList,params.classList,params.labelMap,params.normalize); decode = calculateDecodePerformance(calculateParams); display(sprintf('Min CrossVal Accuracy: %g%% \t Max CrossVal Accuracy: %g%%',decode.minPerformance,decode.maxPerformance)); assignin('base','decode',decode); display('Finished calculations.'); display('Plotting.'); plotParams = struct; plotParams.psthStart = calculateParams.psthStart; plotParams.psthEnd = calculateParams.psthEnd; plotParams.nClasses = length(calculateParams.classList); plotParams.frameShiftStart = calculateParams.frameShiftStart; plotParams.frameShiftEnd = calculateParams.frameShiftEnd; plotParams.decodePerformance = decode.decodePerformance; plotParams.rawTimeCourse = decode.rawTimeCourse; plotParams.SubjectID = SubjectID; assignin('base','plotParams',plotParams); % plotDecodePerformance(params.psthStart,params.psthEnd,params.nClasses,decode.decodeTable,params.frameShiftStart,params.frameShiftEnd,decode.rawTimeCourse); plotDecodePerformance(plotParams); otherwise display('give action command: clear decode'); end end