b8f957c57897d977ceb737a92b997aef0781fed9
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

1) function spm_SVMCrossVal
2) 
3) 
4) %  Initialize and hide the GUI as it is being constructed.
5)     frameWidth=450;
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

6)     frameHeight=600;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

7)     frame = figure('Visible','off','Position',[0,0,frameWidth,frameHeight]);
8)     movegui(frame,'west'); % get this thing visible on smaller displays.
9)     
10)     set(frame,'Name','SVMCrossVal Decode Performance 4 SPM');
11)     set(frame,'NumberTitle','off');
12)     set(frame,'MenuBar','none');
13)     set(frame,'Color',get(0,'defaultUicontrolBackgroundColor'));
14)     set(frame,'Resize','off');
15)     set(frame,'Units','normalize');
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

16)     
17)     
18)     model.subjectMap = SubjectRoiMapping;
19)     nElementRows = 24;
20)     optionLineHeight = 1.0/nElementRows;
21)     controlElementHeight=optionLineHeight*(1.0/1.5)*frameHeight;
22)     pSubject     = uipanel(frame,'Title','Subject',          'Position',[0 optionLineHeight*22 frameWidth optionLineHeight*2]);
23)     pPSTH        = uipanel(frame,'Title','PSTH Options',     'Position',[0 optionLineHeight*17 frameWidth optionLineHeight*5]); 
24)     pCLASS       = uipanel(frame,'Title','Class Definitions','Position',[0 optionLineHeight*11 frameWidth optionLineHeight*6]); 
25)     pVOXEL       = uipanel(frame,'Title','Voxel Selector',   'Position',[0 optionLineHeight*3  frameWidth optionLineHeight*8]); 
26)     pSVM         = uipanel(frame,'Title','SVM Options',      'Position',[0 optionLineHeight*1  frameWidth optionLineHeight*2]); 
27)     btnRunButton = uicontrol(frame,'Tag','run','String','run decode-performance visualiser','Position',[2 optionLineHeight*0  frameWidth controlElementHeight*1.6]);
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

28) 
29) 
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

30)     % Subject
31)     firstColumn  =  5.00;
32)     firstRow     =  1.00 * controlElementHeight;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

33)     
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

34)     model.subjectSelector = uicontrol(pSubject,'Style','popupmenu',...
35)                     'String',getSubjectCellList(model.subjectMap),...
36)                     'Value',5,...
37)                     'Position',[firstColumn firstRow 0.66*frameWidth controlElementHeight]);
38)     set(model.subjectSelector,'BackgroundColor','w');
39) 
40)     % PSTH
41)     firstColumn  = 5.00;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

42)     secondColumn = 0.33*frameWidth;
43)     thirdColumn  = 0.66*frameWidth;
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

44) %     fourthColumn = 0.84*frameWidth;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

45)     
46)     firstRow    = 5.5*controlElementHeight;
47)     secondRow   = 4.5*controlElementHeight;
48)     thirdRow    = 3.5*controlElementHeight;
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

49)     fourthRow   = 2.5*controlElementHeight;
50)     fifthRow    = 1.0*controlElementHeight;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

51)     
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

52)     lStart      = createLabel(pPSTH, [secondColumn firstRow  0.33*frameWidth controlElementHeight],'Start [sec]');
53)     lEnd        = createLabel(pPSTH, [thirdColumn  firstRow  0.33*frameWidth controlElementHeight],'End [sec]');
54)     lPSTH       = createLabel(pPSTH, [firstColumn  secondRow 0.33*frameWidth controlElementHeight],'PSTH Range');
55)     lBaseline   = createLabel(pPSTH, [firstColumn  thirdRow  0.33*frameWidth controlElementHeight],'Baseline');
56)     lFrameShift = createLabel(pPSTH, [firstColumn  fourthRow 0.33*frameWidth controlElementHeight],'SVM Frame Shift');
57)     lFramsSize  = createLabel(pPSTH, [firstColumn  fifthRow  0.33*frameWidth controlElementHeight],'SVM Frame Size');
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

58)     
59)     
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

60)     model.txtBaselineStart   = createTextField(pPSTH,[secondColumn thirdRow  0.25*frameWidth controlElementHeight],'-22.0');
61)     model.txtBaselineEnd     = createTextField(pPSTH,[thirdColumn  thirdRow  0.25*frameWidth controlElementHeight],'-20.0');
62)     model.txtPSTHStart       = createTextField(pPSTH,[secondColumn secondRow 0.25*frameWidth controlElementHeight],'-25.0');
63)     model.txtPSTHEnd         = createTextField(pPSTH,[thirdColumn  secondRow 0.25*frameWidth controlElementHeight],' 20.0');
Christoph Budziszewski GUI parsing halfway done.

Christoph Budziszewski authored 15 years ago

