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
Showing6 changed files
... ...
@@ -4,15 +4,14 @@ function m = SubjectRoiMapping(argv)
4 4
 %   normally called without any arguments
5 5
 
6 6
 if nargin == 0
7
-    m.subject{1} ='AI020';
8
-    m.subject{2} ='BD001';
9
-    m.subject{3} ='HG027';
10
-    m.subject{4} ='IK011';
11
-    m.subject{5} ='JZ006'; % Guter Proband
12
-    m.subject{6} ='LB001';
13
-    m.subject{7} ='SW007';
14
-    m.subject{8} ='VW005';
15
-
7
+    m.subject{1}='HIGL5';
8
+    m.subject{2}='AXLI5';
9
+    m.subject{3}='SHWA5';
10
+    m.subject{4}='DAPR5';
11
+    m.subject{5}='5IGKA';
12
+    m.subject{6}='5RAEL';
13
+    m.subject{7}='5JEZI';
14
+    m.subject{8}='5PK002';
16 15
     m.subjectNameMap = java.util.HashMap;
17 16
     for subj = 1:size(m.subject,2)
18 17
         m.subjectNameMap.put(m.subject{subj},subj);
... ...
@@ -20,19 +19,15 @@ if nargin == 0
20 19
     
21 20
     
22 21
     
23
-    m.roi_name{1}  ='SPL l'; % <-Parietalkortex links 
24
-    m.roi_name{2}  ='SPL r'; % <-Parietalkortex rechts 
25
-    m.roi_name{3}  ='PMd l'; 
26
-    m.roi_name{4}  ='PMd r'; 
27
-    m.roi_name{5}  ='IPSa l'; 
28
-    m.roi_name{6}  ='IPSa r'; 
29
-    m.roi_name{7}  ='SMA'; 
30
-    m.roi_name{8}  ='DLPFC'; 
31
-    m.roi_name{9}  ='V1 l'; 
32
-    m.roi_name{10} ='V1 r'; 
33
-    m.roi_name{11} ='M1 l'; % <-Motorischer Cortex l 
34
-    m.roi_name{12} ='M1 r'; % <-Motorischer Cortex r 
35
-    
22
+    m.roi_name{1}='SPL l';
23
+    m.roi_name{2}='SPL r';
24
+    m.roi_name{3}='dPM l';
25
+    m.roi_name{4}='dPM r';
26
+    m.roi_name{5}='DLPFC l';
27
+    m.roi_name{6}='DLPFC r';
28
+    m.roi_name{7}='SMA l';
29
+    m.roi_name{8}='antIPS l';
30
+
36 31
     m.roiNameMap = java.util.HashMap;
37 32
     for roi = 1:size(m.roi_name,2)
38 33
         m.roiNameMap.put(m.roi_name{roi},roi);
... ...
@@ -40,103 +35,77 @@ if nargin == 0
40 35
 
41 36
     
42 37
     % Koordinaten aller Probanden A von den ROIS B: rois{A}(B,[x y z in mm]) 
