function spm_SVMCrossVal % Initialize and hide the GUI as it is being constructed. frameWidth=450; frameHeight=450; frame = figure('Visible','off','Position',[0,0,frameWidth,frameHeight]); movegui(frame,'west'); % get this thing visible on smaller displays. set(frame,'Name','SVMCrossVal Decode Performance 4 SPM'); set(frame,'NumberTitle','off'); set(frame,'MenuBar','none'); set(frame,'Color',get(0,'defaultUicontrolBackgroundColor')); set(frame,'Resize','off'); set(frame,'Units','normalize'); optionLineHeight = 1.0/16.0; controlElementHeight=optionLineHeight*(1.0/1.5)*frameHeight; pMain = uipanel(frame,'Title','Main Panel', 'Position',[0 optionLineHeight*10 frameWidth optionLineHeight*6]); pAdvanced = uipanel(frame,'Title','Advanced Options', 'Position',[0 optionLineHeight*5 frameWidth optionLineHeight*5]); pDisplay = uipanel(frame,'Title','Display Options', 'Position',[0 optionLineHeight*1 frameWidth optionLineHeight*4]); btnRunButton = uicontrol(frame,'Tag','run','String','Run PSTH','Position',[0 optionLineHeight*0 frameWidth frameHeight/16]); %Main firstColumn = 0.00*frameWidth; secondColumn = 0.33*frameWidth; thirdColumn = 0.66*frameWidth; firstRow = 6.3*controlElementHeight; secondRow = 5.3*controlElementHeight; thirdRow = 4.3*controlElementHeight; fourthRow = 3.3*controlElementHeight; fifthRow = 2.3*controlElementHeight; sixthRow = 1.0*controlElementHeight; createLabel(pMain, [firstColumn firstRow 0.33*frameWidth controlElementHeight],'Position'); % lPosition createLabel(pMain, [firstColumn secondRow 0.33*frameWidth controlElementHeight],'Voxel Sphere Radius' );%lRadius lEvents = createLabel(pMain, [firstColumn thirdRow 0.33*frameWidth controlElementHeight],'Event List' ); lSessions = createLabel(pMain, [firstColumn fourthRow 0.33*frameWidth controlElementHeight],'Session List' ); lNormalize = createLabel(pMain, [firstColumn fifthRow 0.33*frameWidth controlElementHeight],'Normalization Method' ); lParametric = createLabel(pMain, [firstColumn sixthRow 0.25*frameWidth controlElementHeight],'Parametric Modulation'); lParametricFactor = createLabel(pMain, [(secondColumn+0.33*frameWidth*0.2) sixthRow 0.33*frameWidth*0.8 controlElementHeight],'Modulation Factor'); model.txtPosition = createTextField(pMain, [secondColumn firstRow 0.33*frameWidth controlElementHeight],'0 0 0'); btnParseHReg = createButton(pMain, [thirdColumn firstRow 0.33*frameWidth controlElementHeight],'hReg', 'parse hReg',model.txtPosition); model.txtRadius = createTextField(pMain, [secondColumn secondRow 0.33*frameWidth controlElementHeight],'3'); model.txtEvents = createTextField(pMain, [secondColumn thirdRow 0.33*frameWidth controlElementHeight],''); btnEvents = createButton(pMain, [thirdColumn thirdRow 0.33*frameWidth controlElementHeight],'events', 'show Event List',model.txtEvents); set(btnEvents,'Enable','off'); model.txtSessions = createTextField(pMain, [secondColumn fourthRow 0.33*frameWidth controlElementHeight],''); model.normalization = createDropDown(pMain, [secondColumn fifthRow 0.33*frameWidth controlElementHeight],... defaults.tools.psth4spm.normalizeSelectionModel); model.chkParametric = uicontrol(pMain,'Position',[secondColumn sixthRow 0.33*frameWidth*0.2 controlElementHeight],'Style','checkbox'); model.txtParametricMappingFactor = createTextField(pMain, [thirdColumn sixthRow 0.33*frameWidth controlElementHeight],'1.0'); set(model.txtParametricMappingFactor,'Enable','off'); set(model.chkParametric,'Callback',{@cbToggleEnableTarget,model.txtParametricMappingFactor}); %Advanced firstColumn = 0.00*frameWidth; secondColumn = 0.33*frameWidth; thirdColumn = 0.66*frameWidth; fourthColumn = 0.84*frameWidth; firstRow = 5.5*controlElementHeight; secondRow = 4.5*controlElementHeight; thirdRow = 3.5*controlElementHeight; fourthRow = 2*controlElementHeight; lStart = createLabel(pAdvanced, [secondColumn firstRow 0.33*frameWidth controlElementHeight],'Start [sec]'); lEnd = createLabel(pAdvanced, [thirdColumn firstRow 0.33*frameWidth controlElementHeight],'End [sec]'); lBaseline = createLabel(pAdvanced,[firstColumn secondRow 0.33*frameWidth controlElementHeight],'Baseline'); lTimeRange = createLabel(pAdvanced,[firstColumn thirdRow 0.33*frameWidth controlElementHeight],'Time Range (X-Axis)'); lTemporalResolutionMultiplyer = createLabel(pAdvanced, [firstColumn fourthRow 0.33*frameWidth controlElementHeight],'TR Factor'); model.txtBaselineStart = createTextField(pAdvanced,[secondColumn secondRow 0.25*frameWidth controlElementHeight],'-3.0'); model.txtBaselineEnd = createTextField(pAdvanced,[thirdColumn secondRow 0.25*frameWidth controlElementHeight],'-1.0'); model.txtTimeRangeStart = createTextField(pAdvanced,[secondColumn thirdRow 0.25*frameWidth controlElementHeight],'-5.0'); model.txtTimeRangeEnd = createTextField(pAdvanced,[thirdColumn thirdRow 0.25*frameWidth controlElementHeight],'45.0'); model.txtTemporalResolution = createTextField(pAdvanced,[thirdColumn fourthRow 0.18*frameWidth controlElementHeight],''); set(model.txtTemporalResolution,'Enable','inactive'); try tr = evalin('base','SPM.xsDes.Interscan_interval(1:end-3)'); set(model.txtTemporalResolution,'String',tr); catch btnParseTemporalResolution = createButton(pAdvanced,[fourthColumn fourthRow 0.15*frameWidth controlElementHeight],'TR','parse TR',model.txtTemporalResolution); end model.txtTemporalResolutionFactor = createTextField(pAdvanced,[secondColumn fourthRow 0.25*frameWidth controlElementHeight],'0.5'); %Display firstColumn = 0.00*frameWidth; secondColumn = 0.33*frameWidth; thirdColumn = 0.66*frameWidth; firstRow = 4*controlElementHeight; secondRow = 3*controlElementHeight; thirdRow = 2*controlElementHeight; fourthRow = 0.5*controlElementHeight; lAxisUpper = createLabel(pDisplay, [firstColumn firstRow 0.33*frameWidth controlElementHeight],'Y-Axis Upper Bound'); lAxisLower = createLabel(pDisplay, [firstColumn secondRow 0.33*frameWidth controlElementHeight],'Y-Axis Lower Bound'); lColorScheme = createLabel(pDisplay, [firstColumn thirdRow 0.33*frameWidth controlElementHeight],'Color Scheme'); lShowLegend = createLabel(pDisplay, [secondColumn+0.33*frameWidth*0.2 fourthRow 0.33*frameWidth controlElementHeight],'Show Legend'); lShowFiltered = createLabel(pDisplay, [thirdColumn+0.33*frameWidth*0.2 fourthRow 0.33*frameWidth controlElementHeight],'Show Filtered'); model.txtYAxisUpper = createTextField(pDisplay,[secondColumn firstRow 0.33*frameWidth controlElementHeight],'0'); model.txtYAxisLower = createTextField(pDisplay,[secondColumn secondRow 0.33*frameWidth controlElementHeight],'0'); model.colorScheme = createDropDown(pDisplay,[secondColumn thirdRow 0.33*frameWidth controlElementHeight],defaults.tools.psth4spm.colorschemeSelectionModel); model.chkShowLegend = uicontrol(pDisplay,'Position',[secondColumn fourthRow 0.33*frameWidth*0.1 controlElementHeight],'Style','checkbox','Value',1); model.chkShowUnfiltered = uicontrol(pDisplay,'Position',[thirdColumn fourthRow 0.33*frameWidth*0.1 controlElementHeight],'Style','checkbox','Value',1); set(btnRunButton,'Callback',{@cbRunPSTH,model}); set(frame,'Visible','on'); end % this is a function callback function cbToggleEnableTarget(src,eventData,target) if(strcmp(get(target,'Enable'),'off')) % display('is off. set on'); set(target,'Enable','on'); else % display('is on, set off'); set(target,'Enable','off'); end end function cbParseVariable(src,evnt,target) % display('button pressed'); switch(get(src,'Tag')) case 'hReg' pos = num2str(evalin('base','spm_XYZreg(''GetCoords'',hReg)')'); set(target,'String',pos); case 'TR' tr = evalin('base','SPM.xsDes.Interscan_interval(1:end-3)'); set(target,'String',tr); % set(src,'Enable','off'); set(target,'Visible','on'); otherwise display(['no parse Rule for Button Tagged' get(src,'Tag')]); end end function label = createLabel(parent, pos, labelText) label = uicontrol(parent,'Style','text','String',labelText,'Position',pos); set(label,'HorizontalAlignment','left'); set(label,'Units','characters'); % set(label,'BackgroundColor','r'); end function btn = createButton(parent,pos,tag,labelText,cbArgs) btn = uicontrol(parent,'Position',pos,'String',labelText,'tag',tag); set(btn,'Callback',{@cbParseVariable,cbArgs}); % set(btn,'BackgroundColor','b'); end function txt = createTextField(parent,pos,model) txt = uicontrol(parent,'Style','edit','String',model,'Position',pos); set(txt,'BackgroundColor','w'); end function drpField = createDropDown(parent,pos,selectionModel) drpField = uicontrol(parent,'Style','popupmenu','Position',pos); set(drpField,'String',selectionModel.Strings); set(drpField,'BackgroundColor','w'); end function cbRunPSTH(src,evnt,model) % TODO test parameter values if isSane(model) set(0,'userdata',model); % set(src,'Enable','off'); evalin('base','runPSTH4SPM(SPM)'); % set(src,'Enable','on'); else %todo error beep! error('spmtoolbox:SVMCrossVal:paramcheck','please verify all parameters'); end end