git.schokokeks.org
Repositories
Help
Report an Issue
SVMCrossVal.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
2095645
Branches
Tags
master
SVMCrossVal.git
classify.m
SVMCrossVal toolbox init
Christoph Budziszewski
commited
2095645
at 2008-12-17 13:45:29
classify.m
Blame
History
Raw
function classify(action) if ~exist('action','var') action='no action'; end switch(action) case 'clear' evalin('base','clear map lm SPM classList dataTimeLine decodeTable labelTimeLine svmopts trialProtocol voxelList xTimeEnd xTimeStart xTimeWindow'); case 'decode' 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 = 1; 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); case 'gen' center = '[-39 -33 67]'; sessionList = '1:3'; conditionList = '1:2'; radius = 3; normalize = 1; cmd=sprintf(... '[label data] = generateDataMatrix(generateVoxelList(%s,%d), generateTrialProtocol(%s,%s),%d);',... center,radius,sessionList,conditionList,normalize); % assignin('base','label',label); % assignin('base','data',data); case 'norm' cmd = ['for i=1:size(data,2)'... 'data(:,i)=data(:,i)/std(data(:,i));'... 'end;']; case 'xtrain' svmargs = '-t 0'; %linear kernel svmargs = [svmargs '-v 4']; cmd=sprintf('model = svmtrain(label,data,''%s'')',svmargs); case 'train' svmargs = '-t 0'; %linear kernel % svmargs = [svmargs '-v 4']; cmd=sprintf('model = svmtrain(label,data,%s)',svmargs); case 'pred' cmd = '[predicted_label, accuracy, decision_values] = svmpredict(label, data, model);'; otherwise display('give action command: clear load gen (norm) xtrain train pred'); end if exist('cmd','var') evalin('base',cmd); end end