43
-    m.coordinate{1}(1,:)  = [-18, -78, 53];
44
-    m.coordinate{1}(2,:)  = [12, -69, 46];
45
-    m.coordinate{1}(3,:)  = [-21, -12, 49];
46
-    m.coordinate{1}(4,:)  = [30, -12, 53];
47
-    m.coordinate{1}(5,:)  = [-30, -51, 39];
48
-    m.coordinate{1}(6,:)  = [ 33, -60, 49];
49
-    m.coordinate{1}(7,:)  = [ -9, 6, 46];
50
-    m.coordinate{1}(8,:)  = [-27 27 48];
51
-    m.coordinate{1}(9,:)  = [-6, -90, -7];
52
-    m.coordinate{1}(10,:) = [12, -90, -4];
53
-    m.coordinate{1}(11,:) = [-57, -24, 49];
54
-    m.coordinate{1}(12,:) = [42, -24, 60];
55
-    m.coordinate{2}(1,:)  = [-9, -72, 56]; 
56
-    m.coordinate{2}(2,:)  = [15, -72, 60]; 
57
-    m.coordinate{2}(3,:)  = [-30, -9, 53]; 
58
-    m.coordinate{2}(4,:)  = [ 30, -9, 49]; 
59
-    m.coordinate{2}(5,:)  = [-42 -36 39]; 
60
-    m.coordinate{2}(6,:)  = [30 -36 42]; 
61
-    m.coordinate{2}(7,:)  = [ -3, 6, 53];
62
-    m.coordinate{2}(8,:)  = [-27 30 28];
63
-    m.coordinate{2}(9,:)  = [-6, -81, -7]; 
64
-    m.coordinate{2}(10,:) = [9, -78, -7];
65
-    m.coordinate{2}(11,:) = [-51, -24, 60];
66
-    m.coordinate{2}(12,:) = [48, -21, 63]; 
67
-    m.coordinate{3}(1,:)  = [-15, -72, 60];
68
-    m.coordinate{3}(2,:)  = [15, -66, 63];
69
-    m.coordinate{3}(3,:)  = [-27, -12, 56];
70
-    m.coordinate{3}(4,:)  = [24 -15 53];
71
-    m.coordinate{3}(5,:)  = [-36 -36 42];
72
-    m.coordinate{3}(6,:)  = [30 -39 35];
73
-    m.coordinate{3}(7,:)  = [-9, 3, 53]; 
74
-    m.coordinate{3}(8,:)  = [-30 30 28];
75
-    m.coordinate{3}(9,:)  = [-3, -90, 4];
76
-    m.coordinate{3}(10,:) = [15, -99, 14];
77
-    m.coordinate{3}(11,:) = [-27, -27, 74];
78
-    m.coordinate{3}(12,:) = [36, -27, 70]; 
79
-    m.coordinate{4}(1,:)  = [-21, -69, 63]; 
80
-    m.coordinate{4}(2,:)  = [21, -69, 63];
81
-    m.coordinate{4}(3,:)  = [-33 -12 53];
82
-    m.coordinate{4}(4,:)  = [12 -9 60];
83
-    m.coordinate{4}(5,:)  = [-33 -35 46];
84
-    m.coordinate{4}(6,:)  = [42 -36 39];
85
-    m.coordinate{4}(7,:)  = [-3 0 49];
86
-    m.coordinate{4}(8,:)  = [-33 33 28];
87
-    m.coordinate{4}(9,:)  = [-3, -90, -7];
88
-    m.coordinate{4}(10,:) = [9, -81, -7];
89
-    m.coordinate{4}(11,:) = [-39, -27, 53];
90
-    m.coordinate{4}(12,:) = [51, -24, 60];
91
-    m.coordinate{5}(1,:)  = [-12 -66 63];
92
-    m.coordinate{5}(2,:)  = [12, -75, 60];
93
-    m.coordinate{5}(3,:)  = [-24, -12, 53];
94
-    m.coordinate{5}(4,:)  = [27, -9, 60]; 
95
-    m.coordinate{5}(5,:)  = [-42 -42 35]; 
96
-    m.coordinate{5}(6,:)  = [33 -48 35];
97
-    m.coordinate{5}(7,:)  = [ -3, 0, 49];
98
-    m.coordinate{5}(8,:)  = [-36 33 28];
99
-    m.coordinate{5}(9,:)  = [-15, -93, -4];
100
-    m.coordinate{5}(10,:) = [15, -90, 4]; 
101
-    m.coordinate{5}(11,:) = [-39, -33, 67];
102
-    m.coordinate{5}(12,:) = [27, -18, 74];
103
-    m.coordinate{6}(1,:)  = [-21, -69, 60];
104
-    m.coordinate{6}(2,:)  = [9, -72, 63];
105
-    m.coordinate{6}(3,:)  = [-24 -12 53];
106
-    m.coordinate{6}(4,:)  = [32 -12 56]; 
107
-    m.coordinate{6}(5,:)  = [-36 -39 35];
108
-    m.coordinate{6}(6,:)  = [42 -33 46]; 
109
-    m.coordinate{6}(7,:)  = [-6 3 49]; 
110
-    m.coordinate{6}(8,:)  = [-36 33 28];
111
-    m.coordinate{6}(9,:)  = [-12, -99, 0];
112
-    m.coordinate{6}(10,:) = [9, -96, -7];
113
-    m.coordinate{6}(11,:) = [-48, -27, 60];
114
-    m.coordinate{6}(12,:) = [33, -33, 60];
115
-    m.coordinate{7}(1,:)  = [-21, -60, 56]; 
116
-    m.coordinate{7}(2,:)  = [12, -69, 60]; 
117
-    m.coordinate{7}(3,:)  = [-24, -12, 49];
118
-    m.coordinate{7}(4,:)  = [24, -6, 49]; 
119
-    m.coordinate{7}(5,:)  = [-33 -45 46]; 
120
-    m.coordinate{7}(6,:)  = [30, -51, 49];
121
-    m.coordinate{7}(7,:)  = [0, 9, 42]; 
122
-    m.coordinate{7}(8,:)  = [-30 36 35]; 
123
-    m.coordinate{7}(9,:)  = [-3, -84, -4];
124
-    m.coordinate{7}(10,:) = [18, -87, -7];
125
-    m.coordinate{7}(11,:) = [-36, -30, 63]; 
126
-    m.coordinate{7}(12,:) = [42, -27, 60];
127
-    m.coordinate{8}(1,:)  = [-27, -63, 53];
128
-    m.coordinate{8}(2,:)  = [18, -66, 56];
129
-    m.coordinate{8}(3,:)  = [-21, -6, 56];
130
-    m.coordinate{8}(4,:)  = [27 -6 53]; 
131
-    m.coordinate{8}(5,:)  = [-36, -51, 49];
132
-    m.coordinate{8}(6,:)  = [45, -39, 53];
133
-    m.coordinate{8}(7,:)  = [-9, 9, 53];
134
-    m.coordinate{8}(8,:)  = [-36 24 25]; 
135
-    m.coordinate{8}(9,:)  = [0, -90, 4]; 
136
-    m.coordinate{8}(10,:) = [0, -90, 4];
137
-    m.coordinate{8}(11,:) = [-42, -27, 67]; 
138
-    m.coordinate{8}(12,:) = [51, -27, 63]; 
38
+    m.coordinate{1}(1,:)=[-15 -66 60];
39
+    m.coordinate{1}(2,:)=[18 -63 63];
40
+    m.coordinate{1}(3,:)=[-24 -6 57];
41
+    m.coordinate{1}(4,:)=[27 -9 54];
42
+    m.coordinate{1}(5,:)=[-42 30 39];
43
+    m.coordinate{1}(6,:)=[36 45 21];
44
+    m.coordinate{1}(7,:)=[-3 6 60];
45
+    m.coordinate{1}(8,:)=[-33 -39 42];
46
+
47
+    m.coordinate{2}(1,:)=[-15 -66 66];
48
+    m.coordinate{2}(2,:)=[15 -69 63];
49
+    m.coordinate{2}(3,:)=[-30 -9 63];
50
+    m.coordinate{2}(4,:)=[33 -6 60];
51
+    m.coordinate{2}(5,:)=[-30 39 42];
52
+    m.coordinate{2}(6,:)=[36 36 42];
53
+    m.coordinate{2}(7,:)=[-3 0 63];
54
+    m.coordinate{2}(8,:)=[-39 -42 60];
55
+
56
+    m.coordinate{3}(1,:)=[-18 -63 57];
57
+    m.coordinate{3}(2,:)=[15 -69 60];
58
+    m.coordinate{3}(3,:)=[-24 -12 51];
59
+    m.coordinate{3}(4,:)=[27 -12 51];
60
+    m.coordinate{3}(5,:)=[-27 36 42];
61
+    m.coordinate{3}(6,:)=[30 42 42];
62
+    m.coordinate{3}(7,:)=[-3 -6 63];
63
+    m.coordinate{3}(8,:)=[-36 -51 60];
64
+
65
+    m.coordinate{4}(1,:)=[-30 -54 63];
66
+    m.coordinate{4}(2,:)=[18 -60 54];
67
+    m.coordinate{4}(3,:)=[-33 -6 57];
68
+    m.coordinate{4}(4,:)=[27 -6 57];
69
+    m.coordinate{4}(5,:)=[-27 33 27];
70
+    m.coordinate{4}(6,:)=[nan nan nan];
71
+    m.coordinate{4}(7,:)=[-6 3 60];
72
+    m.coordinate{4}(8,:)=[-33 -51 54];
73
+
74
+    m.coordinate{5}(1,:)=[-21 -63 66];
75
+    m.coordinate{5}(2,:)=[24 -54 66];
76
+    m.coordinate{5}(3,:)=[-30 -6 51];
77
+    m.coordinate{5}(4,:)=[21 0 57];
78
+    m.coordinate{5}(5,:)=[-33 36 27];
79
+    m.coordinate{5}(6,:)=[33 45 30];
80
+    m.coordinate{5}(7,:)=[-6 -3 54];
81
+    m.coordinate{5}(8,:)=[-39 -42 54];
82
+
83
+    m.coordinate{6}(1,:)=[-15 -69 54];
84
+    m.coordinate{6}(2,:)=[21 -63 57];
85
+    m.coordinate{6}(3,:)=[-24 -9 66];
86
+    m.coordinate{6}(4,:)=[33 -6 66];
87
+    m.coordinate{6}(5,:)=[-33 30 39];
88
+    m.coordinate{6}(6,:)=[33 45 30];
89
+    m.coordinate{6}(7,:)=[-3 0 54];
90
+    m.coordinate{6}(8,:)=[-39 -42 39];
91
+
92
+    m.coordinate{7}(1,:)=[-12 -66 63];
93
+    m.coordinate{7}(2,:)=[15 -66 63];
94
+    m.coordinate{7}(3,:)=[-21 -9 54];
95
+    m.coordinate{7}(4,:)=[30 -9 57];
96
+    m.coordinate{7}(5,:)=[-39 33 33];
97
+    m.coordinate{7}(6,:)=[39 30 33];
98
+    m.coordinate{7}(7,:)=[-6 0 54];
99
+    m.coordinate{7}(8,:)=[-39 -45 54];
139 100
 
