first plot button. not working. Idea: 3 tasks = 3 models.
Christoph Budziszewski

Christoph Budziszewski commited on 2009-03-16 17:07:44
Zeige 8 geänderte Dateien mit 94 Einfügungen und 28 Löschungen.


git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@153 83ab2cfd-5345-466c-8aeb-2b2739fb922d
... ...
@@ -3,6 +3,9 @@ outputStruct = struct;
3 3
 RANDOMIZE_DATAPOINTS = 1;
4 4
 
5 5
 timeline = header.timeline;
6
+timeline.frameShiftStart = header.frameShift.frameShiftStart;
7
+timeline.frameShiftEnd   = header.frameShift.frameShiftEnd;
8
+timeline.decodeDuration  = header.frameShift.decodeDuration;
6 9
 
7 10
 timeLineStart  = timeline.frameShiftStart;
8 11
 timeLineEnd    = timeline.frameShiftEnd;
... ...
@@ -7,26 +5,27 @@ decode = struct;
7 5
 decode.decodePerformance = [];
8 6
 decode.rawTimeCourse     = [];
9 7
 
8
+nSubjects = numel(subjectdata);
9
+% disp(sprintf('we have %g subjects. Press ANY-Key to continue.\n Use Retrun if your Keyboard lacks the ANY-Key.',numel(subjectdata)));
10
+% pause
11
+disp(sprintf('batch processing %g subjects',nSubjects));
10 12
 
11
-disp(sprintf('we have %g subjects. Press ANY-Key to continue.\n Use Retrun if your Keyboard lacks the ANY-Key.',numel(subjectdata)));
12
-pause
13
-
14
-for subjectDataID = 1:numel(subjectdata)
13
+for subjectDataID = 1:nSubjects
15 14
 %     SubjectID = cell2mat(subjectCell);
16 15
     currentSubject = subjectdata{subjectDataID};
17 16
 
18 17
     namehelper = strcat('s',currentSubject.name); %Vars can not start with numbers.
19 18
 
20 19
     display(sprintf('calculating cross-validation performance time-shift for Subject %s. Please Wait. ...',currentSubject.name));
21
-    display('switching off all warnings');
22
-    warning_state               = warning('off','all');
20
+%     display('switching off all warnings');
21
+%     warning_state               = warning('off','all');
23 22
     display('calculating ...');
24 23
     
25 24
         decode.(namehelper)         = calculateDecodePerformance(header,currentSubject,svmopts);
26 25
 
27 26
     display('... done');
28
-    display('restoring warnings');
29
-    warning(warning_state);
27
+%     display('restoring warnings');
28
+%     warning(warning_state);
30 29
 
31 30
     decode.decodePerformance    = [decode.decodePerformance decode.(namehelper).decodePerformance];
32 31
     decode.rawTimeCourse        = [decode.rawTimeCourse decode.(namehelper).rawTimeCourse];
... ...
@@ -0,0 +1,7 @@
1
+% generate parameter structs for subroutines
2
+function frameshiftStruct = getFrameShiftParams(paramModel)
3
+frameshiftStruct = struct;
4
+frameshiftStruct.frameShiftStart = getDouble(paramModel.txtFrameShiftStart);  % -20;
5
+frameshiftStruct.frameShiftEnd   = getDouble(paramModel.txtFrameShiftEnd); %15;
6
+frameshiftStruct.decodeDuration  = getDouble(paramModel.txtFrameShiftDur);
7
+end
... ...
@@ -1,9 +1,9 @@
1 1
 % generate parameter structs for subroutines
2 2
 function timelineParams = getTimeLineParams(paramModel)
3 3
 timelineParams = struct;
4
-timelineParams.frameShiftStart = getDouble(paramModel.txtFrameShiftStart);  % -20;
5
-timelineParams.frameShiftEnd   = getDouble(paramModel.txtFrameShiftEnd); %15;
6
-timelineParams.decodeDuration  = getDouble(paramModel.txtFrameShiftDur);
4
+% timelineParams.frameShiftStart = getDouble(paramModel.txtFrameShiftStart);  % -20;
5
+% timelineParams.frameShiftEnd   = getDouble(paramModel.txtFrameShiftEnd); %15;
6
+% timelineParams.decodeDuration  = getDouble(paramModel.txtFrameShiftDur);
7 7
 timelineParams.psthStart       = getDouble(paramModel.txtPSTHStart); % -25;
