Browse code

new GUI. Only Layout. Backend missing.

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

Christoph Budziszewski authored on 11/02/2009 16:49:37
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,227 @@
1
+function ui_main(varargin)
2
+
3
+DEFAULT.selectedSubject = 1;
4
+DEFAULT.smoothed        = 1;
5
+DEFAULT.multisubject    = 'single';
6
+DEFAULT.pststart        = -15;
7
+DEFAULT.pstend          = 40;
8
+DEFAULT.baselinestart   = -3;
9
+DEFAULT.baselineend     = -1;
10
+DEFAULT.frameshiftstart = -5;
11
+DEFAULT.frameshiftend   = 35;
12
+DEFAULT.frameshiftdur   = 0;
13
+DEFAULT.classdefstring  = 'left,\t[9,11,13]\nright,\t[10,12,14]';
14
+DEFAULT.voxelstring     = 'SPL l + [ 0, 0, 0] \nSPL r + [ 0, 0, 0]\n';
15
+DEFAULT.svmoptstring    = '-s 0 -t 0 -v 6 -c 1';
16
+DEFAULT.searchlightradius = 3;
17
+
18
+%  Initialize and hide the GUI as it is being constructed.
19
+    frameWidth=450;
20
+    frameHeight=600;
21
+    
22
+    frame = figure('Visible','off','Position',[0,0,frameWidth,frameHeight]);
23
+    movegui(frame,'west'); % get this thing visible on smaller displays.
24
+    set(frame,'Name','SVMCrossVal Decode Performance 4 SPM');
25
+    set(frame,'NumberTitle','off');
26
+    set(frame,'MenuBar','none');
27
+    set(frame,'Color',get(0,'defaultUicontrolBackgroundColor'));
28
+    set(frame,'Resize','off');
29
+    set(frame,'Units','normalized');
30
+
31
+    pFirstStep   = uipanel(frame,'Title','Preprocessing','Position',[0 0.4 1 0.6]);
32
+    set(pFirstStep,'BackgroundColor','w');
33
+    set(pFirstStep,'Units','normalized');
34
+    
35
+
36
+    model = createFirstStepPanel(pFirstStep,DEFAULT);
37
+    assignin('base','model',model);
38
+    
39
+    %Classification Step
40
+    secondStepBaseColor = [0.7 0.7 0.0 ];
41
+    pSecondStep = uipanel(frame,'Title','Classification','Position',[0 0 1 0.4]);
42
+    set(pSecondStep,'BackgroundColor',secondStepBaseColor);
43
+
44
+    
45
+    model2 = createSecondStepPanel(pSecondStep,DEFAULT,secondStepBaseColor);
46
+    assignin('base','model2',model2);
47
+
48
+    set(frame,'Visible','on');
49
+end
50
+
51
+function model = createSecondStepPanel(parent,DEFAULT,basecolor)
52
+pSVM = uipanel(parent,'Units','normalized','Position',[0 0 0.5 0.9]);
53
+    set(pSVM,'Title','SVM Classification');
54
+    set(pSVM,'BackgroundColor',basecolor);
55
+
56
+    model.txtSVMopts = createTextField(pSVM,[0 0.9 1 0.1],DEFAULT.svmoptstring);
57
+    set(model.txtSVMopts,'Enable','on'); %inactive
58
+    set(model.txtSVMopts,'HorizontalAlignment','left');
59
+
60
+    
61
+pSOM = uipanel(parent,'Units','normalized','Position',[0.5 0 0.5 0.9]);
62
+    set(pSOM,'Title','SVM Classification');
63
+    set(pSOM,'BackgroundColor',basecolor);
64
+end
65
+
66
+function model = createFirstStepPanel(parent,DEFAULT)
67
+
68
+    x1 = 0;
69
+    x2 = 0.4;
70
+    x3 = 1;
71
+    
72
+    y1 = 1;
73
+    y2 = 0.6;
74
+    y3 = 0.4;
75
+    y4 = 0.2;
76
+    y5 = 0;
77
+    
78
+    %Subjects
79
+    subjectList = {'Subj1','Subj2','Subj3','Subj4'};
80
+    model.subjectSelector = uicontrol(parent,'Style','listbox',...
81
+                    'Min',1, 'Max',3,...
82
+                    'String',subjectList,...
83
+                    'UserData',subjectList,...
84
+                    'Units','normalized',...
85
+                    'Position',[x1 y2 x2-x1 y1-y2]);
86
+    set(model.subjectSelector,'BackgroundColor','y');
87
+    
88
+    %Classes
89
+    pClasses = uipanel(parent,'Units','normalized','Position',[x1 y3 0.5 0.2]);
90
+    set(pClasses,'Title','Class Definitions');
91
+    set(pClasses,'BackgroundColor','w');
92
+        lClassDef = uicontrol(pClasses,...
93
+            'Style','text',...
94
+            'String',sprintf('<Label>,\t <[Event, Event, ..]>;'),...
95
+            'Units','normalized',...
96
+            'Position',[0 0.8 1 0.2]);
97
+        set(lClassDef,'BackgroundColor','w');
98
+        set(lClassDef,'HorizontalAlignment','left');
99
+        
100
+        model.txtClassDef = uicontrol(pClasses,'Style','edit',...
101
+            'String',sprintf(DEFAULT.classdefstring),...
102
+            'Units','normalized',...
103
+            'Position',[0 0 1 0.8]);
104
+        set(model.txtClassDef,'HorizontalAlignment','left');
105
+        set(model.txtClassDef,'Max',20);
106
+        set(model.txtClassDef,'Min',0);
107
+        set(model.txtClassDef, 'FontName', 'FixedWidth');
108
+        set(model.txtClassDef, 'BackgroundColor', 'y');
109
+
110
+
111
+    %Timeline
112
+    pPSTH        = uipanel(parent,'Title','PSTH Options','Position',[0.5 y2 0.5 y1-y2]);
113
+    set(pPSTH,'BackgroundColor','w');
114
+        
115
+        grid_h = 0.16;
116
+        grid_w = 0.3;
117
+        
118
+        grid = cell([3 6]);
119
+        grid{2,1} = [0.0 0.83 grid_w grid_h];
120
+        grid{2,1} = [0.4 0.83 grid_w grid_h];
121
+        grid{3,1} = [0.7 0.83 grid_w grid_h];
122
+        
123
+        grid{1,2} = [0.0 0.66 grid_w grid_h];
124
+        grid{2,2} = [0.4 0.66 grid_w grid_h];
125
+        grid{3,2} = [0.7 0.66 grid_w grid_h];
126
+
127
+        grid{1,3} = [0.0 0.5 grid_w grid_h];
128
+        grid{2,3} = [0.4 0.5 grid_w grid_h];
129
+        grid{3,3} = [0.7 0.5 grid_w grid_h];
130
+        
131
+        grid{1,4} = [0.0 0.33 grid_w grid_h];
132
+        grid{2,4} = [0.4 0.33 grid_w grid_h];
133
+        grid{3,4} = [0.7 0.33 grid_w grid_h];
134
+
135
+        grid{1,5} = [0.0 0.16 0.5 grid_h];
136
+        grid{2,5} = [0.5 0.16 grid_w grid_h];
137
+        grid{3,5} = [0.75 0.16 grid_w grid_h];
138
+        
139
+        grid{1,6} = [0.0 0.0 0.5 grid_h];
140
+        grid{2,6} = [0.5 0.0 grid_w grid_h];
141
+        grid{3,6} = [0.75 0.0 grid_w grid_h];
142
+
143
+        lStart      = createLabel(pPSTH, cell2mat(grid(2,1)) ,'Start [sec]');
144
+        lEnd        = createLabel(pPSTH, cell2mat(grid(3,1)) ,'End [sec]');
145
+        lPSTH       = createLabel(pPSTH, cell2mat(grid(1,2)),'PSTH Range');
146
+        lBaseline   = createLabel(pPSTH, cell2mat(grid(1,3)),'Baseline');
147
+        lFrameShift = createLabel(pPSTH, cell2mat(grid(1,4)),'Frame Shift');
148
+        lFramsSize  = createLabel(pPSTH, cell2mat(grid(1,5)),'Frame Size');
149
+        lSearchligh = createLabel(pPSTH, cell2mat(grid(1,6)),'Searchlight Radius');
150
+
151
+
152
+        model.txtPSTHStart         = createTextField(pPSTH,cell2mat(grid(2,2)),DEFAULT.pststart);
153
+        model.txtPSTHEnd           = createTextField(pPSTH,cell2mat(grid(3,2)),DEFAULT.pstend);
154
+        model.txtBaselineStart     = createTextField(pPSTH,cell2mat(grid(2,3)),DEFAULT.baselinestart);
155
+        model.txtBaselineEnd       = createTextField(pPSTH,cell2mat(grid(3,3)),DEFAULT.baselineend);
156
+        model.txtFrameShiftStart   = createTextField(pPSTH,cell2mat(grid(2,4)),DEFAULT.frameshiftstart);
157
+        model.txtFrameShiftEnd     = createTextField(pPSTH,cell2mat(grid(3,4)),DEFAULT.frameshiftend);
158
+        model.txtFrameShiftDur     = createTextField(pPSTH,cell2mat(grid(2,5)),DEFAULT.frameshiftdur);
159
+        model.txtSearchlightRadius = createTextField(pPSTH,cell2mat(grid(2,6)),DEFAULT.searchlightradius);
160
+        
161
+        % images
162
+        pImage = uipanel(parent,'Title','Image Options','Position',[0.5 0.4 0.5 0.2]);
163
+        set(pImage,'BackgroundColor','w');
164
+
165
+        createLabel(pImage,[0.0 0.5 1 0.5],'Select Image Base');
166
+        
167
+        imageRegExList = {'swrf*.IMG','wrf*.IMG'};
168
+        model.imageTypeSelection = uicontrol(pImage,'Style','popupmenu',...
169
+        'Units','normalized',...
170
+        'Position',[0.0 0.0 1 0.5],...
171
+        'String',imageRegExList,...
172
+        'UserData',imageRegExList,...
173
+        'Value',1);
174
+        set(model.imageTypeSelection,'BackgroundColor','w');
175
+        
176
+        
177
+        % coordinate Table
178
+        pVoxel = uipanel(parent,'Title','ROI','Position',[0.0 0.0 0.5 0.4]);
179
+        set(pVoxel,'BackgroundColor','w');
180
+        lVoxelDef = createLabel(pVoxel, [0 0.9 1 0.1],'<ROI Name>+[offset];');
181
+        model.txtVoxelDef = createTextField(pVoxel,[0 0 1 0.9],...
182
+            sprintf(DEFAULT.voxelstring));
183
+        set(model.txtVoxelDef,'HorizontalAlignment','left');
184
+        set(model.txtVoxelDef,'Max',20);
185
+        set(model.txtVoxelDef,'Min',0);
186
+        set(model.txtVoxelDef, 'FontName', 'FixedWidth');
187
+        
188
+        pButtons = uipanel(parent,'Position',[0.5 0.0 0.5 0.4]);
189
+        set(pButtons,'BackgroundColor','b');
190
+        
191
+        btnRunButton1 = uicontrol(pButtons,'String','run coord-Table','Units','normalized','Position',[0 0.75 1 0.2]);
192
+        set(btnRunButton1,'Callback',{@cbRunCoordTable,model}); % set here, because of model.    
193
+        
194
+        btnRunButton2 = uicontrol(pButtons,'String','run full Brain Searchlight','Units','normalized','Position',[0 0.5 1 0.2]);
195
+        set(btnRunButton2,'Callback',{@cbRunFBS,model}); % set here, because of model.    
196
+        
197
+        btnRunButton3 = uicontrol(pButtons,'String','run ROI-Image processing','Units','normalized','Position',[0 0.25 1 0.2]);
198
+        set(btnRunButton2,'Callback',{@cbRunROIImage,model}); % set here, because of model.    
199
+        set(btnRunButton3,'Enable','off');
200
+end
201
+
202
+function cbRunCoordTable(src,evnt,model)
203
+    display('RUN Coord-Table Mode');
204
+    main('COORD-LOOKUP-TABLE',model);
205
+end
206
+function cbRunROIImage(src,evnt,model)
207
+    display('RUN Image-Mask Mode');
208
+    main('ROI-IMAGE-MASK', model);
209
+end
210
+function cbRunFBS(src,evnt,model)
211
+    display('RUN Full Brain Searchlight Mode');
212
+    display('not implemented.');
213
+end
214
+
215
+
216
+function label = createLabel(parent,  pos, labelText)
217
+    label = uicontrol(parent,'Style','text','Units','normalized','String',labelText,'Position',pos);
218
+    set(label,'HorizontalAlignment','left');
219
+    set(label,'BackgroundColor','w');
220
+end
221
+
222
+function txt = createTextField(parent,pos,model)
223
+    textfieldcolor = [0.9 0.9 0.0];
224
+    txt = uicontrol(parent,'Style','edit','Units','normalized','String',model,'Position',pos);
225
+    set(txt,'BackgroundColor',textfieldcolor);
226
+end
227
+