101
+    m.coordinate{8}(1,:)=[-15 -72 51];
102
+    m.coordinate{8}(2,:)=[15 -75 51];
103
+    m.coordinate{8}(3,:)=[-27 -12 66];
104
+    m.coordinate{8}(4,:)=[33 -18 69];
105
+    m.coordinate{8}(5,:)=[-48 21 33];
106
+    m.coordinate{8}(6,:)=[42 33 36];
107
+    m.coordinate{8}(7,:)=[-3 -6 57];
108
+    m.coordinate{8}(8,:)=[-39 -48 45];
140 109
     m = class(m,'SubjectRoiMapping');
141 110
     
142 111
 elseif isa(argv,'SubjectRoiMapping') % copy
... ...
@@ -47,7 +47,7 @@ maxPerformance = -inf;
47 47
                 rawdata=cell2mat({extr.mean}); % Raw Data
48 48
                 pst{voxel}  = calculatePST(des,globalStart,baselineStart,baselineEnd,globalEnd,eventList,rawdata,sessionList);
49 49
         end
50
-
50
+        
51 51
         decodePerformance = [];
52 52
 
53 53
         for timeShift   = timeLineStart:1:timeLineEnd
... ...
@@ -58,7 +58,7 @@ maxPerformance = -inf;
58 58
             anyvoxel = 1;
