Browse code

moving things to private, some modifications

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@110 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on16/01/2009 02:48:58
Showing1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,100 +0,0 @@
1
-function classify(varargin)
2
-
3
-
4
-
5
-switch nargin
6
-    case 1
7
-        paramModel = varargin{1};
8
-        %PROJECT_BASE_PATH = 'D:\Analyze\Stimolos';
9
-        PROJECT_BASE_PATH = 'D:\Analyze\Choice\24pilot';
10
-        PROJECT_RESULT_PATH = 'results\SPM.mat';
11
-    otherwise
12
-        error('spmtoolbox:SVMCrossVal:arginError','Please Specify action and parameter model');
13
-end
14
-
15
-        
16
-        % common params
17
-        calculateParams  = struct;
18
-        calculateParams.smoothed        = getDouble(paramModel.txtSmoothed);
19
-
20
-        calculateParams.frameShiftStart = getDouble(paramModel.txtFrameShiftStart);  % -20;
21
-        calculateParams.frameShiftEnd   = getDouble(paramModel.txtFrameShiftEnd); %15;
22
-        calculateParams.decodeDuration  = getDouble(paramModel.txtFrameShiftDur);
23
-        calculateParams.psthStart       = getDouble(paramModel.txtPSTHStart); % -25;
24
-        calculateParams.psthEnd         = getDouble(paramModel.txtPSTHEnd); % 20;
25
-        calculateParams.baselineStart   = getDouble(paramModel.txtBaselineStart); % -22;
26
-        calculateParams.baselineEnd     = getDouble(paramModel.txtBaselineEnd); % -20;
27
-
28
-        calculateParams.svmargs         = get(paramModel.txtSVMopts,'String');
29
-        calculateParams.sessionList     = 1:3;
30
-
31
-        classStruct = parseClassDef(paramModel);
32
-        
33
-        
34
-        calculateParams.labelMap        = LabelMap(classStruct.labelCells , classStruct.conditionCells, 'auto'); % LabelMap({'<','>','<+<','>+>','<+>','>+<'},{-2,-1,1,2,3,4}); 0 is autolabel
35
-        calculateParams.classList       = getClasses(calculateParams.labelMap);
36
-        calculateParams.eventList       = classStruct.eventMatrix; %[9,11,13; 10,12,14];
37
-%         calculateParams.eventList       = getPSTEventMatrix(calculateParams.labelMap);
38
-        
39
-        subjectSelection = getSubjectIDString(paramModel);
40
-        decode = struct;
41
-        decode.decodePerformance = [];
42
-        decode.rawTimeCourse     = [];
43
-        
44
-        for subjectCell = subjectSelection
45
-            SubjectID = cell2mat(subjectCell);
46
-            namehelper = strcat('s',SubjectID); %Vars can not start with numbers.
47
-
48
-            display('loading SPM.mat ...');
49
-            spm = load(fullfile(PROJECT_BASE_PATH,SubjectID,PROJECT_RESULT_PATH));
50
-            display('... done.');
51
-
52
-            %% calculate
53
-            calculateParams.(namehelper).des             = spm.SPM;
54
-            calculateParams.(namehelper).voxelList       = parseVoxelList(paramModel,SubjectID);
55
-            assignin('base','calculateParams',calculateParams);
56
-
57
-            display(sprintf('calculating cross-validation performance time-shift for Subject %s. Please Wait. ...',SubjectID));
58
-            display('switching off all warnings');
59
-            warning_state               = warning('off','all');
60
-            display('calculating ...');
61
-            decode.(namehelper)         = calculateDecodePerformance(calculateParams,SubjectID);
62
-            display('... done');
63
-            display('restoring warnings');
64
-            warning(warning_state);
65
-            
66
-            decode.decodePerformance    = [decode.decodePerformance decode.(namehelper).decodePerformance];
67
-            decode.rawTimeCourse        = [decode.rawTimeCourse decode.(namehelper).rawTimeCourse];
68
-
69
-            assignin('base','decode',decode);
70
-        end
71
-
72
-        display('Finished calculations.');
73
-        display('Plotting...');
74
-
75
-        plotParams                   = struct;
76
-        plotParams.psthStart         = calculateParams.psthStart;
77
-        plotParams.psthEnd           = calculateParams.psthEnd;
78
-        plotParams.nClasses          = length(calculateParams.classList);
79
-        
80
-        plotParams.frameShiftStart   = calculateParams.frameShiftStart;
81
-        plotParams.frameShiftEnd     = calculateParams.frameShiftEnd;
82
-        plotParams.decodePerformance = decode.decodePerformance;
83
-        plotParams.rawTimeCourse     = decode.rawTimeCourse;
84
-        
85
-        if numel(subjectSelection) == 1
86
-          plotParams.SubjectID         = SubjectID;
87
-        else
88
-          plotParams.SubjectID         = 'Multiple';
89
-        end
90
-
91
-        plotParams.smoothed          = boolToYesNoString(calculateParams.smoothed);
92
-         
93
-
94
-        assignin('base','plotParams',plotParams);
95
-%         plotDecodePerformance(params.psthStart,params.psthEnd,params.nClasses,decode.decodeTable,params.frameShiftStart,params.frameShiftEnd,decode.rawTimeCourse);
96
-        plotDecodePerformance(plotParams);
97
-            
98
-        display('all done.');
99
-
100
-    end
101 0
\ No newline at end of file
Browse code

