radius backend working
Christoph Budziszewski

Christoph Budziszewski commited on 2009-03-18 13:53:10
Zeige 2 geänderte Dateien mit 17 Einfügungen und 12 Löschungen.


git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@161 83ab2cfd-5345-466c-8aeb-2b2739fb922d
... ...
@@ -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
 
... ...
@@ -18,6 +19,7 @@ for kImage=1:nImage
18 19
     vdim = tmp(7:9);
19 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,23 +21,23 @@ 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