multiple searchlight radii
Christoph Budziszewski

Christoph Budziszewski commited on 2009-04-26 22:01:30
Zeige 3 geänderte Dateien mit 20 Einfügungen und 10 Löschungen.


git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@186 83ab2cfd-5345-466c-8aeb-2b2739fb922d
... ...
@@ -0,0 +1,4 @@
1
+function a = getArray(fieldhandle)
2
+str = get(fieldhandle,'String');
3
+a = eval([ '[' str ']' ]);
4
+end
0 5
\ No newline at end of file
... ...
@@ -1,3 +1,3 @@
1 1
 function r = getSearchlightRadius(model)
2
-r = getDouble(model.txtSearchlightRadius);
2
+r = getArray(model.txtSearchlightRadius);
3 3
 end
4 4
\ No newline at end of file
... ...
@@ -13,7 +13,7 @@ pstopts = args.psthOpts;
13 13
 pstopts.eventList = args.eventList;
14 14
 pstopts.sessionList = sessionlist;
15 15
 
16
-radius = fbsargs.radius;
16
+radiusList = fbsargs.radius;
17 17
 
18 18
 timeline = header.timeline;
19 19
 timeline.frameShiftStart = header.frameShift.frameShiftStart;
... ...
@@ -60,7 +60,7 @@ for s = 1:nSubjects
60 60
     indexToCoordMap = java.util.HashMap;
61 61
     coordToIndexMap = java.util.HashMap;
62 62
     for iVoxel = 1:nVoxel
63
-        coord = [x(iVoxel) y(iVoxel) z(iVoxel)]
63
+        coord = [x(iVoxel) y(iVoxel) z(iVoxel)];
64 64
         a = java.util.Vector(3,0);
65 65
         a.add(0,coord(1));
66 66
         a.add(1,coord(2));
... ...
@@ -104,7 +104,7 @@ for s = 1:nSubjects
104 104
     pause(0.001) % flush system event queue (respond to ctrl-c)
105 105
     tic
106 106
     
107
-    display(sprintf('rastering %g coordinates with approx. %g mm radius',nVoxel,radius));
107
+    display(sprintf('rastering %g coordinates',nVoxel));
108 108
     % for each timeslice
109 109
     globalStart     = timeline.psthStart;
110 110
     globalEnd       = timeline.psthEnd;
... ...
@@ -134,6 +132,7 @@ if isempty( fbsargs.timeline )
134 132
 	fbsTimeLine = 1:nSamplePoints;
135 133
     fbsTimeLine = fbsTimeLine +globalStart;
136 134
 else 
135
+    %preferred!
137 136
 	fbsTimeLine = fbsargs.timeline;
138 137
 end
139 138
 
... ...
@@ -144,16 +142,18 @@ end
144 142
     frameStartIdx  = floor(-globalStart+1+timeShiftIdx - 0.5*decodeDuration);
145 143
     frameEndIdx    = min(ceil(frameStartIdx+decodeDuration + 0.5*decodeDuration),-globalStart+globalEnd);
146 144
 
147
-        img3D = zeros(size(mask_image)); %output image prepare
145
+        for r = radiusList
146
+            img3D{r} = zeros(size(mask_image)); %output image prepare
147
+        end
148 148
         
149 149
         for iVoxel = 1:nVoxel % linear structure avoids 3D-Loop.
150 150
             if (mod(iVoxel,100)== 0)
151 151
                 display(sprintf('Status: %03u / %03u Timepoints, %05u / %05u Coordinates',find(fbsTimeLine == timeShiftIdx),length(fbsTimeLine),iVoxel,nVoxel));
152 152
                 pause(0.001) %flush system event queue
153 153
             end
154
+            for radius = radiusList
154 155
                 % get surrounding coordinate-IDs within radius
155 156
                 sphere = fbs_buildSphere(mapping,iVoxel,radius,vdim);
156
-%             pause
157 157
                 
158 158
                 %build svm inputmatrix
159 159
                 svmdata = [];
... ...
@@ -180,18 +180,21 @@ end
180 180
                 decode = svm_single_crossval(svmlabel,svmdata,svmopts);
181 181
                 % save the decode value to the corresponding coordinate
182 182
                 
183
-            coord = mapping.indexToCoordMap.get(iVoxel)
183
+                coord = mapping.indexToCoordMap.get(iVoxel);
184 184
                 x = coord(1);
185 185
                 y = coord(2);
186 186
                 z = coord(3);
187 187
                 
188
-            img3D(x,y,z) = ((decode/100)-0.5)*2; % range [-1:1]
188
+                img3D{radius}(x,y,z) = ((decode/100)-0.5)*2; % range [-1:1]
189 189
                 
190
+            end %for each radius
190 191
         end %for each voxel
191 192
 
192
-        nii = make_nii(img3D,vdim,mask_image.hdr.hist.originator(1:3),16,...
193
+        for radius = radiusList
194
+            nii = make_nii(img3D{radius},vdim,mask_image.hdr.hist.originator(1:3),16,...
193 195
                 sprintf('decode performance, time relative to onset: %g to %g sec',frameStartIdx,frameEndIdx));
194
-        save_nii(nii,fullfile(savePath,sprintf('%s-%03g',subjects{s}.name,timeShiftIdx)));
196
+            save_nii(nii,fullfile(savePath,sprintf('%s-r%g-t%+03g',subjects{s}.name,radius,timeShiftIdx)));
197
+        end
195 198
     end %for each timeslice
196 199
     display('rastering done');
197 200
     display(sprintf('result images saved to %s',savePath));
198 201