New Option for COL Bias removal in calculatePST

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@105 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Axel Lindner authored on10/01/2009 08:50:16
Showing1 changed files
... ...
@@ -5,8 +5,8 @@ function classify(varargin)
5 5
 switch nargin
6 6
     case 1
7 7
         paramModel = varargin{1};
8
-         PROJECT_BASE_PATH = 'D:\Analyze\Stimolos';
9
-        %PROJECT_BASE_PATH = 'D:\Analyze\Choice\24pilot';
8
+        %PROJECT_BASE_PATH = 'D:\Analyze\Stimolos';
9
+        PROJECT_BASE_PATH = 'D:\Analyze\Choice\24pilot';
10 10
         PROJECT_RESULT_PATH = 'results\SPM.mat';
11 11
     otherwise
12 12
         error('spmtoolbox:SVMCrossVal:arginError','Please Specify action and parameter model');
Browse code

plot optimiert. normalisierung pst, zwischenversion UI Defaults verbessert

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@103 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Axel Lindner authored on09/01/2009 15:52:07
Showing1 changed files
... ...
@@ -5,8 +5,8 @@ function classify(varargin)
5 5
 switch nargin
6 6
     case 1
7 7
         paramModel = varargin{1};
8
-        % PROJECT_BASE_PATH = 'D:\Analyze\Stimolos';
9
-        PROJECT_BASE_PATH = 'D:\Analyze\Choice\24pilot';
8
+         PROJECT_BASE_PATH = 'D:\Analyze\Stimolos';
9
+        %PROJECT_BASE_PATH = 'D:\Analyze\Choice\24pilot';
10 10
         PROJECT_RESULT_PATH = 'results\SPM.mat';
11 11
     otherwise
12 12
         error('spmtoolbox:SVMCrossVal:arginError','Please Specify action and parameter model');
Browse code

kleine änderungen code move

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@102 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on08/01/2009 11:44:25
Showing1 changed files
... ...
@@ -36,9 +36,6 @@ end
36 36
         calculateParams.eventList       = classStruct.eventMatrix; %[9,11,13; 10,12,14];
37 37
 %         calculateParams.eventList       = getPSTEventMatrix(calculateParams.labelMap);
38 38
         
39
-%         params = struct;
40
-%         params.nClasses = 2;
41
-        
42 39
         subjectSelection = getSubjectIDString(paramModel);
43 40
         decode = struct;
44 41
         decode.decodePerformance = [];
... ...
@@ -53,26 +50,21 @@ end
53 50
             display('... done.');
54 51
 
55 52
             %% calculate
56
-            display(sprintf('calculating cross-validation performance time-shift for Subject %s. Please Wait. ...',SubjectID));
57 53
             calculateParams.(namehelper).des             = spm.SPM;
58 54
             calculateParams.(namehelper).voxelList       = parseVoxelList(paramModel,SubjectID);
59
-            
60 55
             assignin('base','calculateParams',calculateParams);
61
-            
62
-    %         [decodeTable rawTimeCourse] = calculateDecodePerformance(spm,params.frameShiftStart,params.frameShiftEnd,params.xTimeWindow,params.svmopts,1:4,params.sessionList,params.voxelList,params.classList,params.labelMap,params.normalize);
56
+
57
+            display(sprintf('calculating cross-validation performance time-shift for Subject %s. Please Wait. ...',SubjectID));
63 58
             display('switching off all warnings');
64
-            warning_state = warning('off','all');
59
+            warning_state               = warning('off','all');
65 60
             display('calculating ...');
66
-            decode.(namehelper) = calculateDecodePerformance(calculateParams,SubjectID);
61
+            decode.(namehelper)         = calculateDecodePerformance(calculateParams,SubjectID);
67 62
             display('... done');
68 63
             display('restoring warnings');
69 64
             warning(warning_state);
70 65
             
71
-            decode.decodePerformance = [decode.decodePerformance decode.(namehelper).decodePerformance];
72
-            decode.rawTimeCourse = [decode.rawTimeCourse decode.(namehelper).rawTimeCourse];
73
-  
74
-            
75
-%             display(sprintf('Min CrossVal Accuracy: %g%% \t Max CrossVal Accuracy: %g%%',decode.minPerformance,decode.maxPerformance));
66
+            decode.decodePerformance    = [decode.decodePerformance decode.(namehelper).decodePerformance];
67
+            decode.rawTimeCourse        = [decode.rawTimeCourse decode.(namehelper).rawTimeCourse];
76 68
 
77 69
             assignin('base','decode',decode);
78 70
         end
... ...
@@ -80,10 +72,10 @@ end
80 72
         display('Finished calculations.');
81 73
         display('Plotting...');
82 74
 
83
-        plotParams = struct;
84
-        plotParams.psthStart = calculateParams.psthStart;
85
-        plotParams.psthEnd   = calculateParams.psthEnd;
86
-        plotParams.nClasses  = length(calculateParams.classList);
75
+        plotParams                   = struct;
76
+        plotParams.psthStart         = calculateParams.psthStart;
77
+        plotParams.psthEnd           = calculateParams.psthEnd;
78
+        plotParams.nClasses          = length(calculateParams.classList);
87 79
         
88 80
         plotParams.frameShiftStart   = calculateParams.frameShiftStart;
89 81
         plotParams.frameShiftEnd     = calculateParams.frameShiftEnd;
Browse code

new LabelMap new svm grouping method

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@100 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on07/01/2009 18:26:33
Showing1 changed files
... ...
@@ -1,24 +1,17 @@
1 1
 function classify(varargin)
2 2
 
