killed unnecessary assignin raw axis fixed value added smooth option
Christoph Budziszewski

Christoph Budziszewski commited on 2008-12-18 15:29:41
Zeige 5 geänderte Dateien mit 27 Einfügungen und 14 Löschungen.


git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@95 83ab2cfd-5345-466c-8aeb-2b2739fb922d
... ...
@@ -14,7 +14,7 @@ sessionList     = inputStruct.sessionList;
14 14
 voxelList       = inputStruct.voxelList;
15 15
 % classList       = inputStruct.classList;
16 16
 % labelMap        = inputStruct.labelMap;
17
-% normalize       = inputStruct.normalize;
17
+smoothed       = inputStruct.smoothed;
18 18
 globalStart     = inputStruct.psthStart;
19 19
 globalEnd       = inputStruct.psthEnd;
20 20
 baselineStart   = inputStruct.baselineStart;
... ...
@@ -39,7 +39,7 @@ maxPerformance = -inf;
39 39
         
40 40
         
41 41
         for voxel = 1:size(voxelList,1)  % [[x;x],[y;y],[z;z]]
42
-                extr  = calculateImageData(voxelList(voxel,:),des);
42
+                extr  = calculateImageData(voxelList(voxel,:),des,smoothed);
43 43
                 rawdata=cell2mat({extr.mean}); % Raw Data
44 44
                 pst{voxel}  = calculatePST(des,globalStart,baselineStart,baselineEnd,globalEnd,eventList,rawdata,sessionList);
45 45
         end
... ...
@@ -83,7 +83,7 @@ maxPerformance = -inf;
83 83
 end
84 84
 
85 85
 
86
-function extr = calculateImageData(voxelList,des)
86
+function extr = calculateImageData(voxelList,des,smoothed)
87 87
 
88 88
 dtype='PSTH';
89 89
 
... ...
@@ -93,9 +93,15 @@ switch dtype
93 93
     case 'betas'
94 94
         V=des.Vbeta;
95 95
 end;
96
-%   for z=1:length(V) % Change Drive Letter!
97
-%       V(z).fname(1)='E';
98
-%   end;
96
+
97
+if (~smoothed)
98
+  for z=1:length(V) % Change Drive Letter!\
99
+      % D:....SUBJECTID\session\swfanders...
100
+      % D:....SUBJECTID\session\wfanders...
101
+      tmp = findstr(filesep,V(z).fname);
102
+      V(z).fname = strcat(V(z).fname(1:tmp(end)),V(z).fname(tmp(end)+2:end));
103
+  end;
104
+end
99 105
 
100 106
 % rad = 0; % one voxel
101 107
 % opt = 1; % xyz coordinates [mm]
... ...
@@ -31,13 +31,15 @@ end
31 31
         params = struct;
32 32
         params.nClasses = 2;
33 33
 
34
-        assignin('base','params',params);
34
+%         assignin('base','params',params);
35 35
         %% calculate
36 36
         display('calculating cross-validation performance time-shift');
37 37
         calculateParams  = struct;
38 38
         
39 39
         calculateParams.des             = spm.SPM;
40 40
         
41
+        calculateParams.smoothed        = getDouble(paramModel.txtSmoothed);
42
+        
41 43
         calculateParams.frameShiftStart = getDouble(paramModel.txtFrameShiftStart);  % -20;
42 44
         calculateParams.frameShiftEnd   = getDouble(paramModel.txtFrameShiftEnd); %15;
43 45
         calculateParams.decodeDuration  = getDouble(paramModel.txtFrameShiftDur);
... ...
@@ -52,7 +54,7 @@ end
52 54
         calculateParams.sessionList     = 1:3;
53 55
 
54 56
         classStruct = parseClassDef(paramModel);
55
-        assignin('base','classStruct',classStruct);
57
+%         assignin('base','classStruct',classStruct);
56 58
         
57 59
         calculateParams.classList       = classStruct.label; %{'<','>'};
58 60
         calculateParams.labelMap        = LabelMap(classStruct.label , classStruct.value); % LabelMap({'<','>','<+<','>+>','<+>','>+<'},{-2,-1,1,2,3,4});
... ...
@@ -79,6 +81,7 @@ end
79 81
         plotParams.decodePerformance = decode.decodePerformance;