59 59
             for pstConditionGroup = 1:size(pst{1,anyvoxel},2) 
60 60
                 for dp = 1:size(pst{1,anyvoxel}{1,pstConditionGroup},1) % data point
61
-                  row = getSVMLabel(labelMap,eventList(pstConditionGroup,1)) 
61
+                  row = getSVMLabel(labelMap,eventList(pstConditionGroup,1));
62 62
                     for voxel = 1:size(pst,2)
63 63
                         row = [row, pst{1,voxel}{1,pstConditionGroup}(dp,frameStart:frameEnd)]; % label,value,value
64 64
                     end
... ...
@@ -69,6 +69,10 @@ maxPerformance = -inf;
69 69
             svmdata      = tmp(:,2:size(tmp,2));
70 70
             svmlabel     = tmp(:,1);
71 71
             
72
+%             rndindex  = randperm(length(svmlabel));
73
+%             svmdata   = svmdata(rndindex,:);
74
+%             svmlabel  = svmlabel(rndindex);
75
+            
72 76
             if SINGLE
73 77
                 performance  = svmtrain(svmlabel, svmdata, svmargs);
74 78
 
... ...
@@ -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');
... ...
@@ -1,8 +1,8 @@
1 1
 function plotDecodePerformance(varargin)
2 2
 % plotDecodePerformance(timeline,decodePerformance,nClasses,rawData)