3
-PROJECT_BASE_PATH = 'D:\Analyze\Stimolos';
4
-PROJECT_RESULT_PATH = 'results\SPM.mat';
3
+
5 4
 
6 5
 switch nargin
7 6
     case 1
8
-        action = 'decode';
9 7
         paramModel = varargin{1};
8
+        % PROJECT_BASE_PATH = 'D:\Analyze\Stimolos';
9
+        PROJECT_BASE_PATH = 'D:\Analyze\Choice\24pilot';
10
+        PROJECT_RESULT_PATH = 'results\SPM.mat';
10 11
     otherwise
11 12
         error('spmtoolbox:SVMCrossVal:arginError','Please Specify action and parameter model');
12 13
 end
13 14
 
14
-    
15
-
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'
21
-        
22 15
         
23 16
         % common params
24 17
         calculateParams  = struct;
... ...
@@ -37,13 +30,14 @@ end
37 30
 
38 31
         classStruct = parseClassDef(paramModel);
39 32
         
40
-        calculateParams.classList       = classStruct.label; %{'<','>'};
41
-        calculateParams.labelMap        = LabelMap(classStruct.label , classStruct.value); % LabelMap({'<','>','<+<','>+>','<+>','>+<'},{-2,-1,1,2,3,4});
42
-        calculateParams.eventList       = classStruct.event; %[9,11,13; 10,12,14];
43
-
44
-        params = struct;
45
-        params.nClasses = 2;
46 33
         
34
+        calculateParams.labelMap        = LabelMap(classStruct.labelCells , classStruct.conditionCells, 'auto'); % LabelMap({'<','>','<+<','>+>','<+>','>+<'},{-2,-1,1,2,3,4}); 0 is autolabel
35
+        calculateParams.classList       = getClasses(calculateParams.labelMap);
36
+        calculateParams.eventList       = classStruct.eventMatrix; %[9,11,13; 10,12,14];
37
+%         calculateParams.eventList       = getPSTEventMatrix(calculateParams.labelMap);
38
+        
39
+%         params = struct;
40
+%         params.nClasses = 2;
47 41
         
48 42
         subjectSelection = getSubjectIDString(paramModel);
49 43
         decode = struct;
... ...
@@ -52,14 +46,14 @@ end
52 46
         
53 47
         for subjectCell = subjectSelection
54 48
             SubjectID = cell2mat(subjectCell);
49
+            namehelper = strcat('s',SubjectID); %Vars can not start with numbers.
55 50
 
56
-            display('loading SPM.mat');
51
+            display('loading SPM.mat ...');
57 52
             spm = load(fullfile(PROJECT_BASE_PATH,SubjectID,PROJECT_RESULT_PATH));
58
-%             display('done.');
53
+            display('... done.');
59 54
 
60 55
             %% calculate
61
-            display(sprintf('calculating cross-validation performance time-shift for Subject %s',SubjectID));
62
-            namehelper = strcat('s',SubjectID);
56
+            display(sprintf('calculating cross-validation performance time-shift for Subject %s. Please Wait. ...',SubjectID));
63 57
             calculateParams.(namehelper).des             = spm.SPM;
64 58
             calculateParams.(namehelper).voxelList       = parseVoxelList(paramModel,SubjectID);
65 59
             
... ...
@@ -68,8 +62,9 @@ end
68 62
     %         [decodeTable rawTimeCourse] = calculateDecodePerformance(spm,params.frameShiftStart,params.frameShiftEnd,params.xTimeWindow,params.svmopts,1:4,params.sessionList,params.voxelList,params.classList,params.labelMap,params.normalize);
69 63
             display('switching off all warnings');
70 64
             warning_state = warning('off','all');
71
-            
65
+            display('calculating ...');
72 66
             decode.(namehelper) = calculateDecodePerformance(calculateParams,SubjectID);
67
+            display('... done');
73 68
             display('restoring warnings');
74 69
             warning(warning_state);
75 70
             
... ...
@@ -108,9 +103,6 @@ end
108 103
 %         plotDecodePerformance(params.psthStart,params.psthEnd,params.nClasses,decode.decodeTable,params.frameShiftStart,params.frameShiftEnd,decode.rawTimeCourse);
109 104
         plotDecodePerformance(plotParams);
110 105
             
111
-        display('done.');
106
+        display('all done.');
112 107
 
113
-    otherwise
114
-        display('give action command: clear, decode');
115
-    end
116 108
     end
117 109
\ No newline at end of file
Browse code

New5 Studie, Var-Name ersetzungs bug

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@98 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on07/01/2009 12:57:14
Showing1 changed files
... ...
@@ -1,6 +1,6 @@
1 1
 function classify(varargin)
2 2
 
3
-PROJECT_BASE_PATH = 'D:\Analyze\Choice\24pilot';
3
+PROJECT_BASE_PATH = 'D:\Analyze\Stimolos';
4 4
 PROJECT_RESULT_PATH = 'results\SPM.mat';
5 5
 
6 6
 switch nargin
... ...
@@ -59,9 +59,9 @@ end
59 59
 
60 60
             %% calculate
61 61
             display(sprintf('calculating cross-validation performance time-shift for Subject %s',SubjectID));
62
-
63
-            calculateParams.(SubjectID).des             = spm.SPM;
64
-            calculateParams.(SubjectID).voxelList       = parseVoxelList(paramModel,SubjectID);
62
+            namehelper = strcat('s',SubjectID);
63
+            calculateParams.(namehelper).des             = spm.SPM;
64
+            calculateParams.(namehelper).voxelList       = parseVoxelList(paramModel,SubjectID);
65 65
             
