Browse code

error tracking: added psth-plot, debug option. foud possible searchlight error.

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

Christoph Budziszewski authored on 28/04/2009 14:49:31
Showing 3 changed files
... ...
@@ -80,10 +80,10 @@ switch task
80 80
 
81 81
         out.subjectdata  = fbs_load_mask(model.baseDir,subjects);
82 82
         
83
-        if(size(subjects,2)>1)
84
-            display(sprintf('No BATCH Support for Searchlight!'));
85
-            return
86
-        end
83
+%         if(size(subjects,2)>1)
84
+%             display(sprintf('No BATCH Support for Searchlight!'));
85
+%             return
86
+%         end
87 87
         
88 88
         fbsargs = struct;
89 89
         fbsargs.timeline        = timeLine;
... ...
@@ -1,6 +1,8 @@
1 1
 function output =  runFBSImageMaskMode(header,subjectdata,fbsargs)
2 2
 addpath('NIFTI_20090325');
3 3
 
4
+DEBUG = 1;
5
+
4 6
 savePath = fullfile('output',datestr(now,30));
5 7
 mkdir(savePath);
6 8
 
... ...
@@ -96,6 +98,17 @@ for s = 1:nSubjects
96 98
 %              sprintf(' %g%%\t complete',p);
97 99
 %          end
98 100
     end
101
+    if DEBUG == 1
102
+        figure;
103
+        hold on;
104
+        for i = 1:size(pst,2)
105
+            plot(mean(pst{:,i}{1}),'r-');
106
+            plot(mean(pst{:,i}{2}),'b-');
107
+        end
108
+        hold off;
109
+    end
110
+    
111
+    
99 112
     elapsed{s}.psth = toc;
100 113
     disp('psth done');
101 114
     warning(warn);
... ...
@@ -118,6 +131,8 @@ for s = 1:nSubjects
118 131
     % vdim = tmp(7:9); % Voxel-Size
119 132
     
120 133
     mask_image = load_nii(subjects{s}.roiFile.fname);
134
+    tmp = strfind(mask_image.fileprefix,filesep);
135
+    maskname = mask_image.fileprefix(tmp(end)+1:end);
121 136
     
122 137
     vdim = mask_image.hdr.dime.pixdim(2:4);
123 138
     if mask_image.hdr.dime.pixdim(1) == 1
... ...
@@ -143,7 +158,7 @@ for timeShiftIdx = fbsTimeLine
143 158
     frameEndIdx    = min(ceil(frameStartIdx+decodeDuration + 0.5*decodeDuration),-globalStart+globalEnd);
144 159
 
145 160
         for rIdx = 1:length(radiusList)
146
-            img3D{rIdx} = zeros(size(mask_image)); %output image prepare
161
+            img3D{rIdx}(:,:,:) = zeros(size(mask_image)); %output image prepare
147 162
         end
148 163
         
149 164
         for iVoxel = 1:nVoxel % linear structure avoids 3D-Loop.
... ...
@@ -155,6 +170,10 @@ for timeShiftIdx = fbsTimeLine
155 170
                 radius = radiusList(rIdx);
156 171
                 % get surrounding coordinate-IDs within radius
157 172
                 sphere = fbs_buildSphere(mapping,iVoxel,radius,vdim);
173
+%                 for i = 1: length(sphere)
174
+%                      sphere(i )
175
+%                      mapping.indexToCoordMap.get(sphere(i))
176
+%                 end
158 177
                 
159 178
                 %build svm inputmatrix
160 179
                 svmdata = [];
... ...
@@ -164,7 +183,7 @@ for timeShiftIdx = fbsTimeLine
164 183
                     for dp = 1:size(pst{1,anyvoxel}{1,pstConditionGroup},1) % data point
165 184
                         svmlabel = [svmlabel; lm_getSVMLabel(labelMap,eventList(pstConditionGroup,1))];
166 185
                         row = [];
167
-                        for voxel = 1:size(sphere,2)
186
+                        for voxel = sphere
168 187
                             row = [row, pst{1,voxel}{1,pstConditionGroup}(dp,frameStartIdx:frameEndIdx)]; % label,[value,value,...],[value,value,...]...
169 188
                         end
170 189
                         svmdata  = [svmdata; row];
... ...
@@ -177,7 +196,7 @@ for timeShiftIdx = fbsTimeLine
177 196
                     svmdata   = svmdata(rndindex,:);
178 197
                     svmlabel  = svmlabel(rndindex);
179 198
                 end
180
-                
199
+                decode = 0;
181 200
                 decode = svm_single_crossval(svmlabel,svmdata,svmopts);
182 201
                 % save the decode value to the corresponding coordinate
183 202
                 
... ...
@@ -193,9 +212,9 @@ for timeShiftIdx = fbsTimeLine
193 212
 
194 213
         for rIdx = 1:length(radiusList)
195 214
             radius = radiusList(rIdx);
196
-            nii = make_nii(img3D{radius},vdim,mask_image.hdr.hist.originator(1:3),16,...
215
+            nii = make_nii(img3D{rIdx},vdim,mask_image.hdr.hist.originator(1:3),16,...
197 216
                 sprintf('decode performance, time relative to onset: %g to %g sec',frameStartIdx,frameEndIdx));
198
-            save_nii(nii,fullfile(savePath,sprintf('%s-r%g-t%+03g',subjects{s}.name,radius,timeShiftIdx)));
217
+            save_nii(nii,fullfile(savePath,sprintf('%s-%s-r%g-t%+03g',subjects{s}.name,maskname,radius,timeShiftIdx)));
199 218
         end
200 219
     end %for each timeslice
201 220
     display('rastering done');
... ...
@@ -1,6 +1,6 @@
1 1
 function ui_main(varargin)
2 2
 
3
-DEFAULT.selectedSubject = [1];
3
+DEFAULT.selectedSubject = [2];
4 4
 
5 5
 DEFAULT.pststart        = -5;
6 6
 DEFAULT.pstend          = 15;
... ...
@@ -19,8 +19,8 @@ DEFAULT.searchlightradius = 3;
19 19
 DEFAULT.searchlightTimeline = '';
20 20
 
21 21
 
22
-%DEFAULT.wd  = fullfile('d:','Analyze','Choice','24pilot');
23
-DEFAULT.wd  = fullfile('/','media','fMRI');
22
+DEFAULT.wd  = fullfile('d:','Analyze','Choice','24pilot');
23
+% DEFAULT.wd  = fullfile('/','media','fMRI');
24 24
 
25 25
 %  Initialize and hide the GUI as it is being constructed.
26 26
     frameWidth=450;
... ...
@@ -270,7 +270,7 @@ function model = createFirstStepPanel(model,parent,DEFAULT)
270 270
         set(btnRunButton1,'Callback',{@cbRunPreprocessing,model,'COORD'}); % set here, because of model.    
271 271
         set(btnRunButton1,'Enable','on');
272 272
         
273
-        btnRunButton2 = uicontrol(pButtons,'String',sprintf('use this settings for FBS'),...
273
+        btnRunButton2 = uicontrol(pButtons,'String',sprintf('load ROI for FBS'),...
274 274
             'Units','normalized','Position',[0.33 0 0.33 1]);
275 275
         set(btnRunButton2,'Callback',{@cbRunPreprocessing,model,'FBS'}); % set here, because of model.  
276 276
         set(btnRunButton2,'Enable','on');