8 8
 timelineParams.psthEnd         = getDouble(paramModel.txtPSTHEnd); % 20;
9 9
 timelineParams.baselineStart   = getDouble(paramModel.txtBaselineStart); % -22;
... ...
@@ -73,16 +73,21 @@ end
73 73
 
74 74
 function decode(model,task)
75 75
 preprocessedData = evalin('base','preprocessedData');
76
+
77
+header            = preprocessedData.header;
78
+header.frameShift = getFrameShiftParams(model);
79
+data              = preprocessedData.subjectdata;
80
+
76 81
 switch task
77 82
     case 'SVM'
78 83
         disp('SVM');
79 84
         svmopts    = getSvmArgs(model,1);
80
-        decode = calculateMultiSubjectDecodePerformance(preprocessedData.header,preprocessedData.subjectdata,svmopts);
85
+        decode = calculateMultiSubjectDecodePerformance(header,data,svmopts);
81 86
         assignin('base','decode',decode);
82 87
     case 'XSVM'
83 88
         disp('XSVM')
84 89
         svmopts  = getSvmArgs(model,0);
85
-        decode = xsvm_subject_loop(preprocessedData.header,preprocessedData.subjectdata,svmopts);
90
+        decode = xsvm_subject_loop(header,data,svmopts);
86 91
         assignin('base','decode',decode);
87 92
     case 'SOM'
88 93
         disp('not implemented')
... ...
@@ -96,6 +101,9 @@ end
96 101
 % warning('on',warn);
97 102
 end
98 103
 
104
+function decode_plot()
105
+end
106
+
99 107
 
100 108
 
101 109
 
... ...
@@ -7,8 +7,7 @@ subjects = args.subjects;
7 7
 nSubjects = numel(subjects);
8 8
 sessionlist = args.sessionList;
9 9
 
10
-disp(sprintf('we have %g subjects. Press ANY-Key to continue.\n Use Retrun if your Keyboard lacks the ANY-Key.',nSubjects));
11
-pause
10
+disp(sprintf('batch processing  %g subjects.',nSubjects));
12 11
 
13 12
 for s = 1:nSubjects
14 13
     subjectStruct{s}.dir = fullfile(args.basedir,cell2mat(subjects(s)));
... ...
@@ -56,6 +56,11 @@ DEFAULT.wd  = fullfile('d:','Analyze','Choice','24pilot');
56 56
     set(task.classification,'BackgroundColor','w');
57 57
     model = createSecondStepPanel(model,task.classification,DEFAULT);
58 58
     
59
+    % PLOT
60
+    task.plot = uipanel(frame,'Title','Plot','Position',[0 0.0 1 TASK_HEIGHT]);
61
+    set(task.plot,'BackgroundColor','w');
62
+    model = createVisualStepPanel(model,task.plot,DEFAULT);
63
+    
59 64
     % TASK
60 65
     task.taskSwitch = uipanel(frame,'Position',[0 1-0.13 1 0.10]);
61 66
 %         set(task.taskSwitch,'Title','TASK');
... ...
@@ -91,7 +96,7 @@ DEFAULT.wd  = fullfile('d:','Analyze','Choice','24pilot');
91 96
     model = scanDirs(model);
92 97
     set(frame,'Visible','on');
93 98
 
94
-    assignin('base','model',model);
99
+%     assignin('base','model',model);
95 100
 end
96 101
 
97 102
 function model = createFirstStepPanel(model,parent,DEFAULT)
... ...
@@ -118,6 +123,7 @@ function model = createFirstStepPanel(model,parent,DEFAULT)
118 123
                     'UserData',subjectList,...
119 124
                     'Units','normalized',...
120 125
                     'Position',[0 0 1 1]);
126
+    set(model.subjectSelector, 'FontName', 'FixedWidth');
121 127
     set(model.subjectSelector,'BackgroundColor','w');
122 128
     
123 129
     %Classes
... ...
@@ -179,19 +185,15 @@ function model = createFirstStepPanel(model,parent,DEFAULT)
179 185
         lEnd        = createLabel(pPSTH, cell2mat(tl_grid(3,1)) ,'End [sec]');
