New Option for COL Bias removal in calculatePST
Axel Lindner

Axel Lindner commited on 2009-01-10 08:50:16
Zeige 3 geänderte Dateien mit 154 Einfügungen und 90 Löschungen.


git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@105 83ab2cfd-5345-466c-8aeb-2b2739fb922d
... ...
@@ -4,14 +4,15 @@ function m = SubjectRoiMapping(argv)
4 4
 %   normally called without any arguments
5 5
 
6 6
 if nargin == 0
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';
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
+
15 16
     m.subjectNameMap = java.util.HashMap;
16 17
     for subj = 1:size(m.subject,2)
17 18
         m.subjectNameMap.put(m.subject{subj},subj);
... ...
@@ -19,14 +20,18 @@ if nargin == 0
19 20
     
20 21
     
21 22
     
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';
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 
30 35
     
31 36
     m.roiNameMap = java.util.HashMap;
32 37
     for roi = 1:size(m.roi_name,2)
... ...
@@ -35,77 +40,103 @@ if nargin == 0
35 40
 
36 41
     
37 42
     % Koordinaten aller Probanden A von den ROIS B: rois{A}(B,[x y z in mm]) 
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];
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]; 
100 139
 
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];
109 140
     m = class(m,'SubjectRoiMapping');
110 141
     
111 142
 elseif isa(argv,'SubjectRoiMapping') % copy
... ...
@@ -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');
... ...
@@ -93,12 +93,13 @@ function pst = calculatePST(des,globalStart,baselineStart,baselineEnd,globalEnd,
93 93
 
94 94
                         n{zr}=n{zr}+1;
95 95
                         pst{zr}(n{zr},:)=interp1(stime,sdata(:,sessionID),[des.Sess(sessionID).U(eventList(zr,ze)).ons(zz)+pre:res:des.Sess(sessionID).U(eventList(zr,ze)).ons(zz)+post],'linear');
96
+                        pstevnt{zr}(n{zr})=eventList(zr,ze); % NEW 090110 Specify #Event/Condition for each PST
96 97
                         if strcmp(normz,'epoc')
97 98
                             bline=nanmean(pst{zr}(n{zr},round(-pre/res+(bstart)/res+1):round(-pre/res+(bend)/res+1)));
98 99
                             if isnan(bline)
99 100
                                 pst{zr}(n{zr},1:-pre/res+post/res+1)=nan;
100 101
                             else
101
-%                                     nn{zr}=nn{zr}+1;
102
+                                nn{zr}=nn{zr}+1;
102 103
                                 pst{zr}(n{zr},:)=(pst{zr}(n{zr},:)-bline)/bline*100; % 'epoch-based' normalization
103 104
                             end;
104 105
                         end;
... ...
@@ -122,9 +123,41 @@ function pst = calculatePST(des,globalStart,baselineStart,baselineEnd,globalEnd,
122 123
         end;
123 124
     end;
124 125
     
126
+    %%%%COL BIAS REMOVAL, added 090110 %%%%%
127
+    col_bias_removal=0;
128
+    if col_bias_removal
129
+
130
+        for zr=1:evntrow % Event ROW
131
+            pst4row(zr,:)=nanmean(pst{zr}); % Average PST for overall ROW
132
+            n_col=0;
133
+            for ze=1:evntcol % Even COL
134
+                if ze==1 || (ze>1 && eventList(zr,ze)~=eventList(zr,ze-1))
135
+                    n_col=n_col+1;
136
+                    tmp_index=[];
137
+                    tmp_index=find(pstevnt{zr}(:)==eventList(zr,ze));
138
+                    % Calculate Average PST for each COL within ROW
139
+                    pst4col(n_col,:)=nanmean(pst{zr}(tmp_index,:));
140
+                    % COL BIAS: Calculate Difference between COL Ave and Overall Row Ave
141
+                    pst_delta(n_col,:)=pst4col(n_col,:)-pst4row(zr,:);
142
+                    % Remove COL BIAS from single PSTs
143
+                    for z=1:length(tmp_index)
144
+                        pst{zr}(tmp_index(z),:)=pst{zr}(tmp_index(z),:)-pst_delta(n_col,:);
145
+                    end;
146
+                end;
147
+            end;
148
+        end;
149
+    end;
150
+    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    
151
+                
152
+            
153
+            
154
+    
155
+    
156
+    
157
+    
125 158
     %%%%%%%%%%% new 090109 Axel: "Normalization" for SVM
126 159
 
127
-    norm4SVM='none'; %Normalization method for SVM
160
+    norm4SVM='mean'; %Normalization method for SVM
128 161
     disp(['normalization: ' norm4SVM]);   
129 162
     % none - no normalization
130 163
     % mean - mean normalization (meanPSTH max at .5, baseline at -.5]
131 164