64)     model.txtFrameShiftStart = createTextField(pPSTH,[secondColumn fourthRow 0.25*frameWidth controlElementHeight],'-20.0');
65)     model.txtFrameShiftEnd   = createTextField(pPSTH,[thirdColumn  fourthRow 0.25*frameWidth controlElementHeight],' 15.0');
66)     model.txtFrameShiftDur   = createTextField(pPSTH,[secondColumn fifthRow  0.25*frameWidth controlElementHeight],' 0');
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

67) 
68)                 
69)     %Classes
70)     nClassRows = 6;
71)     firstColumn  = 5.00;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

72)     
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

73)     firstRow    = (nClassRows-0.5)*controlElementHeight;
74)     secondRow   = (nClassRows-4.5)*controlElementHeight;
75) 
76)     lClassDef = createLabel(pCLASS, [firstColumn firstRow  0.66*frameWidth controlElementHeight],'<Label>,<[Event,Event,..]>,<SVM-Value>;');
77)     model.txtClassDef = createTextField(pCLASS,[firstColumn secondRow 0.98*frameWidth 4*controlElementHeight],sprintf('<,\t[ 9,11,13],\t-2 ;\n>,\t[10,12,14],\t-1;'));
78)     set(model.txtClassDef,'HorizontalAlignment','left');
79)     set(model.txtClassDef,'Max',20);
80)     set(model.txtClassDef,'Min',0);
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

81)     
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

82)     %Voxel
83)     nVoxelRows = 8;
84)     firstColumn  = 5.00;
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

85)     
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

86)     firstRow    = (nVoxelRows-0.5)*controlElementHeight;
87)     secondRow   = (nVoxelRows-7.5)*controlElementHeight;
88) 
89)     lVoxelDef = createLabel(pVOXEL, [firstColumn firstRow  0.66*frameWidth controlElementHeight],'<ROI Name>,<ROI Modifier>;');
90)     model.txtVoxelDef = createTextField(pVOXEL,[firstColumn secondRow 0.98*frameWidth 6*controlElementHeight],...
91)         sprintf('M1 l,\t[ 0, 0, 0];\nM1 l,\t[ 1, 0, 0];\nM1 l,\t[ 0, 1, 0];\nM1 l,\t[ 1, 0, 1];\n'));
92)     set(model.txtVoxelDef,'HorizontalAlignment','left');
93)     set(model.txtVoxelDef,'Max',20);
94)     set(model.txtVoxelDef,'Min',0);
95)                 
96)     % SVM
97)     firstColumn  =  5.00;
98)     firstRow     =  1.00 * controlElementHeight;
99) 
100)     model.txtSVMopts = createTextField(pSVM,[firstColumn firstRow  0.66*frameWidth controlElementHeight],'-t 0 -s 0 -v 6');
101)     set(model.txtSVMopts,'Enable','inactive');
102)     set(model.txtSVMopts,'HorizontalAlignment','left');
103) 
104)     set(btnRunButton,'Callback',{@cbRunSVM,model}); % set here, because of model.    
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

105)     set(frame,'Visible','on');
106) end
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

107)     
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

108) function label = createLabel(parent,  pos, labelText)
109)     label = uicontrol(parent,'Style','text','String',labelText,'Position',pos);
110)     set(label,'HorizontalAlignment','left');
111)     set(label,'Units','characters');
112) %     set(label,'BackgroundColor','r');
113) end
114) 
115) function btn = createButton(parent,pos,tag,labelText,cbArgs)
116)     btn = uicontrol(parent,'Position',pos,'String',labelText,'tag',tag);
117)      set(btn,'Callback',{@cbParseVariable,cbArgs});
118) %     set(btn,'BackgroundColor','b');
119) end
120) 
121) function txt = createTextField(parent,pos,model)
122)     txt = uicontrol(parent,'Style','edit','String',model,'Position',pos);
123)     set(txt,'BackgroundColor','w');
124) end
125) 
126) function drpField = createDropDown(parent,pos,selectionModel)
127)  drpField = uicontrol(parent,'Style','popupmenu','Position',pos);
128)   set(drpField,'String',selectionModel.Strings);
129)   set(drpField,'BackgroundColor','w');
130) end
131) 
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

132) function sane = isSane(model)
133)     sane = 1;
134) end
135) 
136) 
137) function cbRunSVM(src,evnt,model)
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

138) 
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

139)     display('RUN');
Christoph Budziszewski SVMCrossVal toolbox init

Christoph Budziszewski authored 15 years ago

140) 
141)     % TODO test parameter values
142)     
143)     if isSane(model)
144)         set(0,'userdata',model);
145) %         set(src,'Enable','off');
Christoph Budziszewski GUI parsing halfway done.

Christoph Budziszewski authored 15 years ago

146)         assignin('base','guiParams',model);
Christoph Budziszewski gui layout finished

Christoph Budziszewski authored 15 years ago

147)         classify(model)