Browse code

added timer

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

Christoph Budziszewski authored on 02/04/2009 14:30:49
Showing 1 changed files
... ...
@@ -31,25 +31,24 @@ svmopts = fbsargs.svmopts;
31 31
 disp(sprintf('batch processing  %g subjects.',nSubjects));
32 32
 
33 33
 for s = 1:nSubjects
34
+    elapsed{s} = struct; %measure the timing
34 35
 
35
-
36
-    
37
-    elapsed = struct; %measure the timing
38 36
     disp(sprintf('processing subject %s.',subjects{s}.name));
39 37
     % load image data
40 38
    
41 39
     disp('fetching volume definitions, please wait');
42 40
     tic;
43 41
     volumes = spm_vol(getImageFileList(subjects{s}.dir,sessionlist,args.mask));
44
-    elapsed.loadList = toc;
42
+    elapsed{s}.loadList = toc;
43
+    
45 44
     disp('computing volume values, please wait');
46 45
     tic 
47 46
     [extr x y z] = calculateRoiImageData(volumes,subjects{s}.roiFile);
48
-    elapsed.calcExtr = toc;
47
+    elapsed{s}.calcExtr = toc;
49 48
     
50
-% clear volumes; %save memory ??
51
-% disp('cleared volumes');
52
-tic
49
+    clear volumes; %save memory ??
50
+    disp('cleared volumes');
51
+    tic
53 52
     
54 53
     nVoxel = size(extr(1).dat,1);
55 54
 
... ...
@@ -68,7 +67,7 @@ tic
68 67
     mapping.indexToCoordMap = indexToCoordMap;
69 68
     mapping.coordToIndexMap = coordToIndexMap;
70 69
 
71
-    elapsed.mapping = toc;
70
+    elapsed{s}.mapping = toc;
72 71
     
73 72
     % calculate psth
74 73
     
... ...
@@ -76,7 +75,7 @@ tic
76 75
     pstopts.des = subjects{s}.des;
77 76
 
78 77
     disp(sprintf('computing psth for %g voxel.',nVoxel));
79
-tic 
78
+    tic
80 79
 
81 80
     for iVoxel = 1:nVoxel
82 81
         rawdata = [];
... ...
@@ -88,24 +87,24 @@ tic
88 87
         pst{iVoxel} = calculatePST(args.timeline,pstopts,rawdata); % do not store in subjectStruct, so we can clear it later.
89 88
 
90 89
          p = iVoxel/nVoxel*100;
91
-         if(mod(iVoxel,nVoxel/100)==0)
90
+         if(mod(iVoxel,floor(nVoxel/100))==0)
92 91
              sprintf(' %g%%\t complete',p);
93 92
          end
94 93
     end
95
-elapsed.psth = toc;
94
+    elapsed{s}.psth = toc;
96 95
     disp('psth done');
97 96
     warning(warn);
98 97
     clear extr;
99 98
     %run searchlight
100
-tic
99
+    tic
101 100
     
102 101
     display(sprintf('rastering %g coordinates with approx. %g mm radius',nVoxel,radius));
103 102
     % for each timeslice
104
-    globalStart = timeline.psthStart;
105
-    globalEnd = timeline.psthEnd;
106
-    decodeDuration = timeline.decodeDuration;
107
-    labelMap = timePointArgs.labelMap;
108
-    eventList = pstopts.eventList;
103
+    globalStart     = timeline.psthStart;
104
+    globalEnd       = timeline.psthEnd;
105
+    decodeDuration  = timeline.decodeDuration;
106
+    labelMap        = timePointArgs.labelMap;
107
+    eventList       = pstopts.eventList;
109 108
     
110 109
     % tmp = spm_imatrix(V(kImage).mat); %
111 110
     % vdim = tmp(7:9); % Voxel-Size
... ...
@@ -158,16 +157,15 @@ tic
158 157
         end  %for each voxel
159 158
 
160 159
         nii = make_nii(img3D,vdim,mask_image.hdr.hist.originator(1:3),16,'decode performance'); %default origin
161
-        save_nii(nii,sprintf('TESTFILE%g',timeShift));
160
+        save_nii(nii,fullfile('output',sprintf('TESTFILE%g',timeShift)));
162 161
 %         save_nii(mask_image,sprintf('MTESTFILE%g',timeShift));
163 162
     
164 163
     end %for each timeslice
165 164
     display('rastering done');
166
-elapsed.decode = toc;
167
-
165
+    elapsed{s}.decode = toc;
168 166
 
169 167
     clear pst; %save memory!
170
-assignin('base','timing',elapsed);
168
+    assignin('base','timing',elapsed);
171 169
 end
172 170
 
173 171
 end