66 66
             assignin('base','calculateParams',calculateParams);
67 67
             
... ...
@@ -69,12 +69,12 @@ end
69 69
             display('switching off all warnings');
70 70
             warning_state = warning('off','all');
71 71
             
72
-            decode.(SubjectID) = calculateDecodePerformance(calculateParams,SubjectID);
72
+            decode.(namehelper) = calculateDecodePerformance(calculateParams,SubjectID);
73 73
             display('restoring warnings');
74 74
             warning(warning_state);
75 75
             
76
-            decode.decodePerformance = [decode.decodePerformance decode.(SubjectID).decodePerformance];
77
-            decode.rawTimeCourse = [decode.rawTimeCourse decode.(SubjectID).rawTimeCourse];
76
+            decode.decodePerformance = [decode.decodePerformance decode.(namehelper).decodePerformance];
77
+            decode.rawTimeCourse = [decode.rawTimeCourse decode.(namehelper).rawTimeCourse];
78 78
   
79 79
             
80 80
 %             display(sprintf('Min CrossVal Accuracy: %g%% \t Max CrossVal Accuracy: %g%%',decode.minPerformance,decode.maxPerformance));
Browse code

multi-subject support

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@96 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on05/01/2009 18:25:16
Showing1 changed files
... ...
@@ -1,13 +1,12 @@
1 1
 function classify(varargin)
2 2
 
3
+PROJECT_BASE_PATH = 'D:\Analyze\Choice\24pilot';
4
+PROJECT_RESULT_PATH = 'results\SPM.mat';
5
+
3 6
 switch nargin
4
-    case 0
5
-        action = 'decode';
6
-        SubjectID = 'JZ006';
7 7
     case 1
8 8
         action = 'decode';
9 9
         paramModel = varargin{1};
10
-        SubjectID = getSubjectIDString(paramModel);
11 10
     otherwise
12 11
         error('spmtoolbox:SVMCrossVal:arginError','Please Specify action and parameter model');
13 12
 end
... ...
@@ -20,26 +19,11 @@ end
20 19
       
21 20
     case 'decode'
22 21
         
23
-        display('loading SPM.mat');
24
-%         SubjectID = 'JZ006';
25
-%         SubjectID = 'AI020';
26
-%         SubjectID = 'HG027';
27
-        spm = load(fullfile('D:\Analyze\Choice\24pilot',SubjectID,'results\SPM.mat'));
28
-
29
-        display('done.');
30 22
         
31
-        params = struct;
32
-        params.nClasses = 2;
33
-
34
-%         assignin('base','params',params);
35
-        %% calculate
36
-        display('calculating cross-validation performance time-shift');
23
+        % common params
37 24
         calculateParams  = struct;
38
-        
39
-        calculateParams.des             = spm.SPM;
40
-        
41 25
         calculateParams.smoothed        = getDouble(paramModel.txtSmoothed);
42
-        
26
+
43 27
         calculateParams.frameShiftStart = getDouble(paramModel.txtFrameShiftStart);  % -20;
44 28
         calculateParams.frameShiftEnd   = getDouble(paramModel.txtFrameShiftEnd); %15;
45 29
         calculateParams.decodeDuration  = getDouble(paramModel.txtFrameShiftDur);
... ...
@@ -48,47 +32,85 @@ end
48 32
         calculateParams.baselineStart   = getDouble(paramModel.txtBaselineStart); % -22;
49 33
         calculateParams.baselineEnd     = getDouble(paramModel.txtBaselineEnd); % -20;
50 34
 
51
-        calculateParams.voxelList       = parseVoxelList(paramModel);
52
-
53 35
         calculateParams.svmargs         = get(paramModel.txtSVMopts,'String');
54 36
         calculateParams.sessionList     = 1:3;
55 37
 
56 38
         classStruct = parseClassDef(paramModel);
57
-%         assignin('base','classStruct',classStruct);
58 39
         
59 40
         calculateParams.classList       = classStruct.label; %{'<','>'};
60 41
         calculateParams.labelMap        = LabelMap(classStruct.label , classStruct.value); % LabelMap({'<','>','<+<','>+>','<+>','>+<'},{-2,-1,1,2,3,4});
61 42
         calculateParams.eventList       = classStruct.event; %[9,11,13; 10,12,14];
43
+
44
+        params = struct;
45
+        params.nClasses = 2;
62 46
         
63 47
         
64
-        assignin('base','calculateParams',calculateParams);
65
-        
66
-%         [decodeTable rawTimeCourse] = calculateDecodePerformance(spm,params.frameShiftStart,params.frameShiftEnd,params.xTimeWindow,params.svmopts,1:4,params.sessionList,params.voxelList,params.classList,params.labelMap,params.normalize);
67
-        decode = calculateDecodePerformance(calculateParams);
68
-        display(sprintf('Min CrossVal Accuracy: %g%% \t Max CrossVal Accuracy: %g%%',decode.minPerformance,decode.maxPerformance));
48
+        subjectSelection = getSubjectIDString(paramModel);
49
+        decode = struct;
50
+        decode.decodePerformance = [];
51
+        decode.rawTimeCourse     = [];
69 52
         
