preliminary confidence intervall plot data save+load
Christoph Budziszewski

Christoph Budziszewski commited on 2009-08-05 14:12:52
Zeige 3 geänderte Dateien mit 75 Einfügungen und 5 Löschungen.


git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@203 83ab2cfd-5345-466c-8aeb-2b2739fb922d
... ...
@@ -16,14 +16,13 @@ SubjectID         = subjectData;
16 16
 
17 17
 nSubjects         = size(SubjectID,2);
18 18
 
19
+nTrials           = getNTrials(psth);
19 20
 
20 21
     f = figure;
21 22
   
22 23
     hold on;
23 24
     chanceLevel = 100/nClasses;
24
-    goodPredictionLevel = chanceLevel*1.5;
25
-    plot([psthStart psthEnd],[chanceLevel chanceLevel],'k:');
26
-    plot([psthStart psthEnd],[goodPredictionLevel goodPredictionLevel],'k:');
25
+
27 26
     axis([psthStart psthEnd 0 100])
28 27
     xlabel('time [sec]');
29 28
     ylabel('decode performance [%]');
... ...
@@ -41,12 +40,40 @@ nSubjects         = size(SubjectID,2);
41 40
             end
42 41
             plotDecodePerformanceWithSE(frameStart,frameEnd,decodePerformance)
43 42
     end
43
+    
44
+    plot([psthStart psthEnd],[chanceLevel chanceLevel],'k:');
45
+
46
+    plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.05,chanceLevel/100,'r');
47
+    plotBinConfidenceIntervall(psthStart,psthEnd,nTrials,0.01,chanceLevel/100,'g');
48
+    
44 49
     hold off;
45 50
     
46 51
 %     setTitle(f,header,decode,subjectData);
47 52
     
48 53
 end
49 54
 
55
+function plotBinConfidenceIntervall(pStart,pEnd,nTrials,alpha,limit,color)
56
+    [pLevel Z] = rev_ki_bin(nTrials,alpha,limit);
57
+    [lower upper proz] = ki_bin(Z,nTrials,alpha);
58
+
59
+    plot([pStart pEnd],[pLevel*100 pLevel*100],[color ':']);
60
+
61
+    plot([pStart pEnd],[lower*100 lower*100],[color '-.']);
62
+    plot([pStart pEnd],[upper*100 upper*100],[color '-.']);
63
+end
64
+
65
+function n = getNTrials(psth)
66
+nSubjects = size(psth,2);
67
+
68
+n = 0;
69
+for ns = 1:nSubjects
70
+    nClasses = size(psth{ns},2);
71
+    for nc = 1:nClasses
72
+        n = n + size(psth{ns}{nc},1);
73
+    end
74
+end
75
+end
76
+
50 77
 function plotClassPerformance(frameStart,frameEnd,decodePerformance,nClasses)
51 78
 for c = 1:size(decodePerformance,2)
52 79
     plot(frameStart:frameEnd, decodePerformance(:,c) ,[colorChooser(mod(c,nClasses)+3) '-']);
... ...
@@ -76,6 +103,7 @@ PSTH_AXIS_MAX = 2;
76 103
               for timepoint = 1:size(psth{voxel}{label},2)
77 104
                   psthData = nanmean(psth{voxel}{label});
78 105
               end
106
+              PSTH_AXIS_MAX = max(PSTH_AXIS_MAX,nanmax(psthData));
79 107
               plot(psthStart:psthEnd,psthData,[colorChooser(voxel), lineStyleChooser(label)]);
80 108
           end
81 109
       end
... ...
@@ -71,7 +71,11 @@ function ui_main(varargin)
71 71
     % MENUS
72 72
 
73 73
     savemenu = uimenu(frame,'Label','Save ...','Enable','on');
74
-        uimenu(savemenu,'Label','Save All','Callback',{@mcb_save,model},'Enable','on');
74
+        uimenu(savemenu,'Label','Save Parameter','Callback',{@mcb_save,'PARAMS',model},'Enable','on');
75
+        uimenu(savemenu,'Label','Save ImageProcesseding Data','Callback',{@mcb_save,'IMAGEPROCESSING',model},'Enable','on');
76
+        uimenu(savemenu,'Label','Load ImageProcesseding Data','Callback',{@mcb_load,'IMAGEPROCESSING',model},'Enable','on');
77
+        uimenu(savemenu,'Label','Save Decode Data','Callback',{@mcb_save,'DECODE',model},'Enable','on');
78
+        uimenu(savemenu,'Label','Load Decode Data','Callback',{@mcb_load,'DECODE',model},'Enable','on');
75 79
         
76 80
     studySelectMenu = uimenu(frame,'Label','Study ...','Enable','on');
77 81
         uimenu(studySelectMenu,'Label','*new Study*','Callback',{@mcb_new_study,studySelectMenu,model});
... ...
@@ -473,9 +477,47 @@ end
473 477
 
474 478
 %%%%%%%%%% menu callbacks
475 479
 
476
-function mcb_save(src,evnt,model)
480
+function mcb_save(src,evnt,token,model)
481
+switch token
482
+    case 'PARAMS'
477 483
         studyID = get(model.txtStudyID,'String');
478 484
         saveStudy(studyID,model);
485
+    case 'IMAGEPROCESSING'
486
+        disp('save img data..');
487
+        [FileName,PathName,FilterIndex] = uiputfile('*.mat','Save ImageProcessing Data') ;
488
+        if(~strcmp(FileName,''))
489
+            evalin('base', sprintf('save(''%s'',''%s'')',fullfile(PathName,FileName),'preprocessedData'));
490
+            disp('saved');
491
+        end
492
+%         [FileName,PathName,FilterIndex] = uigetfile('*.mat','Load ImageProcessing Data') 
493
+%         evalin('base', sprintf('load(%s,%s)',fullfile(PathName,FileName),'preprocessedData'));
494
+    case 'DECODE'
495
+        disp('save decode data..');
496
+        [FileName,PathName,FilterIndex] = uiputfile('*.mat','Save Decode Data') ;
497
+        if(~strcmp(FileName,''))
498
+            evalin('base', sprintf('save(''%s'',''%s'')',fullfile(PathName,FileName),'decode'));
499
+            disp('saved');
500
+        end
501
+end
502
+end
503
+
504
+function mcb_load(src,evnt,token,model)
505
+switch token
506
+    case 'IMAGEPROCESSING'
507
+        disp('load img data..');
508
+        [FileName,PathName,FilterIndex] = uigetfile('*.mat','Load ImageProcessing Data') ;
509
+        if(~strcmp(FileName,''))
510
+            evalin('base', sprintf('load(''%s'',''%s'')',fullfile(PathName,FileName),'preprocessedData'));
511
+            disp('done');
512
+        end
513
+    case 'DECODE'
514
+        disp('load decode data..');
515
+        [FileName,PathName,FilterIndex] = uigetfile('*.mat','Load Decode Data') ;
516
+        if(~strcmp(FileName,''))
517
+            evalin('base', sprintf('load(''%s'',''%s'')',fullfile(PathName,FileName),'decode'));
518
+            disp('done');
519
+        end
520
+end
479 521
 end
480 522
 
481 523
 function mcb_update_subjects(src,evnt,model)