Browse code

radius backend working

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

Christoph Budziszewski authored on 18/03/2009 13:53:10
Showing 2 changed files
... ...
@@ -1,4 +1,5 @@
1
-function extr = calculateImageData(filenameList, voxelList, rad)
1
+function [extr voxelcount] = calculateImageData(filenameList, voxelList, rad)
2
+voxelcount = 0;
2 3
 
3 4
 V = filenameList;
4 5
 
... ...
@@ -14,10 +15,11 @@ for kImage=1:nImage
14 15
     y = roicenter(2,:);
15 16
     z = roicenter(3,:);
16 17
 
17
-            tmp = spm_imatrix(V(kImage).mat);
18
-            vdim = tmp(7:9);
19
-            vxrad = ceil((rad*ones(nVoxel,3))./(ones(nVoxel,1)*vdim))';
18
+    tmp = spm_imatrix(V(kImage).mat);
19
+    vdim = tmp(7:9);
20
+    vxrad = ceil((rad*ones(nVoxel,3))./(ones(nVoxel,1)*vdim))';
20 21
 
22
+    subvoxelcount = 0;
21 23
     for iVoxel = 1:nVoxel
22 24
 
23 25
         if rad==0
... ...
@@ -35,13 +37,16 @@ for kImage=1:nImage
35 37
             z = roicenter(3,iVoxel)+z(sel(:));
36 38
         end;
37 39
 
38
-
39 40
         dat = spm_sample_vol(V(kImage), x, y, z,0);
40 41
         
41
-        extr(kImage).dat(iVoxel,:)    = dat;
42
-        extr(kImage).mean(iVoxel)     = nanmean(dat);
43
-        extr(kImage).nvx(iVoxel)      = numel(dat);
44
-    end;
42
+        for iSubVoxel = 1:size(dat,1)
43
+            subvoxelcount = subvoxelcount +1;
44
+            extr(kImage).dat(subvoxelcount)    = dat(iSubVoxel);
45
+        end
46
+%         extr(kImage).mean(iVoxel)     = nanmean(dat);
47
+%         extr(kImage).nvx(iVoxel)      = numel(dat);
48
+    end
49
+    voxelcount = max(voxelcount,subvoxelcount);
50
+end   
45 51
 
46
-end;
47 52
 end
48 53
\ No newline at end of file
... ...
@@ -21,27 +21,28 @@ function subjectData = runCoordTable(args)
21 21
         map = load(fullfile(subjectStruct{s}.dir,'results','roi','coord_map.mat'));
22 22
         subjectStruct{s}.coords = getSubjectCoordinates(args.coords,map);
23 23
         
24
-        nVoxel = size(subjectStruct{s}.coords,1);
24
+%         nVoxel = size(subjectStruct{s}.coords,1);
25 25
         
26 26
         disp('fetching volume definitions, please wait');
27 27
         subjectStruct{s}.volumes = spm_vol(getImageFileList(subjectStruct{s}.dir,sessionlist,args.mask));
28 28
       
29
-        extr = calculateImageData(subjectStruct{s}.volumes,subjectStruct{s}.coords,radius);
29
+        [extr nExtractedVoxel] = calculateImageData(subjectStruct{s}.volumes,subjectStruct{s}.coords,radius);
30 30
          
31 31
         pstopts.des = subjectStruct{s}.des;
32 32
         pstopts.eventList = args.eventList;
33 33
         pstopts.sessionList = sessionlist;
34 34
         
35
-        disp('computing psth');
36
-        for iVoxel = 1:nVoxel
35
+        disp(sprintf('computing psth for %g voxel',nExtractedVoxel));
36
+        for iVoxel = 1:nExtractedVoxel
37 37
             rawdata = [];
38 38
             for iImage = 1:length(extr);
39 39
                 tmp = extr(iImage);
40
-                rawdata = [rawdata tmp.dat(iVoxel,:)];
40
+                rawdata = [rawdata tmp.dat(iVoxel)];
41 41
             end
42 42
             subjectStruct{s}.rawData{iVoxel} = rawdata;
43 43
             subjectStruct{s}.pst{iVoxel} = calculatePST(args.timeline,pstopts,rawdata);
44 44
         end
45
+        
45 46
        disp(sprintf('done %g / %g',s,nSubjects));
46 47
     end
47 48