70
-        assignin('base','decode',decode);
53
+        for subjectCell = subjectSelection
54
+            SubjectID = cell2mat(subjectCell);
55
+
56
+            display('loading SPM.mat');
57
+            spm = load(fullfile(PROJECT_BASE_PATH,SubjectID,PROJECT_RESULT_PATH));
58
+%             display('done.');
59
+
60
+            %% calculate
61
+            display(sprintf('calculating cross-validation performance time-shift for Subject %s',SubjectID));
62
+
63
+            calculateParams.(SubjectID).des             = spm.SPM;
64
+            calculateParams.(SubjectID).voxelList       = parseVoxelList(paramModel,SubjectID);
65
+            
66
+            assignin('base','calculateParams',calculateParams);
67
+            
68
+    %         [decodeTable rawTimeCourse] = calculateDecodePerformance(spm,params.frameShiftStart,params.frameShiftEnd,params.xTimeWindow,params.svmopts,1:4,params.sessionList,params.voxelList,params.classList,params.labelMap,params.normalize);
69
+            display('switching off all warnings');
70
+            warning_state = warning('off','all');
71
+            
72
+            decode.(SubjectID) = calculateDecodePerformance(calculateParams,SubjectID);
73
+            display('restoring warnings');
74
+            warning(warning_state);
75
+            
76
+            decode.decodePerformance = [decode.decodePerformance decode.(SubjectID).decodePerformance];
77
+            decode.rawTimeCourse = [decode.rawTimeCourse decode.(SubjectID).rawTimeCourse];
78
+  
79
+            
80
+%             display(sprintf('Min CrossVal Accuracy: %g%% \t Max CrossVal Accuracy: %g%%',decode.minPerformance,decode.maxPerformance));
81
+
82
+            assignin('base','decode',decode);
83
+        end
71 84
 
72 85
         display('Finished calculations.');
73
-        display('Plotting.');
86
+        display('Plotting...');
74 87
 
75 88
         plotParams = struct;
76 89
         plotParams.psthStart = calculateParams.psthStart;
77 90
         plotParams.psthEnd   = calculateParams.psthEnd;
78 91
         plotParams.nClasses  = length(calculateParams.classList);
92
+        
79 93
         plotParams.frameShiftStart   = calculateParams.frameShiftStart;
80 94
         plotParams.frameShiftEnd     = calculateParams.frameShiftEnd;
81 95
         plotParams.decodePerformance = decode.decodePerformance;
82 96
         plotParams.rawTimeCourse     = decode.rawTimeCourse;
83
-        plotParams.SubjectID         = SubjectID;
84
-        plotParams.smoothed          = calculateParams.smoothed;
85 97
         
98
+        if numel(subjectSelection) == 1
99
+          plotParams.SubjectID         = SubjectID;
100
+        else
101
+          plotParams.SubjectID         = 'Multiple';
102
+        end
103
+
104
+        plotParams.smoothed          = boolToYesNoString(calculateParams.smoothed);
105
+         
106
+
86 107
         assignin('base','plotParams',plotParams);
87 108
 %         plotDecodePerformance(params.psthStart,params.psthEnd,params.nClasses,decode.decodeTable,params.frameShiftStart,params.frameShiftEnd,decode.rawTimeCourse);
88 109
         plotDecodePerformance(plotParams);
110
+            
111
+        display('done.');
89 112
 
90 113
     otherwise
91
-        display('give action command: clear decode');
114
+        display('give action command: clear, decode');
92 115
     end
93
-    
94
-end
95 116
\ No newline at end of file
117
+    end
96 118
\ No newline at end of file
Browse code

killed unnecessary assignin raw axis fixed value added smooth option

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@95 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on18/12/2008 15:29:41
Showing1 changed files
... ...
@@ -31,13 +31,15 @@ end
31 31
         params = struct;
32 32
         params.nClasses = 2;
33 33
 
34
-        assignin('base','params',params);
34
+%         assignin('base','params',params);
35 35
         %% calculate
36 36
         display('calculating cross-validation performance time-shift');
37 37
         calculateParams  = struct;
38 38
         
39 39
         calculateParams.des             = spm.SPM;
40 40
         
41
+        calculateParams.smoothed        = getDouble(paramModel.txtSmoothed);
42
+        
41 43
         calculateParams.frameShiftStart = getDouble(paramModel.txtFrameShiftStart);  % -20;
42 44
         calculateParams.frameShiftEnd   = getDouble(paramModel.txtFrameShiftEnd); %15;
43 45
         calculateParams.decodeDuration  = getDouble(paramModel.txtFrameShiftDur);
... ...
@@ -52,7 +54,7 @@ end
52 54
         calculateParams.sessionList     = 1:3;
53 55
 
54 56
         classStruct = parseClassDef(paramModel);
55
-        assignin('base','classStruct',classStruct);
57
+%         assignin('base','classStruct',classStruct);
56 58
         
57 59
         calculateParams.classList       = classStruct.label; %{'<','>'};
58 60
         calculateParams.labelMap        = LabelMap(classStruct.label , classStruct.value); % LabelMap({'<','>','<+<','>+>','<+>','>+<'},{-2,-1,1,2,3,4});
... ...
@@ -79,6 +81,7 @@ end
79 81
         plotParams.decodePerformance = decode.decodePerformance;
80 82
         plotParams.rawTimeCourse     = decode.rawTimeCourse;
81 83
         plotParams.SubjectID         = SubjectID;
84
+        plotParams.smoothed          = calculateParams.smoothed;
82 85
         
83 86
         assignin('base','plotParams',plotParams);
84 87
 %         plotDecodePerformance(params.psthStart,params.psthEnd,params.nClasses,decode.decodeTable,params.frameShiftStart,params.frameShiftEnd,decode.rawTimeCourse);
Browse code