180 186
         lPSTH       = createLabel(pPSTH, cell2mat(tl_grid(1,2)),'PSTH Range');
181 187
         lBaseline   = createLabel(pPSTH, cell2mat(tl_grid(1,3)),'Baseline');
182
-        lFrameShift = createLabel(pPSTH, cell2mat(tl_grid(1,4)),'Frame Shift');
183
-        lFramsSize  = createLabel(pPSTH, cell2mat(tl_grid(1,5)),'Frame Size');
184
-        lSearchligh = createLabel(pPSTH, cell2mat(tl_grid(1,6)),'Searchlight Radius');
188
+
189
+        lSearchligh = createLabel(pPSTH, cell2mat(tl_grid(1,5)),'Searchlight Radius');
185 190
 
186 191
 
187 192
         model.txtPSTHStart         = createTextField(pPSTH,cell2mat(tl_grid(2,2)),DEFAULT.pststart);
188 193
         model.txtPSTHEnd           = createTextField(pPSTH,cell2mat(tl_grid(3,2)),DEFAULT.pstend);
189 194
         model.txtBaselineStart     = createTextField(pPSTH,cell2mat(tl_grid(2,3)),DEFAULT.baselinestart);
190 195
         model.txtBaselineEnd       = createTextField(pPSTH,cell2mat(tl_grid(3,3)),DEFAULT.baselineend);
191
-        model.txtFrameShiftStart   = createTextField(pPSTH,cell2mat(tl_grid(2,4)),DEFAULT.frameshiftstart);
192
-        model.txtFrameShiftEnd     = createTextField(pPSTH,cell2mat(tl_grid(3,4)),DEFAULT.frameshiftend);
193
-        model.txtFrameShiftDur     = createTextField(pPSTH,cell2mat(tl_grid(2,5)),DEFAULT.frameshiftdur);
194
-        model.txtSearchlightRadius = createTextField(pPSTH,cell2mat(tl_grid(2,6)),DEFAULT.searchlightradius);
196
+        model.txtSearchlightRadius = createTextField(pPSTH,cell2mat(tl_grid(2,5)),DEFAULT.searchlightradius);
195 197
         
196 198
         % images
197 199
         pImage = uipanel(parent,'Title','Image Options','Position',cell2mat(main_grid(2,2)));
... ...
@@ -267,11 +269,33 @@ end
267 269
 function model = createSecondStepPanel(model,parent,DEFAULT)
268 270
 basecolor = 'w';
269 271
 
270
-pTime = uipanel(parent,'Units','normalized','Position',[0.0 0.8 1 0.3]);
271
-%     set(pTime,'Title','Frameshift Opts');
272
+pTime = uipanel(parent,'Units','normalized','Position',[0.0 0.8 1 0.2]);
273
+    set(pTime,'Title','Decode Timeframe Options');
272 274
     set(pTime,'BackgroundColor',basecolor);
273
-    
274
-pSVM = uipanel(parent,'Units','normalized','Position',[0 0.0 0.5 0.7]);
275
+    grid_h = 0.3;
276
+    grid_w = 0.3;
277
+    time_grid = cell([3 3]);
278
+    time_grid{1,1} = [0.0 0.63 grid_w grid_h];
279
+    time_grid{2,1} = [0.4 0.63 grid_w grid_h];
280
+    time_grid{3,1} = [0.7 0.63 grid_w grid_h];
281
+    time_grid{1,2} = [0.0 0.33 grid_w grid_h];
282
+    time_grid{2,2} = [0.4 0.33 grid_w grid_h];
283
+    time_grid{3,2} = [0.7 0.33 grid_w grid_h];
284
+    time_grid{1,3} = [0.0 0.03 grid_w grid_h];
285
+    time_grid{2,3} = [0.4 0.03 grid_w grid_h];
286
+    time_grid{3,3} = [0.7 0.03 grid_w grid_h];
287
+
288
+    lStart      = createLabel(pTime, cell2mat(time_grid(2,1)) ,'Start [sec]');
289
+    lEnd        = createLabel(pTime, cell2mat(time_grid(3,1)) ,'End [sec]');
290
+    lFrameShift = createLabel(pTime, cell2mat(time_grid(1,2)),'Frame Shift');
291
+    lFramsSize  = createLabel(pTime, cell2mat(time_grid(1,3)),'Frame Size');
292
+    
293
+    model.txtFrameShiftStart   = createTextField(pTime,cell2mat(time_grid(2,2)),DEFAULT.frameshiftstart);
294
+    model.txtFrameShiftEnd     = createTextField(pTime,cell2mat(time_grid(3,2)),DEFAULT.frameshiftend);
295
+    model.txtFrameShiftDur     = createTextField(pTime,cell2mat(time_grid(2,3)),DEFAULT.frameshiftdur);
296
+
297
+    
298
+pSVM = uipanel(parent,'Units','normalized','Position',[0 0.4 0.5 0.4]);
275 299
     set(pSVM,'Title','SVM Classification');
