function ret = saveStudy(studyID,model)
if strcmp(studyID,'')
    ret = 0;
    return
end
display(['SAVE ' studyID]);

StudyArgs.baseDir             = getBaseDir(model);
StudyArgs.subjectSelectString = get(model.subjectSelector,'String');
StudyArgs.subjectSelectValue  = get(model.subjectSelector,'Value');

StudyArgs.classdefString      = get(model.txtClassDef,'String');

StudyArgs.pststart            = get(model.txtPSTHStart,'String');
StudyArgs.pstend              = get(model.txtPSTHEnd,'String');
StudyArgs.baselinestart       = get(model.txtBaselineStart,'String');
StudyArgs.baselineend         = get(model.txtBaselineEnd,'String');
StudyArgs.trfactor            = get(model.txtTrFactor,'String');
StudyArgs.trlabel             = get(model.labelTR,'String');

StudyArgs.imageTypeSelectionString  = get(model.imageTypeSelection,'String');
StudyArgs.imageTypeSelectionValue   = get(model.imageTypeSelection,'Value');

StudyArgs.voxelString         = get(model.txtVoxelDef,'String');

StudyArgs.selNormPSTValue     = get(model.selNormPST, 'Value');
StudyArgs.chkColBiasValue     = get(model.chkColBias, 'Value');
StudyArgs.roiGroupingValue    = get(model.selRoiGrouping, 'Value');

% %%%%%%%%%%%%%%%

StudyArgs.frameshiftstart       = get(model.txtFrameShiftStart,'String');
StudyArgs.frameshiftend         = get(model.txtFrameShiftEnd,'String');
StudyArgs.frameshiftdur         = get(model.txtFrameShiftDur,'String');

StudyArgs.timeframeGroupingValue    = get(model.selTimeframeGrouping,'Value');

StudyArgs.svmoptstring          = get(model.txtSVMopts,'String');
StudyArgs.svmnfold              = get(model.txtSVMnfold,'String');
StudyArgs.svmrnd                = get(model.chkSVMrnd,'Value');

StudyArgs.somM                  = get(model.txtSomM,'String');
StudyArgs.somN                  = get(model.txtSomN,'String');
StudyArgs.latticeModelValue     = get(model.selSomLattice,'Value');
StudyArgs.somnfold              = get(model.txtSOMnfold,'String');

StudyArgs.searchlightradius     = get(model.txtSearchlightRadius,'String');
StudyArgs.searchlightTimeline   = get(model.txtSearchlightTimeline,'String');


file = strcat(studyID,'.mat');
save(fullfile(getStudyPath,file),'-Struct','StudyArgs') ;
ret=1;
end