class def parsing added strtrunc.m

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@94 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on17/12/2008 18:42:12
Showing1 changed files
... ...
@@ -28,8 +28,6 @@ end
28 28
 
29 29
         display('done.');
30 30
         
31
-        
32
-        
33 31
         params = struct;
34 32
         params.nClasses = 2;
35 33
 
... ...
@@ -48,15 +46,18 @@ end
48 46
         calculateParams.baselineStart   = getDouble(paramModel.txtBaselineStart); % -22;
49 47
         calculateParams.baselineEnd     = getDouble(paramModel.txtBaselineEnd); % -20;
50 48
 
51
-        calculateParams.voxelList = parseVoxelList(paramModel);
49
+        calculateParams.voxelList       = parseVoxelList(paramModel);
52 50
 
53 51
         calculateParams.svmargs         = get(paramModel.txtSVMopts,'String');
54 52
         calculateParams.sessionList     = 1:3;
55 53
 
56
-%         parseClassDef(paramModel)
57
-        calculateParams.classList       = {'<','>'};
58
-        calculateParams.labelMap        = LabelMap({'<','>','<+<','>+>','<+>','>+<'},{-2,-1,1,2,3,4});
59
-        calculateParams.eventList       = [9,11,13; 10,12,14];
54
+        classStruct = parseClassDef(paramModel);
55
+        assignin('base','classStruct',classStruct);
56
+        
57
+        calculateParams.classList       = classStruct.label; %{'<','>'};
58
+        calculateParams.labelMap        = LabelMap(classStruct.label , classStruct.value); % LabelMap({'<','>','<+<','>+>','<+>','>+<'},{-2,-1,1,2,3,4});
59
+        calculateParams.eventList       = classStruct.event; %[9,11,13; 10,12,14];
60
+        
60 61
         
61 62
         assignin('base','calculateParams',calculateParams);
62 63
         
Browse code

fixed: parseVoxelList empty-Lines bug

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@93 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on17/12/2008 18:04:50
Showing1 changed files
... ...
@@ -7,6 +7,7 @@ switch nargin
7 7
     case 1
8 8
         action = 'decode';
9 9
         paramModel = varargin{1};
10
+        SubjectID = getSubjectIDString(paramModel);
10 11
     otherwise
11 12
         error('spmtoolbox:SVMCrossVal:arginError','Please Specify action and parameter model');
12 13
 end
... ...
@@ -19,9 +20,6 @@ end
19 20
       
20 21
     case 'decode'
21 22
         
22
-        SubjectID = getSubjectIDString(paramModel);
23
-
24
-        
25 23
         display('loading SPM.mat');
26 24
 %         SubjectID = 'JZ006';
27 25
 %         SubjectID = 'AI020';
Browse code

GUI parsing halfway done.

working version

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@92 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on17/12/2008 17:57:53
Showing1 changed files
... ...
@@ -18,9 +18,9 @@ end
18 18
         evalin('base','clear map lm SPM classList dataTimeLine decodeTable labelTimeLine svmopts trialProtocol voxelList xTimeEnd xTimeStart xTimeWindow');
19 19
       
20 20
     case 'decode'
21
-        tmp_sidx =  get(paramModel.subjectSelector,'Value');
22
-        tmp_cellList = getSubjectCellList(paramModel.subjectMap);
23
-        SubjectID = cell2mat(tmp_cellList(tmp_sidx));
21
+        
22
+        SubjectID = getSubjectIDString(paramModel);
23
+
24 24
         
25 25
         display('loading SPM.mat');
26 26
 %         SubjectID = 'JZ006';
... ...
@@ -29,30 +29,7 @@ end
29 29
         spm = load(fullfile('D:\Analyze\Choice\24pilot',SubjectID,'results\SPM.mat'));
30 30
 
31 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
-                      ];
32
+        
56 33
         
57 34
         
58 35
         params = struct;
... ...
@@ -64,18 +41,23 @@ end
64 41
         calculateParams  = struct;
65 42
         
66 43
         calculateParams.des             = spm.SPM;
67
-        calculateParams.frameShiftStart = -20;
68
-        calculateParams.frameShiftEnd   = 15;
69
-        calculateParams.decodeDuration  = 0;
70
-        calculateParams.svmargs         = '-t 0 -s 0 -v 6';
44
+        
45
+        calculateParams.frameShiftStart = getDouble(paramModel.txtFrameShiftStart);  % -20;
46
+        calculateParams.frameShiftEnd   = getDouble(paramModel.txtFrameShiftEnd); %15;
47
+        calculateParams.decodeDuration  = getDouble(paramModel.txtFrameShiftDur);
48
+        calculateParams.psthStart       = getDouble(paramModel.txtPSTHStart); % -25;
49
+        calculateParams.psthEnd         = getDouble(paramModel.txtPSTHEnd); % 20;
50
+        calculateParams.baselineStart   = getDouble(paramModel.txtBaselineStart); % -22;
51
+        calculateParams.baselineEnd     = getDouble(paramModel.txtBaselineEnd); % -20;
52
+
53
+        calculateParams.voxelList = parseVoxelList(paramModel);
54
+
55
+        calculateParams.svmargs         = get(paramModel.txtSVMopts,'String');
71 56
         calculateParams.sessionList     = 1:3;
72
-        calculateParams.voxelList       = voxelList;
57
+
58
+%         parseClassDef(paramModel)
73 59
         calculateParams.classList       = {'<','>'};
74 60
         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 61
         calculateParams.eventList       = [9,11,13; 10,12,14];
