644333a8c37a8d2e2d8c96c91ddc26d0d0b667b7
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

1) function classify(varargin)
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

2) 
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

3) switch nargin
4)     case 0
5)         action = 'decode';
6)         SubjectID = 'JZ006';
7)     case 1
8)         action = 'decode';
9)         paramModel = varargin{1};
10)     otherwise
11)         error('spmtoolbox:SVMCrossVal:arginError','Please Specify action and parameter model');
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

12) end
13) 
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

14)     
15) 
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

16)     switch(action)
17)     case 'clear'
18)         evalin('base','clear map lm SPM classList dataTimeLine decodeTable labelTimeLine svmopts trialProtocol voxelList xTimeEnd xTimeStart xTimeWindow');
19)       
20)     case 'decode'
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

21)         tmp_sidx =  get(paramModel.subjectSelector,'Value');
22)         tmp_cellList = getSubjectCellList(paramModel.subjectMap);
23)         SubjectID = cell2mat(tmp_cellList(tmp_sidx));
24)         
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

25)         display('loading SPM.mat');
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

26) %         SubjectID = 'JZ006';
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

27) %         SubjectID = 'AI020';
28) %         SubjectID = 'HG027';
29)         spm = load(fullfile('D:\Analyze\Choice\24pilot',SubjectID,'results\SPM.mat'));
30) 
31)         display('done.');
32) 
33) 
34) 
35) 
36)         map = SubjectRoiMapping;
37) 
38)         voxelList  = [...
39)                       getCoordinate(map,SubjectID,'SPL l')+[0,0,0];...
40)                           getCoordinate(map,SubjectID,'SPL l')+[1,0,0];...
41)                           getCoordinate(map,SubjectID,'SPL l')+[-1,0,0];...
42)                           getCoordinate(map,SubjectID,'SPL l')+[0,1,0];...
43)                           getCoordinate(map,SubjectID,'SPL l')+[0,-1,0];...
44)                           getCoordinate(map,SubjectID,'SPL l')+[0,0,1];...
45)                           getCoordinate(map,SubjectID,'SPL l')+[0,0,-1];...
46)                       getCoordinate(map,SubjectID,'SPL r')+[0,0,0];...
47)                           getCoordinate(map,SubjectID,'SPL r')+[1,0,0];...
48)                           getCoordinate(map,SubjectID,'SPL r')+[-1,0,0];...
49)                           getCoordinate(map,SubjectID,'SPL r')+[0,1,0];...
50)                           getCoordinate(map,SubjectID,'SPL r')+[0,-1,0];...
51)                           getCoordinate(map,SubjectID,'SPL r')+[0,0,1];...
52)                           getCoordinate(map,SubjectID,'SPL r')+[0,0,-1];...
53)                       getCoordinate(map,SubjectID,'M1 r')+[0,0,0];...
54)                       getCoordinate(map,SubjectID,'M1 l')+[0,0,0];...
55)                       ];
56)         
57)         
58)         params = struct;
59)         params.nClasses = 2;
60) 
61)         assignin('base','params',params);
62)         %% calculate
63)         display('calculating cross-validation performance time-shift');
64)         calculateParams  = struct;
65)         
66)         calculateParams.des             = spm.SPM;
67)         calculateParams.frameShiftStart = -20;
68)         calculateParams.frameShiftEnd   = 15;
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

69)         calculateParams.decodeDuration  = 0;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

70)         calculateParams.svmargs         = '-t 0 -s 0 -v 6';
71)         calculateParams.sessionList     = 1:3;
72)         calculateParams.voxelList       = voxelList;
73)         calculateParams.classList       = {'<','>'};
74)         calculateParams.labelMap        = LabelMap({'<','>','<+<','>+>','<+>','>+<'},{-2,-1,1,2,3,4});
75)         calculateParams.psthStart       = -25;
76)         calculateParams.psthEnd         = 20;
77)         calculateParams.baselineStart   = -22;
78)         calculateParams.baselineEnd     = -20;
79)         calculateParams.eventList       = [9,11,13; 10,12,14];
80)         
81)         assignin('base','calculateParams',calculateParams);
82)         
83) %         [decodeTable rawTimeCourse] = calculateDecodePerformance(spm,params.frameShiftStart,params.frameShiftEnd,params.xTimeWindow,params.svmopts,1:4,params.sessionList,params.voxelList,params.classList,params.labelMap,params.normalize);
84)         decode = calculateDecodePerformance(calculateParams);
85)         display(sprintf('Min CrossVal Accuracy: %g%% \t Max CrossVal Accuracy: %g%%',decode.minPerformance,decode.maxPerformance));
86)         
87)         assignin('base','decode',decode);
88) 
89)         display('Finished calculations.');
90)         display('Plotting.');
91) 
92)         plotParams = struct;
93)         plotParams.psthStart = calculateParams.psthStart;
94)         plotParams.psthEnd   = calculateParams.psthEnd;
95)         plotParams.nClasses  = length(calculateParams.classList);
96)         plotParams.frameShiftStart   = calculateParams.frameShiftStart;
97)         plotParams.frameShiftEnd     = calculateParams.frameShiftEnd;
98)         plotParams.decodePerformance = decode.decodePerformance;
99)         plotParams.rawTimeCourse     = decode.rawTimeCourse;
100)         plotParams.SubjectID         = SubjectID;
101)         
102)         assignin('base','plotParams',plotParams);
103) %         plotDecodePerformance(params.psthStart,params.psthEnd,params.nClasses,decode.decodeTable,params.frameShiftStart,params.frameShiftEnd,decode.rawTimeCourse);
104)         plotDecodePerformance(plotParams);
105) 
106)     otherwise
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

107)         display('give action command: clear decode');