80 82
         plotParams.rawTimeCourse     = decode.rawTimeCourse;
81 83
         plotParams.SubjectID         = SubjectID;
84
+        plotParams.smoothed          = calculateParams.smoothed;
82 85
         
83 86
         assignin('base','plotParams',plotParams);
84 87
 %         plotDecodePerformance(params.psthStart,params.psthEnd,params.nClasses,decode.decodeTable,params.frameShiftStart,params.frameShiftEnd,decode.rawTimeCourse);
... ...
@@ -12,6 +12,7 @@ if(nargin==1)
12 12
     frameEnd          = inputStruct.frameShiftEnd;
13 13
     psth              = inputStruct.rawTimeCourse;
14 14
     SubjectID         = inputStruct.SubjectID;
15
+    smoothed          = inputStruct.smoothed;
15 16
     
16 17
     
17 18
 elseif( nargin == 7)
... ...
@@ -25,6 +26,7 @@ elseif( nargin == 7)
25 26
     psth        = varargin(7);
26 27
     psth        = psth{1};
27 28
     SubjectID   = '';
29
+    smoothed    = '';
28 30
 end
29 31
 
30 32
     f = figure;
... ...
@@ -39,7 +41,7 @@ end
39 41
               plot(psthStart:psthEnd,psthData,[colorChooser(voxel), lineStyleChooser(label)]);
40 42
           end
41 43
       end
42
-%     axis([psthStart psthEnd 0 0])
44
+    axis([psthStart psthEnd -2 5])
43 45
     hold off
44 46
     
45 47
     subplot(2,1,2)    
... ...
@@ -55,7 +57,7 @@ end
55 57
 
56 58
     hold off;
57 59
 
58
-    title = sprintf('Subject %s, over %g voxel',SubjectID,size(psth,2));
60
+    title = sprintf('Subject %s, over %g voxel, smoothed %g',SubjectID,size(psth,2),smoothed);
59 61
     set(f,'Name',title);
60 62
     display(sprintf('%s',title));
61 63
 
... ...
@@ -87,7 +89,7 @@ switch(mod(n,4))
87 89
     case 2 
88 90
         style = ':';
89 91
     case 3
90
-        style = ':-';
92
+        style = '-.';
91 93
 end
92 94
 end
93 95
 
... ...
@@ -6,7 +6,7 @@ function voxelList = parseVoxelList(model)
6 6
         map = model.subjectMap;
7 7
         SubjectID = getSubjectIDString(model);
8 8
         
9
-        assignin('base','txt',txt);
9
+%         assignin('base','txt',txt);
10 10
         
11 11
         rows  = size(txt,1);
12 12
         
... ...
@@ -37,6 +37,8 @@ function spm_SVMCrossVal
37 37
                     'Position',[firstColumn firstRow 0.66*frameWidth controlElementHeight]);
38 38
     set(model.subjectSelector,'BackgroundColor','w');
39 39
     
40
+    model.txtSmoothed = createTextField(pSubject,[0.68*frameWidth firstRow  0.25*frameWidth controlElementHeight],'0');
41
+
40 42
     % PSTH
41 43
     firstColumn  = 5.00;
42 44
     secondColumn = 0.33*frameWidth;
... ...
@@ -100,7 +102,7 @@ function spm_SVMCrossVal
100 102
     firstRow     =  1.00 * controlElementHeight;
101 103
 
102 104
     model.txtSVMopts = createTextField(pSVM,[firstColumn firstRow  0.66*frameWidth controlElementHeight],'-t 0 -s 0 -v 6');
103
-    set(model.txtSVMopts,'Enable','inactive');
105
+    set(model.txtSVMopts,'Enable','on'); %inactive
104 106
     set(model.txtSVMopts,'HorizontalAlignment','left');
105 107
 
106 108
     set(btnRunButton,'Callback',{@cbRunSVM,model}); % set here, because of model.    
... ...
@@ -145,7 +147,7 @@ function cbRunSVM(src,evnt,model)
145 147
     if isSane(model)
146 148
         set(0,'userdata',model);
147 149
 %         set(src,'Enable','off');
148
-        assignin('base','guiParams',model);
150
+%         assignin('base','guiParams',model);
149 151
         classify(model)
150 152
 %         set(src,'Enable','on');
151 153
     else
152 154