function main_UI(args)

%     project = args.project;
%     DEFAULT = project.default;

    % DELETE THIS
DEFAULT.selectedSubject = 1;
DEFAULT.smoothed        = 1;
DEFAULT.multisubject    = 'single';
DEFAULT.pststart        = -15;
DEFAULT.pstend          = 40;
DEFAULT.baselinestart   = -3;
DEFAULT.baselineend     = -1;
DEFAULT.frameshiftstart = -5;
DEFAULT.frameshiftend   = 35;
DEFAULT.frameshiftdur   = 0;
DEFAULT.classdefstring  = 'left,\t[9,11,13],\t -2 ;\nright,\t[10,12,14],\t -1;';
DEFAULT.voxelstring     = 'SPL l,\t[ 0, 0, 0];\nSPL r,\t[ 0, 0, 0];\n';
DEFAULT.svmoptstring    = '-s 0 -t 0 -v 6 -c 1';
    % STOP DELETE HERE

%  Initialize and hide the GUI as it is being constructed.
    frameWidth=450;
    frameHeight=600;
    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');
    
    
    savemenu = uimenu(frame,'Label','Save/Load');
    
%     model.subjectMap = SubjectRoiMapping(project);
    model.subjectMap = SubjectRoiMapping;
    
    nElementRows = 24;
    optionLineHeight = 1.0/nElementRows;
    controlElementHeight=optionLineHeight*(1.0/1.5)*frameHeight;
    pSubject     = uipanel(frame,'Title','Subject',          'Position',[0 optionLineHeight*19 frameWidth optionLineHeight*5]);
    pPSTH        = uipanel(frame,'Title','PSTH Options',     'Position',[0 optionLineHeight*14 frameWidth optionLineHeight*5]); 
    pCLASS       = uipanel(frame,'Title','Class Definitions','Position',[0 optionLineHeight*9  frameWidth optionLineHeight*5]); 
    pVOXEL       = uipanel(frame,'Title','Voxel Selector',   'Position',[0 optionLineHeight*3  frameWidth optionLineHeight*6]); 
    pSVM         = uipanel(frame,'Title','SVM Options',      'Position',[0 optionLineHeight*1  frameWidth optionLineHeight*2]); 
    btnRunButton = uicontrol(frame,'Tag','run','String','run decode-performance visualiser','Position',[2 optionLineHeight*0  frameWidth controlElementHeight*1.6]);


    % Subject
    firstColumn  =  5.00;
    firstRow     =  1.00 * controlElementHeight;
    
    model.subjectSelector = uicontrol(pSubject,'Style','listbox',...
                    'Min',1, 'Max',3,...
                    'String',getSubjectCellList(model.subjectMap),...
                    'Value',DEFAULT.selectedSubject,...  % default selected item
                    'Position',[firstColumn firstRow 0.66*frameWidth controlElementHeight*6]);
    set(model.subjectSelector,'BackgroundColor','w');
    
    createLabel(pSubject,[0.68*frameWidth firstRow*2  0.25*frameWidth controlElementHeight],'Smooth Data');
    model.txtSmoothed     = uicontrol(pSubject,'Style','checkbox','Position',[0.68*frameWidth firstRow  0.25*frameWidth controlElementHeight],'Value',DEFAULT.smoothed);

    createLabel(pSubject,[0.68*frameWidth firstRow*4  0.25*frameWidth controlElementHeight],'Crossvalidation');
    model.txtMultisubject = createTextField(pSubject,[0.68*frameWidth firstRow*3  0.25*frameWidth controlElementHeight],DEFAULT.multisubject);
    set(model.txtMultisubject,'enable','off');

    % PSTH
    firstColumn  = 5.00;
    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.5*controlElementHeight;
    fifthRow    = 1.0*controlElementHeight;
    
    lStart      = createLabel(pPSTH, [secondColumn firstRow  0.33*frameWidth controlElementHeight],'Start [sec]');
    lEnd        = createLabel(pPSTH, [thirdColumn  firstRow  0.33*frameWidth controlElementHeight],'End [sec]');
    lPSTH       = createLabel(pPSTH, [firstColumn  secondRow 0.33*frameWidth controlElementHeight],'PSTH Range');
    lBaseline   = createLabel(pPSTH, [firstColumn  thirdRow  0.33*frameWidth controlElementHeight],'Baseline');
    lFrameShift = createLabel(pPSTH, [firstColumn  fourthRow 0.33*frameWidth controlElementHeight],'SVM Frame Shift');
    lFramsSize  = createLabel(pPSTH, [firstColumn  fifthRow  0.33*frameWidth controlElementHeight],'SVM Frame Size');
    
    
    model.txtPSTHStart       = createTextField(pPSTH,[secondColumn secondRow 0.25*frameWidth controlElementHeight],DEFAULT.pststart);
    model.txtPSTHEnd         = createTextField(pPSTH,[thirdColumn  secondRow 0.25*frameWidth controlElementHeight],DEFAULT.pstend);
    model.txtBaselineStart   = createTextField(pPSTH,[secondColumn thirdRow  0.25*frameWidth controlElementHeight],DEFAULT.baselinestart);
    model.txtBaselineEnd     = createTextField(pPSTH,[thirdColumn  thirdRow  0.25*frameWidth controlElementHeight],DEFAULT.baselineend);
    model.txtFrameShiftStart = createTextField(pPSTH,[secondColumn fourthRow 0.25*frameWidth controlElementHeight],DEFAULT.frameshiftstart);
    model.txtFrameShiftEnd   = createTextField(pPSTH,[thirdColumn  fourthRow 0.25*frameWidth controlElementHeight],DEFAULT.frameshiftend);
    model.txtFrameShiftDur   = createTextField(pPSTH,[secondColumn fifthRow  0.25*frameWidth controlElementHeight],DEFAULT.frameshiftdur);

                
    %Classes
    nClassRows = 6;
    firstColumn  = 5.00;
    
    firstRow    = (nClassRows-0.5)*controlElementHeight;
    secondRow   = (nClassRows-4.5)*controlElementHeight;

    lClassDef = createLabel(pCLASS, [firstColumn firstRow  0.66*frameWidth controlElementHeight],'<Label>,<[Event,Event,..]>,<SVM-Value>;');
    model.txtClassDef = createTextField(pCLASS,[firstColumn secondRow 0.98*frameWidth 4*controlElementHeight],sprintf(DEFAULT.classdefstring));
    set(model.txtClassDef,'HorizontalAlignment','left');
    set(model.txtClassDef,'Max',20);
    set(model.txtClassDef,'Min',0);
    set(model.txtClassDef, 'FontName', 'FixedWidth')
    
    %Voxel
    nVoxelRows = 8;
    firstColumn  = 5.00;
    
    firstRow    = (nVoxelRows-0.5)*controlElementHeight;
    secondRow   = (nVoxelRows-7.5)*controlElementHeight;

    lVoxelDef = createLabel(pVOXEL, [firstColumn firstRow  0.66*frameWidth controlElementHeight],'<ROI Name>,<ROI Modifier>;');
    model.txtVoxelDef = createTextField(pVOXEL,[firstColumn secondRow 0.98*frameWidth 6*controlElementHeight],...
        sprintf(DEFAULT.voxelstring));
    set(model.txtVoxelDef,'HorizontalAlignment','left');
    set(model.txtVoxelDef,'Max',20);
    set(model.txtVoxelDef,'Min',0);
    set(model.txtVoxelDef, 'FontName', 'FixedWidth')
                
    % SVM
    firstColumn  =  5.00;
    firstRow     =  1.00 * controlElementHeight;

    model.txtSVMopts = createTextField(pSVM,[firstColumn firstRow  0.66*frameWidth controlElementHeight],DEFAULT.svmoptstring);
    %model.txtSVMopts = createTextField(pSVM,[firstColumn firstRow  0.66*frameWidth controlElementHeight],'-s 0 -t 2 -v 6 -c 10 -g .1');
    set(model.txtSVMopts,'Enable','on'); %inactive
    set(model.txtSVMopts,'HorizontalAlignment','left');

    set(btnRunButton,'Callback',{@cbRunSVM,model}); % set here, because of model.    
    uimenu(savemenu,'Label','Save','Callback',{@mcb_save,model});
    uimenu(savemenu,'Label','Load','Callback',{@mcb_load,model});

    set(frame,'Visible','on');
end

function mcb_save(src,event,model)
display('SAVE');

end

function mcb_load(src,event,model)
display('LOAD');
end

function sane = isSane(model)
% TODO
sane = 1;
end

function cbRunSVM(src,evnt,model)
    display('RUN');
    if isSane(model)
        classify(model)
    else
        error('spmtoolbox:SVMCrossVal:paramcheck','please verify all parameters');
    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