80 62
         
81 63
         assignin('base','calculateParams',calculateParams);
Browse code

gui layout finished

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@91 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on17/12/2008 16:12:53
Showing1 changed files
... ...
@@ -1,19 +1,29 @@
1
-function classify(action)
1
+function classify(varargin)
2 2
 
3
-if ~exist('action','var')
4
-    action='no action';
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');
5 12
 end
6 13
 
14
+    
15
+
7 16
     switch(action)
8 17
     case 'clear'
9 18
         evalin('base','clear map lm SPM classList dataTimeLine decodeTable labelTimeLine svmopts trialProtocol voxelList xTimeEnd xTimeStart xTimeWindow');
10 19
       
11 20
     case 'decode'
12
-    
13
-
14
-
21
+        tmp_sidx =  get(paramModel.subjectSelector,'Value');
22
+        tmp_cellList = getSubjectCellList(paramModel.subjectMap);
23
+        SubjectID = cell2mat(tmp_cellList(tmp_sidx));
24
+        
15 25
         display('loading SPM.mat');
16
-        SubjectID = 'JZ006';
26
+%         SubjectID = 'JZ006';
17 27
 %         SubjectID = 'AI020';
18 28
 %         SubjectID = 'HG027';
19 29
         spm = load(fullfile('D:\Analyze\Choice\24pilot',SubjectID,'results\SPM.mat'));
... ...
@@ -56,7 +66,7 @@ end
56 66
         calculateParams.des             = spm.SPM;
57 67
         calculateParams.frameShiftStart = -20;
58 68
         calculateParams.frameShiftEnd   = 15;
59
-        calculateParams.decodeDuration  = 1;
69
+        calculateParams.decodeDuration  = 0;
60 70
         calculateParams.svmargs         = '-t 0 -s 0 -v 6';
61 71
         calculateParams.sessionList     = 1:3;
62 72
         calculateParams.voxelList       = voxelList;
... ...
@@ -93,46 +103,8 @@ end
93 103
 %         plotDecodePerformance(params.psthStart,params.psthEnd,params.nClasses,decode.decodeTable,params.frameShiftStart,params.frameShiftEnd,decode.rawTimeCourse);
94 104
         plotDecodePerformance(plotParams);
95 105
 
96
-        case 'gen'
97
-            center = '[-39 -33 67]';
98
-            sessionList = '1:3';
99
-            conditionList = '1:2';
100
-            radius = 3;
101
-            normalize = 1;
102
-
103
-            cmd=sprintf(...
104
-                '[label data] = generateDataMatrix(generateVoxelList(%s,%d), generateTrialProtocol(%s,%s),%d);',...
105
-                center,radius,sessionList,conditionList,normalize);
106
-
107
-            %     assignin('base','label',label);
108
-            %     assignin('base','data',data);
109
-
110
-    case 'norm'
111
-        cmd = ['for i=1:size(data,2)'...
112
-            'data(:,i)=data(:,i)/std(data(:,i));'...
113
-        'end;'];
114
-        
115
-    case 'xtrain'
116
-        svmargs = '-t 0'; %linear kernel
117
-        svmargs = [svmargs '-v 4'];
118
-        
119
-        cmd=sprintf('model = svmtrain(label,data,''%s'')',svmargs);
120
-        
121
-    case 'train'
122
-        svmargs = '-t 0'; %linear kernel
123
-%         svmargs = [svmargs '-v 4'];
124
-        
125
-        cmd=sprintf('model = svmtrain(label,data,%s)',svmargs);
126
-       
127
-    case 'pred'
128
-        cmd = '[predicted_label, accuracy, decision_values] = svmpredict(label, data, model);';
129
-        
130 106
     otherwise
131
-        display('give action command: clear load gen (norm) xtrain train pred');
107
+        display('give action command: clear decode');
132 108
     end
133 109
     
134
-    if exist('cmd','var') 
135
-        evalin('base',cmd);
136
-    end
137
-
138 110
 end
139 111
\ No newline at end of file
Browse code

