Browse code

stable version for conference.

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

Christoph Budziszewski authored on19/03/2009 15:14:44
Showing1 changed files
... ...
@@ -1,4 +1,4 @@
1
-function extr = calculateRoiImageData(filenameList,roiImageList)
1
+function [extr xx yy zz] = calculateRoiImageData(filenameList,roiImageList)
2 2
 
3 3
 V = filenameList;
4 4
 nImage = numel(V);
... ...
@@ -22,7 +22,13 @@ for kImage=1:nImage
22 22
             end
23 23
         end
24 24
         dat = [dat spm_sample_vol(V(kImage), x, y, z,0)];
25
-        
25
+
26
+        if kImage == 1 % sample coordinates from first image
27
+            xx = x;
28
+            yy = y;
29
+            zz = z;
30
+        end
31
+
26 32
     end
27 33
     extr(kImage).dat = dat;
28 34
 end
Browse code

roi image working

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

Christoph Budziszewski authored on25/02/2009 13:40:40
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,30 @@
1
+function extr = calculateRoiImageData(filenameList,roiImageList)
2
+
3
+V = filenameList;
4
+nImage = numel(V);
5
+Vm = roiImageList;
6
+nRoi = numel(Vm);
7
+
8
+for kImage=1:nImage
9
+    x = []; y = []; z = [];
10
+    dat = [];
11
+    for iRoiFile = 1:nRoi
12
+        [x1 y1] = ndgrid(1:V(kImage).dim(1),1:V(kImage).dim(2));
13
+        for p = 1:V(kImage).dim(3) % resample mask Vm(i) in space of V(k)
14
+            B = spm_matrix([0 0 -p 0 0 0 1 1 1]);
15
+            M = inv(B*inv(V(kImage).mat)*Vm(iRoiFile).mat);
16
+            msk = find(spm_slice_vol(Vm(iRoiFile),M,V(kImage).dim(1:2),0));
17
+            if ~isempty(msk)
18
+                z1 = p*ones(size(msk(:)));
19
+                x = [x; x1(msk(:))];
20
+                y = [y; y1(msk(:))];
21
+                z = [z; z1];
22
+            end
23
+        end
24
+        dat = [dat spm_sample_vol(V(kImage), x, y, z,0)];
25
+        
26
+    end
27
+    extr(kImage).dat = dat;
28
+end
29
+
30
+end
0 31
\ No newline at end of file