private/ui_createStudy.m
9e39a52b
 function ui_createStudy(menu,uimodel)
     frameWidth=300;
     frameHeight=200;
4b81e19c
     
9e39a52b
     frame = figure('Visible','on','Position',[0,0,frameWidth,frameHeight]);
     movegui(frame,'center'); % get this thing visible on smaller displays.
4b81e19c
     set(frame,'Name','Create Study');
     set(frame,'NumberTitle','off');
     set(frame,'MenuBar','none');
 %     set(frame,'Color',get(0,'defaultUicontrolBackgroundColor'));
     set(frame,'Resize','on');
     set(frame,'Units','normalized');
     set(frame,'Color','y');
 
     
9e39a52b
     study= struct();
     % name
     namelabel = createLabel(frame,[0 0.6 1 0.1],'Identifier for new study (the name):');
     study.name = createTextField(frame,[0 0.5 1 .1],'');
     % base-dir
     dirlabel = createLabel(frame,[0 0.4 1 0.1],'Full path to the directory containing the data:');
     study.basedir = createTextField(frame,[0 0.3 1 .1],'');
     
     %fertig-button
         btnSwitchPreprocessing = uicontrol(frame,'Style','pushbutton',...
             'String','create',...
             'Units','normalized','Position',[0.0 0.0 1 0.1]);
         set(btnSwitchPreprocessing,'Callback',{@cbCreateStudy,study,frame,uimodel,menu}); 
         set(btnSwitchPreprocessing,'Enable','on');
     
 end
 
 function uimodel = cbCreateStudy(src,evnt,study,window,uimodel,menu)
 % global SVMCROSSVAL_STUDYDIR;
 disp('Creating new Study');
 if strcmp(get(study.name,'String'),'') || strcmp(get(study.basedir,'String'),'')
     error('spm_SVMCrossVal:createStudy','please provide Name and Path');
 end
 studyID = get(study.name,'String');
 baseDir = get(study.basedir,'String');
 
 set(uimodel.txtBaseDir,'String',baseDir);
 set(uimodel.txtStudyID,'String',studyID);
 
 StudyArgs.subjectSelectString = listDirNames(baseDir);
 StudyArgs.subjectSelectValue = 1;
 set(uimodel.subjectSelector,'String',StudyArgs.subjectSelectString);
 set(uimodel.subjectSelector,'UserData',StudyArgs.subjectSelectString);
 set(uimodel.subjectSelector,'Value',StudyArgs.subjectSelectValue);
 
 StudyArgs.imageTypeSelectionString = imageMaskNames(fullfile(baseDir,cell2mat(StudyArgs.subjectSelectString(StudyArgs.subjectSelectValue))));
 StudyArgs.imageTypeSelectionValue = 1;
 set(uimodel.imageTypeSelection, 'String'  ,StudyArgs.imageTypeSelectionString);
 set(uimodel.imageTypeSelection, 'UserData',StudyArgs.imageTypeSelectionString);
 set(uimodel.imageTypeSelection, 'Value'   ,StudyArgs.imageTypeSelectionValue);
 
 % des = 
 % tr = des.xsDes.Interscan_interval(1:end-3);
 StudyArgs.trlabel = '2';
 set(uimodel.labelTR, 'String',sprintf(StudyArgs.trlabel));
  
 studyfile = [studyID '.mat'];
 saveStudy(studyID,uimodel);
 addStudyToMenu(menu,studyfile,uimodel);
 close(window);
4b81e19c
 end