276 300
     set(pSVM,'BackgroundColor',basecolor);
277 301
 
... ...
@@ -281,7 +305,7 @@ pSVM = uipanel(parent,'Units','normalized','Position',[0 0.0 0.5 0.7]);
281 305
     model.txtSVMnfold = createTextField(pSVM,[0.0 0.50 0.5 0.25],DEFAULT.svmnfold);
282 306
     createLabel(pSVM,[0.5 0.50 0.5 0.25 ],'-Fold CrossVal');
283 307
     
284
-pSOM = uipanel(parent,'Units','normalized','Position',[0.5 0.0 0.5 0.7]);
308
+pSOM = uipanel(parent,'Units','normalized','Position',[0.5 0.4 0.5 0.4]);
285 309
     set(pSOM,'Title','SOM Classification');
286 310
     set(pSOM,'BackgroundColor',basecolor);
287 311
 
... ...
@@ -319,10 +343,24 @@ pSOM = uipanel(parent,'Units','normalized','Position',[0.5 0.0 0.5 0.7]);
319 343
     set(btnRunXSOM,'Enable','off');
320 344
 end
321 345
 
346
+function model = createVisualStepPanel(model,parent,DEFAULT)
347
+    pButtonPane = uipanel(parent,'Units','normalized','Position',[0.0 0.5 1 0.5]);
348
+%     set(pButtonPane,'Title','Plot');
349
+    set(pButtonPane,'BackgroundColor','w');
350
+
351
+    btnPlot01 = uicontrol(pButtonPane,'String','plot BBBB',...
352
+        'Units','normalized',...
353
+        'Position',[0.0 0.0 1 0.25]);
354
+    set(btnPlot01,'Callback',{@cbPlot,model,'XSOM'}); % set here, because of model.
355
+    set(btnPlot01,'Enable','on');
356
+
357
+end
358
+
322 359
 
323 360
 function cbSwitchTask(src,evnt,task,taskpanel)
324 361
 set(taskpanel.preprocessing,'Visible','off');
325 362
 set(taskpanel.classification,'Visible','off');
363
+set(taskpanel.plot,'Visible','off');
326 364
 
327 365
 switch task
328 366
     case 'PRE'
... ...
@@ -330,6 +368,7 @@ switch task
330 368
     case 'CLASSIFY'
331 369
         set(taskpanel.classification,'Visible','on');
332 370
     case 'PLOT'
371
+        set(taskpanel.plot,'Visible','on');
333 372
 end
334 373
 end
335 374
 
... ...
@@ -342,6 +381,12 @@ function cbRunDecode(src,evnt,model,task)
342 381
 main(model,'decode',task);
343 382
 end
344 383
 
384
+function cbPlot(src,evnt,model,type)
385
+display('Not Implemented');
386
+main(model,'plot',type);
387
+end
388
+
389
+
345 390
 function model = mcb_cd(src,evnt,model)
346 391
 disp('CD');
347 392
 directory_name = uigetdir(model.baseDir,'Select Study Base Directory ...');
... ...
@@ -14,6 +14,9 @@ decode.rawTimeCourse     = [];
14 14
 disp(sprintf('computinig additional datastructs for %u subjects',nSubjects));
15 15
 
16 16
 timeline = header.timeline;
17
+timeline.frameShiftStart = header.frameShift.frameShiftStart;
18
+timeline.frameShiftEnd   = header.frameShift.frameShiftEnd;
19
+timeline.decodeDuration  = header.frameShift.decodeDuration;
17 20
 
18 21
 % TimePointMatrix
19 22
 for subjectDataID = 1:nSubjects
20 23