SVMCrossVal toolbox init

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@90 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on17/12/2008 13:45:29
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,138 @@
1
+function classify(action)
2
+
3
+if ~exist('action','var')
4
+    action='no action';
5
+end
6
+
7
+    switch(action)
8
+    case 'clear'
9
+        evalin('base','clear map lm SPM classList dataTimeLine decodeTable labelTimeLine svmopts trialProtocol voxelList xTimeEnd xTimeStart xTimeWindow');
10
+      
11
+    case 'decode'
12
+    
13
+
14
+
15
+        display('loading SPM.mat');
16
+        SubjectID = 'JZ006';
17
+%         SubjectID = 'AI020';
18
+%         SubjectID = 'HG027';
19
+        spm = load(fullfile('D:\Analyze\Choice\24pilot',SubjectID,'results\SPM.mat'));
20
+
21
+        display('done.');
22
+
23
+
24
+
25
+
26
+        map = SubjectRoiMapping;
27
+
28
+        voxelList  = [...
29
+                      getCoordinate(map,SubjectID,'SPL l')+[0,0,0];...
30
+                          getCoordinate(map,SubjectID,'SPL l')+[1,0,0];...
31
+                          getCoordinate(map,SubjectID,'SPL l')+[-1,0,0];...
32
+                          getCoordinate(map,SubjectID,'SPL l')+[0,1,0];...
33
+                          getCoordinate(map,SubjectID,'SPL l')+[0,-1,0];...
34
+                          getCoordinate(map,SubjectID,'SPL l')+[0,0,1];...
35
+                          getCoordinate(map,SubjectID,'SPL l')+[0,0,-1];...
36
+                      getCoordinate(map,SubjectID,'SPL r')+[0,0,0];...
37
+                          getCoordinate(map,SubjectID,'SPL r')+[1,0,0];...
38
+                          getCoordinate(map,SubjectID,'SPL r')+[-1,0,0];...
39
+                          getCoordinate(map,SubjectID,'SPL r')+[0,1,0];...
40
+                          getCoordinate(map,SubjectID,'SPL r')+[0,-1,0];...
41
+                          getCoordinate(map,SubjectID,'SPL r')+[0,0,1];...
42
+                          getCoordinate(map,SubjectID,'SPL r')+[0,0,-1];...
43
+                      getCoordinate(map,SubjectID,'M1 r')+[0,0,0];...
44
+                      getCoordinate(map,SubjectID,'M1 l')+[0,0,0];...
45
+                      ];
46
+        
47
+        
48
+        params = struct;
49
+        params.nClasses = 2;
50
+
51
+        assignin('base','params',params);
52
+        %% calculate
53
+        display('calculating cross-validation performance time-shift');
54
+        calculateParams  = struct;
55
+        
56
+        calculateParams.des             = spm.SPM;
57
+        calculateParams.frameShiftStart = -20;
58
+        calculateParams.frameShiftEnd   = 15;
59
+        calculateParams.decodeDuration  = 1;
60
+        calculateParams.svmargs         = '-t 0 -s 0 -v 6';
61
+        calculateParams.sessionList     = 1:3;
62
+        calculateParams.voxelList       = voxelList;
63
+        calculateParams.classList       = {'<','>'};
64
+        calculateParams.labelMap        = LabelMap({'<','>','<+<','>+>','<+>','>+<'},{-2,-1,1,2,3,4});
65
+        calculateParams.psthStart       = -25;
66
+        calculateParams.psthEnd         = 20;
67
+        calculateParams.baselineStart   = -22;
68
+        calculateParams.baselineEnd     = -20;
69
+        calculateParams.eventList       = [9,11,13; 10,12,14];
70
+        
71
+        assignin('base','calculateParams',calculateParams);
72
+        
73
+%         [decodeTable rawTimeCourse] = calculateDecodePerformance(spm,params.frameShiftStart,params.frameShiftEnd,params.xTimeWindow,params.svmopts,1:4,params.sessionList,params.voxelList,params.classList,params.labelMap,params.normalize);
74
+        decode = calculateDecodePerformance(calculateParams);
75
+        display(sprintf('Min CrossVal Accuracy: %g%% \t Max CrossVal Accuracy: %g%%',decode.minPerformance,decode.maxPerformance));
76
+        
77
+        assignin('base','decode',decode);
78
+
79
+        display('Finished calculations.');
80
+        display('Plotting.');
81
+
82
+        plotParams = struct;
83
+        plotParams.psthStart = calculateParams.psthStart;
84
+        plotParams.psthEnd   = calculateParams.psthEnd;
85
+        plotParams.nClasses  = length(calculateParams.classList);
86
+        plotParams.frameShiftStart   = calculateParams.frameShiftStart;
87
+        plotParams.frameShiftEnd     = calculateParams.frameShiftEnd;
88
+        plotParams.decodePerformance = decode.decodePerformance;
89
+        plotParams.rawTimeCourse     = decode.rawTimeCourse;
90
+        plotParams.SubjectID         = SubjectID;
91
+        
92
+        assignin('base','plotParams',plotParams);
93
+%         plotDecodePerformance(params.psthStart,params.psthEnd,params.nClasses,decode.decodeTable,params.frameShiftStart,params.frameShiftEnd,decode.rawTimeCourse);
94
+        plotDecodePerformance(plotParams);
95
+
96
+        case 'gen'
97
+            center = '[-39 -33 67]';
98
+            sessionList = '1:3';
99
+            conditionList = '1:2';
100
+            radius = 3;
101
+            normalize = 1;
102
+
103
+            cmd=sprintf(...
104
+                '[label data] = generateDataMatrix(generateVoxelList(%s,%d), generateTrialProtocol(%s,%s),%d);',...
105
+                center,radius,sessionList,conditionList,normalize);
106
+
107
+            %     assignin('base','label',label);
108
+            %     assignin('base','data',data);
109
+
110
+    case 'norm'
111
+        cmd = ['for i=1:size(data,2)'...
112
+            'data(:,i)=data(:,i)/std(data(:,i));'...
113
+        'end;'];
114
+        
115
+    case 'xtrain'
116
+        svmargs = '-t 0'; %linear kernel
117
+        svmargs = [svmargs '-v 4'];
118
+        
119
+        cmd=sprintf('model = svmtrain(label,data,''%s'')',svmargs);
120
+        
121
+    case 'train'
122
+        svmargs = '-t 0'; %linear kernel
123
+%         svmargs = [svmargs '-v 4'];
124
+        
125
+        cmd=sprintf('model = svmtrain(label,data,%s)',svmargs);
126
+       
127
+    case 'pred'
128
+        cmd = '[predicted_label, accuracy, decision_values] = svmpredict(label, data, model);';
129
+        
130
+    otherwise
131
+        display('give action command: clear load gen (norm) xtrain train pred');
132
+    end
133
+    
134
+    if exist('cmd','var') 
135
+        evalin('base',cmd);
136
+    end
137
+
138
+end
0 139
\ No newline at end of file