3 3
 
4
-PSTH_AXIS_MIN = -2;
5
-PSTH_AXIS_MAX = 5;
4
+PSTH_AXIS_MIN = -1;
5
+PSTH_AXIS_MAX = 1;
6 6
 
7 7
 switch nargin
8 8
     
... ...
@@ -30,7 +30,7 @@ end
30 30
           for label = 1:size(psth{voxel},2)
31 31
               psthData = [];
32 32
               for timepoint = 1:size(psth{voxel}{label},2)
33
-                  psthData = nanmean(psth{voxel}{label})+voxel/100;
33
+                  psthData = nanmean(psth{voxel}{label}); % +voxel/100; % ???????????
34 34
               end
35 35
               plot(psthStart:psthEnd,psthData,[colorChooser(voxel), lineStyleChooser(label)]);
36 36
           end
... ...
@@ -121,4 +121,23 @@ function pst = calculatePST(des,globalStart,baselineStart,baselineEnd,globalEnd,
121 121
             end;
122 122
         end;
123 123
     end;
124
+    
125
+    %%%%%%%%%%% new 090109 Axel: "Normalization" for SVM
126
+    
127
+%     for zr=1:evntrow
128
+% %        tmp_max(zr)=max(nanmean(pst{zr}));
129
+%           tmp_max(zr)=max(max(pst{zr}));
130
+%           tmp_min(zr)=min(min(pst{zr}));
131
+%     end;
132
+% %    pstmax=max(tmp_max);
133
+% %    pstmin=min(tmp_min);
134
+%     pstmax=max(abs([tmp_max tmp_min]));
135
+%     for zr=1:evntrow
136
+%         pst{zr}=pst{zr}./pstmax-.5;
137
+% %        pst{zr}=(pst{zr}-pstmin)./(pstmax-pstmin);
138
+%     end;
139
+    
140
+    
141
+    
142
+    
124 143
 end
125 144
\ No newline at end of file
... ...
@@ -64,12 +64,12 @@ function spm_SVMCrossVal
64 64
     lFramsSize  = createLabel(pPSTH, [firstColumn  fifthRow  0.33*frameWidth controlElementHeight],'SVM Frame Size');
65 65
     
66 66
     
67
-    model.txtPSTHStart       = createTextField(pPSTH,[secondColumn secondRow 0.25*frameWidth controlElementHeight],'-1.0');
68
-    model.txtPSTHEnd         = createTextField(pPSTH,[thirdColumn  secondRow 0.25*frameWidth controlElementHeight],' 35.0');
67
+    model.txtPSTHStart       = createTextField(pPSTH,[secondColumn secondRow 0.25*frameWidth controlElementHeight],'-10.0');
68
+    model.txtPSTHEnd         = createTextField(pPSTH,[thirdColumn  secondRow 0.25*frameWidth controlElementHeight],' 40.0');
69 69
     model.txtBaselineStart   = createTextField(pPSTH,[secondColumn thirdRow  0.25*frameWidth controlElementHeight],'-3.0');
70 70
     model.txtBaselineEnd     = createTextField(pPSTH,[thirdColumn  thirdRow  0.25*frameWidth controlElementHeight],'-1.0');
71 71
     model.txtFrameShiftStart = createTextField(pPSTH,[secondColumn fourthRow 0.25*frameWidth controlElementHeight],'-5.0');
72
-    model.txtFrameShiftEnd   = createTextField(pPSTH,[thirdColumn  fourthRow 0.25*frameWidth controlElementHeight],' 45.0');
72
+    model.txtFrameShiftEnd   = createTextField(pPSTH,[thirdColumn  fourthRow 0.25*frameWidth controlElementHeight],' 35.0');
73 73
     model.txtFrameShiftDur   = createTextField(pPSTH,[secondColumn fifthRow  0.25*frameWidth controlElementHeight],' 0');
74 74
 
75 75
                 
... ...
@@ -81,7 +81,7 @@ function spm_SVMCrossVal
81 81
     secondRow   = (nClassRows-4.5)*controlElementHeight;
82 82
 
83 83
     lClassDef = createLabel(pCLASS, [firstColumn firstRow  0.66*frameWidth controlElementHeight],'<Label>,<[Event,Event,..]>,<SVM-Value>;');
84
-    model.txtClassDef = createTextField(pCLASS,[firstColumn secondRow 0.98*frameWidth 4*controlElementHeight],sprintf('<,\t[ 9,11,13],\t-2 ;\n>,\t[10,12,14],\t-1;'));
84
+    model.txtClassDef = createTextField(pCLASS,[firstColumn secondRow 0.98*frameWidth 4*controlElementHeight],sprintf('DRT,\t[9,10],\t-2 ;\nM2ST,\t[11,12],\t-1;'));
85 85
     set(model.txtClassDef,'HorizontalAlignment','left');
86 86
     set(model.txtClassDef,'Max',20);
87 87
     set(model.txtClassDef,'Min',0);
... ...
@@ -96,7 +96,7 @@ function spm_SVMCrossVal
96 96
 
97 97
     lVoxelDef = createLabel(pVOXEL, [firstColumn firstRow  0.66*frameWidth controlElementHeight],'<ROI Name>,<ROI Modifier>;');
98 98
     model.txtVoxelDef = createTextField(pVOXEL,[firstColumn secondRow 0.98*frameWidth 6*controlElementHeight],...
99
-        sprintf('M1 l,\t[ 0, 0, 0];\nM1 l,\t[ 1, 0, 0];\nM1 l,\t[ 0, 1, 0];\nM1 l,\t[ 0, 0, 1];\n'));
99
+        sprintf('SPL l,\t[ 0, 0, 0];\nSPL r,\t[ 0, 0, 0];\n'));
100 100
     set(model.txtVoxelDef,'HorizontalAlignment','left');
101 101
     set(model.txtVoxelDef,'Max',20);
102 102
     set(model.txtVoxelDef,'Min',0);
... ...
@@ -106,7 +106,8 @@ function spm_SVMCrossVal
106 106
     firstColumn  =  5.00;
107 107
     firstRow     =  1.00 * controlElementHeight;
108 108
 
109
-    model.txtSVMopts = createTextField(pSVM,[firstColumn firstRow  0.66*frameWidth controlElementHeight],'-t 0 -s 0 -v 6');
109
+    model.txtSVMopts = createTextField(pSVM,[firstColumn firstRow  0.66*frameWidth controlElementHeight],'-s 0 -t 0 -v 6 -c 1');
110
+    %model.txtSVMopts = createTextField(pSVM,[firstColumn firstRow  0.66*frameWidth controlElementHeight],'-s 0 -t 2 -v 6 -c 10 -g .1');
110 111
     set(model.txtSVMopts,'Enable','on'); %inactive
111 112
     set(model.txtSVMopts,'HorizontalAlignment','left');
112 113