Search in sources :

Example 1 with ProfileDataElement

use of org.vcell.optimization.ProfileDataElement in project vcell by virtualcell.

the class MicroscopyXmlproducer method getXML.

private static Element getXML(ProfileData profileData) {
    Element profileDataNode = new Element(MicroscopyXMLTags.ProfileDataTag);
    ArrayList<ProfileDataElement> profileDataElements = profileData.getProfileDataElements();
    for (int i = 0; i < profileDataElements.size(); i++) {
        profileDataNode.addContent(getXML(profileDataElements.get(i)));
    }
    return profileDataNode;
}
Also used : ProfileDataElement(org.vcell.optimization.ProfileDataElement) ProfileDataElement(org.vcell.optimization.ProfileDataElement) Element(org.jdom.Element)

Example 2 with ProfileDataElement

use of org.vcell.optimization.ProfileDataElement in project vcell by virtualcell.

the class FRAPOptFunctions method evaluateParameters.

// profileData array contains only two profile distribution, one for bleachWhileMonitoringRate and another for reaction off rate
public ProfileData[] evaluateParameters(Parameter[] currentParams, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    int totalParamLen = currentParams.length;
    int resultDataCounter = 0;
    ProfileData[] resultData = new ProfileData[NUM_PARAM_ESTIMATED];
    FRAPStudy frapStudy = getExpFrapStudy();
    for (int j = 0; j < totalParamLen; j++) {
        // only bleach while monitoring rate and reaction off rate need to evaluated
        if (currentParams[j] != null && (currentParams[j].getName().equals(FRAPModel.MODEL_PARAMETER_NAMES[FRAPModel.INDEX_BLEACH_MONITOR_RATE]) || currentParams[j].getName().equals(FRAPModel.MODEL_PARAMETER_NAMES[FRAPModel.INDEX_OFF_RATE]))) {
            ProfileData profileData = new ProfileData();
            // add the fixed parameter to profileData, output exp data and opt results
            Parameter[] newBestParameters = getBestParamters(frapStudy.getFrapData(), null, true);
            double iniError = getOffRateResults().getObjectiveFunctionValue();
            // fixed parameter(make sure parameter shall not be smaller than epsilon)
            Parameter fixedParam = newBestParameters[j];
            if (// log function cannot take 0 as parameter
            fixedParam.getInitialGuess() == 0) {
                fixedParam = new Parameter(fixedParam.getName(), fixedParam.getLowerBound(), fixedParam.getUpperBound(), fixedParam.getScale(), FRAPOptimizationUtils.epsilon);
            }
            if (clientTaskStatusSupport != null) {
                clientTaskStatusSupport.setMessage("<html>Evaluating confidence intervals of \'" + fixedParam.getName() + "\' <br> of finding reaction off rate model.</html>");
                // start evaluation of a parameter.
                clientTaskStatusSupport.setProgress(0);
            }
            ProfileDataElement pde = new ProfileDataElement(fixedParam.getName(), Math.log10(fixedParam.getInitialGuess()), iniError, newBestParameters);
            profileData.addElement(pde);
            // increase
            int iterationCount = 1;
            double paramLogVal = Math.log10(fixedParam.getInitialGuess());
            double lastError = iniError;
            boolean isBoundReached = false;
            double incrementStep = FRAPOptData.DEFAULT_CI_STEPS_OFF_RATE[resultDataCounter];
            int stepIncreaseCount = 0;
            while (true) {
                if (// if exceeds the maximum iterations, break;
                iterationCount > FRAPOptData.MAX_ITERATION) {
                    break;
                }
                if (isBoundReached) {
                    break;
                }
                paramLogVal = paramLogVal + incrementStep;
                double paramVal = Math.pow(10, paramLogVal);
                if (paramVal > (fixedParam.getUpperBound() - FRAPOptimizationUtils.epsilon)) {
                    paramVal = fixedParam.getUpperBound();
                    paramLogVal = Math.log10(fixedParam.getUpperBound());
                    isBoundReached = true;
                }
                Parameter increasedParam = new Parameter(fixedParam.getName(), fixedParam.getLowerBound(), fixedParam.getUpperBound(), fixedParam.getScale(), paramVal);
                // getBestParameters returns the whole set of parameters including the fixed parameters
                Parameter[] newParameters = getBestParamters(frapStudy.getFrapData(), increasedParam, true);
                double error = getOffRateResults().getObjectiveFunctionValue();
                pde = new ProfileDataElement(increasedParam.getName(), paramLogVal, error, newParameters);
                profileData.addElement(pde);
                // check if the we run enough to get confidence intervals(99% @6.635, we plus 10 over the min error)
                if (error > (iniError + 10)) {
                    break;
                }
                if (Math.abs((error - lastError) / lastError) < FRAPOptData.MIN_LIKELIHOOD_CHANGE) {
                    stepIncreaseCount++;
                    incrementStep = FRAPOptData.DEFAULT_CI_STEPS_OFF_RATE[resultDataCounter] * Math.pow(2, stepIncreaseCount);
                } else {
                    if (stepIncreaseCount > 1) {
                        incrementStep = FRAPOptData.DEFAULT_CI_STEPS_OFF_RATE[resultDataCounter] / Math.pow(2, stepIncreaseCount);
                        stepIncreaseCount--;
                    }
                }
                if (clientTaskStatusSupport.isInterrupted()) {
                    throw UserCancelException.CANCEL_GENERIC;
                }
                lastError = error;
                iterationCount++;
                clientTaskStatusSupport.setProgress((int) ((iterationCount * 1.0 / FRAPOptData.MAX_ITERATION) * 0.5 * 100));
            }
            // half way through evaluation of a parameter.
            clientTaskStatusSupport.setProgress(50);
            // decrease
            iterationCount = 1;
            paramLogVal = Math.log10(fixedParam.getInitialGuess());
            lastError = iniError;
            isBoundReached = false;
            double decrementStep = FRAPOptData.DEFAULT_CI_STEPS_OFF_RATE[resultDataCounter];
            stepIncreaseCount = 0;
            while (true) {
                if (// if exceeds the maximum iterations, break;
                iterationCount > FRAPOptData.MAX_ITERATION) {
                    break;
                }
                if (isBoundReached) {
                    break;
                }
                paramLogVal = paramLogVal - decrementStep;
                double paramVal = Math.pow(10, paramLogVal);
                // System.out.println("paramVal:" + paramVal);
                if (paramVal < (fixedParam.getLowerBound() + FRAPOptimizationUtils.epsilon)) {
                    paramVal = fixedParam.getLowerBound();
                    paramLogVal = Math.log10(FRAPOptimizationUtils.epsilon);
                    isBoundReached = true;
                }
                Parameter decreasedParam = new Parameter(fixedParam.getName(), fixedParam.getLowerBound(), fixedParam.getUpperBound(), fixedParam.getScale(), paramVal);
                // getBestParameters returns the whole set of parameters including the fixed parameters
                Parameter[] newParameters = getBestParamters(frapStudy.getFrapData(), decreasedParam, true);
                double error = getOffRateResults().getObjectiveFunctionValue();
                pde = new ProfileDataElement(decreasedParam.getName(), paramLogVal, error, newParameters);
                profileData.addElement(0, pde);
                if (error > (iniError + 10)) {
                    break;
                }
                if (Math.abs((error - lastError) / lastError) < FRAPOptData.MIN_LIKELIHOOD_CHANGE) {
                    stepIncreaseCount++;
                    decrementStep = FRAPOptData.DEFAULT_CI_STEPS_OFF_RATE[resultDataCounter] * Math.pow(2, stepIncreaseCount);
                } else {
                    if (stepIncreaseCount > 1) {
                        incrementStep = FRAPOptData.DEFAULT_CI_STEPS_OFF_RATE[resultDataCounter] / Math.pow(2, stepIncreaseCount);
                        stepIncreaseCount--;
                    }
                }
                if (clientTaskStatusSupport.isInterrupted()) {
                    throw UserCancelException.CANCEL_GENERIC;
                }
                lastError = error;
                iterationCount++;
                clientTaskStatusSupport.setProgress((int) (((iterationCount + FRAPOptData.MAX_ITERATION) * 1.0 / FRAPOptData.MAX_ITERATION) * 0.5 * 100));
            }
            resultData[resultDataCounter++] = profileData;
            // finish evaluation of a parameter
            clientTaskStatusSupport.setProgress(100);
        } else {
            continue;
        }
    }
    // this message is specifically set for batchrun, the message will stay in the status panel. It doesn't affect single run,which disappears quickly that user won't notice.
    clientTaskStatusSupport.setMessage("Evaluating confidence intervals ...");
    return resultData;
}
Also used : ProfileDataElement(org.vcell.optimization.ProfileDataElement) Parameter(cbit.vcell.opt.Parameter) ProfileData(org.vcell.optimization.ProfileData)

Example 3 with ProfileDataElement

use of org.vcell.optimization.ProfileDataElement in project vcell by virtualcell.

the class MicroscopyXmlReader method getProfileData.

private ProfileData getProfileData(Element profileDataElement) {
    ProfileData profileData = null;
    if (profileDataElement != null) {
        profileData = new ProfileData();
        @SuppressWarnings("unchecked") List<Element> profileDataElementList = profileDataElement.getChildren(MicroscopyXMLTags.ProfieDataElementTag);
        for (// loop through each profile data element
        int i = 0; // loop through each profile data element
        i < profileDataElementList.size(); // loop through each profile data element
        i++) {
            profileData.addElement(getProfileDataElement(profileDataElementList.get(i)));
        }
    }
    return profileData;
}
Also used : ProfileDataElement(org.vcell.optimization.ProfileDataElement) Element(org.jdom.Element) ProfileData(org.vcell.optimization.ProfileData)

Example 4 with ProfileDataElement

use of org.vcell.optimization.ProfileDataElement in project vcell by virtualcell.

the class RunProfileLikelihoodGeneralOp method evaluateParameters.

private ProfileData[] evaluateParameters(OptContext optContext, Parameter[] currentParams, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    // long startTime =System.currentTimeMillis();
    int totalParamLen = currentParams.length;
    ProfileData[] resultData = new ProfileData[totalParamLen];
    for (int j = 0; j < totalParamLen; j++) {
        ProfileData profileData = new ProfileData();
        // add the fixed parameter to profileData, output exp data and opt results
        Parameter[] newBestParameters = getBestParameters(optContext, currentParams, null);
        double iniError = leastError;
        // fixed parameter
        Parameter fixedParam = newBestParameters[j];
        if (// log function cannot take 0 as parameter
        fixedParam.getInitialGuess() == 0) {
            fixedParam = new Parameter(fixedParam.getName(), fixedParam.getLowerBound(), fixedParam.getUpperBound(), fixedParam.getScale(), epsilon);
        }
        if (clientTaskStatusSupport != null) {
            clientTaskStatusSupport.setMessage("<html>Evaluating confidence intervals of \'" + fixedParam.getName() + "\' <br> of model '" + optContext.getModelName() + "'.</html>");
        }
        ProfileDataElement pde = new ProfileDataElement(fixedParam.getName(), Math.log10(fixedParam.getInitialGuess()), iniError, newBestParameters);
        profileData.addElement(pde);
        Parameter[] unFixedParams = new Parameter[totalParamLen - 1];
        int indexCounter = 0;
        for (int i = 0; i < totalParamLen; i++) {
            if (!newBestParameters[i].getName().equals(fixedParam.getName())) {
                unFixedParams[indexCounter] = newBestParameters[i];
                indexCounter++;
            } else
                continue;
        }
        // increase
        int iterationCount = 1;
        double paramLogVal = Math.log10(fixedParam.getInitialGuess());
        double lastError = iniError;
        boolean isBoundReached = false;
        double incrementStep = CONFIDENCE_INTERVAL_STEP;
        int stepIncreaseCount = 0;
        while (true) {
            if (// if exceeds the maximum iterations, break;
            iterationCount > MAX_ITERATION) {
                break;
            }
            if (isBoundReached) {
                break;
            }
            paramLogVal = paramLogVal + incrementStep;
            double paramVal = Math.pow(10, paramLogVal);
            if (paramVal > (fixedParam.getUpperBound() - epsilon)) {
                paramVal = fixedParam.getUpperBound() - epsilon;
                paramLogVal = Math.log10(fixedParam.getUpperBound());
                isBoundReached = true;
            }
            Parameter increasedParam = new Parameter(fixedParam.getName(), fixedParam.getLowerBound(), fixedParam.getUpperBound(), fixedParam.getScale(), paramVal);
            // getBestParameters returns the whole set of parameters including the fixed parameters
            optContext.setFixedParameter(fixedParam, paramVal);
            Parameter[] newParameters = getBestParameters(optContext, unFixedParams, increasedParam);
            for (// use last step unfixed parameter values to optimize
            int i = 0; // use last step unfixed parameter values to optimize
            i < newParameters.length; // use last step unfixed parameter values to optimize
            i++) {
                for (int k = 0; k < unFixedParams.length; k++) {
                    if (newParameters[i].getName().equals(unFixedParams[k].getName())) {
                        Parameter tempParameter = new Parameter(unFixedParams[k].getName(), unFixedParams[k].getLowerBound(), unFixedParams[k].getUpperBound(), unFixedParams[k].getScale(), newParameters[i].getInitialGuess());
                        unFixedParams[k] = tempParameter;
                    }
                }
            }
            double error = leastError;
            pde = new ProfileDataElement(increasedParam.getName(), paramLogVal, error, newParameters);
            profileData.addElement(pde);
            // check if the we run enough to get confidence intervals(99% @6.635, we plus 10 over the min error)
            if (error > (iniError + 10)) {
                break;
            }
            if (Math.abs((error - lastError) / lastError) < MIN_LIKELIHOOD_CHANGE) {
                stepIncreaseCount++;
                incrementStep = CONFIDENCE_INTERVAL_STEP * Math.pow(2, stepIncreaseCount);
            } else {
                if (stepIncreaseCount > 1) {
                    incrementStep = CONFIDENCE_INTERVAL_STEP / Math.pow(2, stepIncreaseCount);
                    stepIncreaseCount--;
                }
            }
            if (clientTaskStatusSupport != null && clientTaskStatusSupport.isInterrupted()) {
                throw UserCancelException.CANCEL_GENERIC;
            }
            lastError = error;
            iterationCount++;
            if (clientTaskStatusSupport != null) {
                clientTaskStatusSupport.setProgress((int) ((iterationCount * 1.0 / MAX_ITERATION) * 0.5 * 100));
            }
        }
        if (clientTaskStatusSupport != null) {
            // half way through evaluation of a parameter.
            clientTaskStatusSupport.setProgress(50);
        }
        // decrease
        iterationCount = 1;
        paramLogVal = Math.log10(fixedParam.getInitialGuess());
        ;
        ;
        lastError = iniError;
        isBoundReached = false;
        double decrementStep = incrementStep;
        stepIncreaseCount = 0;
        while (true) {
            if (// if exceeds the maximum iterations, break;
            iterationCount > MAX_ITERATION) {
                break;
            }
            if (isBoundReached) {
                break;
            }
            paramLogVal = paramLogVal - decrementStep;
            double paramVal = Math.pow(10, paramLogVal);
            if (paramVal < (fixedParam.getLowerBound() + epsilon)) {
                paramVal = fixedParam.getLowerBound() + epsilon;
                paramLogVal = Math.log10(epsilon);
                isBoundReached = true;
            }
            Parameter decreasedParam = new Parameter(fixedParam.getName(), fixedParam.getLowerBound(), fixedParam.getUpperBound(), fixedParam.getScale(), paramVal);
            // getBestParameters returns the whole set of parameters including the fixed parameters
            optContext.setFixedParameter(fixedParam, paramVal);
            Parameter[] newParameters = getBestParameters(optContext, unFixedParams, decreasedParam);
            for (// use last step unfixed parameter values to optimize
            int i = 0; // use last step unfixed parameter values to optimize
            i < newParameters.length; // use last step unfixed parameter values to optimize
            i++) {
                for (int k = 0; k < unFixedParams.length; k++) {
                    if (newParameters[i].getName().equals(unFixedParams[k].getName())) {
                        Parameter tempParameter = new Parameter(unFixedParams[k].getName(), unFixedParams[k].getLowerBound(), unFixedParams[k].getUpperBound(), unFixedParams[k].getScale(), newParameters[i].getInitialGuess());
                        unFixedParams[k] = tempParameter;
                    }
                }
            }
            double error = leastError;
            pde = new ProfileDataElement(decreasedParam.getName(), paramLogVal, error, newParameters);
            profileData.addElement(0, pde);
            if (error > (iniError + 10)) {
                break;
            }
            if (Math.abs((error - lastError) / lastError) < MIN_LIKELIHOOD_CHANGE) {
                stepIncreaseCount++;
                decrementStep = CONFIDENCE_INTERVAL_STEP * Math.pow(2, stepIncreaseCount);
            } else {
                if (stepIncreaseCount > 1) {
                    incrementStep = CONFIDENCE_INTERVAL_STEP / Math.pow(2, stepIncreaseCount);
                    stepIncreaseCount--;
                }
            }
            if (clientTaskStatusSupport != null && clientTaskStatusSupport.isInterrupted()) {
                throw UserCancelException.CANCEL_GENERIC;
            }
            lastError = error;
            iterationCount++;
            if (clientTaskStatusSupport != null) {
                clientTaskStatusSupport.setProgress((int) (((iterationCount + MAX_ITERATION) * 1.0 / MAX_ITERATION) * 0.5 * 100));
            }
        }
        resultData[j] = profileData;
        if (clientTaskStatusSupport != null) {
            // finish evaluation of a parameter
            clientTaskStatusSupport.setProgress(100);
        }
    }
    optContext.clearFixedParameter();
    // this message is specifically set for batchrun, the message will stay in the status panel. It doesn't affect single run,which disappears quickly that user won't notice.
    if (clientTaskStatusSupport != null) {
        clientTaskStatusSupport.setMessage("Evaluating confidence intervals ...");
    }
    // System.out.println("total time used:" + (endTime - startTime));
    return resultData;
}
Also used : ProfileDataElement(org.vcell.optimization.ProfileDataElement) Parameter(cbit.vcell.opt.Parameter) ProfileData(org.vcell.optimization.ProfileData)

Example 5 with ProfileDataElement

use of org.vcell.optimization.ProfileDataElement in project vcell by virtualcell.

the class FRAPParamTest method runProfileLikelihood.

public void runProfileLikelihood() {
    String errorMsg = checkFrapStudyValidity();
    if (!errorMsg.equals("")) {
        System.out.println("Application terminated due to " + errorMsg);
        System.exit(1);
    } else {
        try {
            ClientTaskStatusSupport ctss = new ClientTaskStatusSupport() {

                public void setProgress(int progress) {
                    System.out.println(progress);
                }

                public void setMessage(String message) {
                    System.out.println(message);
                }

                public boolean isInterrupted() {
                    // TODO Auto-generated method stub
                    return false;
                }

                public int getProgress() {
                    // TODO Auto-generated method stub
                    return 0;
                }

                public void addProgressDialogListener(ProgressDialogListener progressDialogListener) {
                    throw new RuntimeException("not yet implemented");
                }
            };
            // get startign index
            if (frapStudy.getStartingIndexForRecovery() == null) {
                int index = FRAPDataAnalysis.calculateRecoveryIndex(frapStudy.getFrapData());
                frapStudy.setStartingIndexForRecovery(index);
            }
            // get dependent rois
            if (frapStudy.getFrapData().getRois().length < 4) {
                frapStudy.refreshDependentROIs();
            }
            // get selected ROIs
            if (frapStudy.getSelectedROIsForErrorCalculation() == null) {
                boolean[] selectedROIs = new boolean[FRAPData.VFRAP_ROI_ENUM.values().length];
                int counter = 0;
                for (FRAPData.VFRAP_ROI_ENUM roiEnum : FRAPData.VFRAP_ROI_ENUM.values()) {
                    if (roiEnum.name().equals(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name()) || roiEnum.name().equals(FRAPData.VFRAP_ROI_ENUM.ROI_BACKGROUND.name())) {
                        counter++;
                        continue;
                    }
                    if (frapStudy.getFrapData().getRoi(roiEnum.name()).getNonzeroPixelsCount() > 0) {
                        selectedROIs[counter] = true;
                        counter++;
                    }
                }
                frapStudy.setSelectedROIsForErrorCalculation(selectedROIs);
            }
            // get frap opt data
            if (frapStudy.getFrapOptData() == null) {
                if (!FRAPWorkspace.areExternalDataOK(getLocalWorkspace(), frapStudy.getFrapDataExternalDataInfo(), frapStudy.getRoiExternalDataInfo())) {
                    // if external files are missing/currupt or ROIs are changed, create keys and save them
                    frapStudy.setFrapDataExternalDataInfo(FRAPStudy.createNewExternalDataInfo(localWorkspace, FRAPStudy.IMAGE_EXTDATA_NAME));
                    frapStudy.setRoiExternalDataInfo(FRAPStudy.createNewExternalDataInfo(localWorkspace, FRAPStudy.ROI_EXTDATA_NAME));
                    frapStudy.saveROIsAsExternalData(localWorkspace, frapStudy.getRoiExternalDataInfo().getExternalDataIdentifier(), frapStudy.getStartingIndexForRecovery());
                    frapStudy.saveImageDatasetAsExternalData(localWorkspace, frapStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier(), frapStudy.getStartingIndexForRecovery());
                }
                // run ref sim
                frapStudy.setFrapOptData(new FRAPOptData(frapStudy, FRAPModel.NUM_MODEL_PARAMETERS_ONE_DIFF, localWorkspace, ctss));
            }
            FRAPOptData optData = frapStudy.getFrapOptData();
            // create frapModels
            if (frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT] == null) {
                frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT] = new FRAPModel(FRAPModel.MODEL_TYPE_ARRAY[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT], null, null, null);
                if (frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT].getModelParameters() == null) {
                    frapStudy.getFrapOptData().setNumEstimatedParams(FRAPModel.NUM_MODEL_PARAMETERS_ONE_DIFF);
                    Parameter[] initialParams = FRAPModel.getInitialParameters(frapStudy.getFrapData(), FRAPModel.MODEL_TYPE_ARRAY[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT], frapStudy.getStartingIndexForRecovery());
                    Parameter[] bestParameters = frapStudy.getFrapOptData().getBestParamters(initialParams, frapStudy.getSelectedROIsForErrorCalculation());
                    frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT].setModelParameters(bestParameters);
                }
            }
            if (frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS] == null) {
                frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS] = new FRAPModel(FRAPModel.MODEL_TYPE_ARRAY[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS], null, null, null);
                if (frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS].getModelParameters() == null) {
                    frapStudy.getFrapOptData().setNumEstimatedParams(FRAPModel.NUM_MODEL_PARAMETERS_TWO_DIFF);
                    Parameter[] initialParams = FRAPModel.getInitialParameters(frapStudy.getFrapData(), FRAPModel.MODEL_TYPE_ARRAY[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS], frapStudy.getStartingIndexForRecovery());
                    Parameter[] bestParameters = frapStudy.getFrapOptData().getBestParamters(initialParams, frapStudy.getSelectedROIsForErrorCalculation());
                    frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS].setModelParameters(bestParameters);
                }
            }
            // try diffusion with one diffusing component model
            System.out.println("Evaluating parameters in diffusion with one diffusing compoent model...");
            Parameter[] bestParameters = frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT].getModelParameters();
            ProfileData[] profileData = optData.evaluateParameters(bestParameters, ctss);
            // output profile likelihood
            File outputDir_oneComponent = new File(getLocalWorkspace().getDefaultWorkspaceDirectory() + SUB_DIRECTORY + "OneComponent_SAVED_AT_" + BeanUtils.generateDateTimeString() + System.getProperty("file.separator"));
            if (!outputDir_oneComponent.exists()) {
                outputDir_oneComponent.mkdirs();
            }
            for (int i = 0; i < profileData.length; i++) {
                ProfileDataElement profileDataElement = profileData[i].getProfileDataElements().get(0);
                outputProfileLikelihood(profileData[i].getProfileDataElements(), profileDataElement.getParamName(), outputDir_oneComponent);
            }
            // try diffusion with two diffusing components model
            System.out.println("Evaluating parameters in diffusion with two diffusing compoents model...");
            bestParameters = frapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS].getModelParameters();
            profileData = optData.evaluateParameters(bestParameters, ctss);
            // output profile likelihood
            File outputDir_twoComponents = new File(getLocalWorkspace().getDefaultWorkspaceDirectory() + SUB_DIRECTORY + "TwoComponents_SAVED_AT_" + BeanUtils.generateDateTimeString() + System.getProperty("file.separator"));
            if (!outputDir_twoComponents.exists()) {
                outputDir_twoComponents.mkdirs();
            }
            for (int i = 0; i < profileData.length; i++) {
                ProfileDataElement profileDataElement = profileData[i].getProfileDataElements().get(0);
                outputProfileLikelihood(profileData[i].getProfileDataElements(), profileDataElement.getParamName(), outputDir_twoComponents);
            }
        } catch (Exception e) {
            e.printStackTrace(System.out);
            System.exit(1);
        }
    }
}
Also used : ProfileData(org.vcell.optimization.ProfileData) Point(java.awt.Point) IOException(java.io.IOException) ProgressDialogListener(org.vcell.util.ProgressDialogListener) ProfileDataElement(org.vcell.optimization.ProfileDataElement) ClientTaskStatusSupport(org.vcell.util.ClientTaskStatusSupport) Parameter(cbit.vcell.opt.Parameter) File(java.io.File)

Aggregations

ProfileDataElement (org.vcell.optimization.ProfileDataElement)10 Parameter (cbit.vcell.opt.Parameter)8 ProfileData (org.vcell.optimization.ProfileData)5 Element (org.jdom.Element)4 Plot2D (cbit.plot.Plot2D)2 PlotData (cbit.plot.PlotData)2 ConfidenceInterval (org.vcell.optimization.ConfidenceInterval)2 ProfileSummaryData (org.vcell.optimization.ProfileSummaryData)2 DescriptiveStatistics (org.vcell.util.DescriptiveStatistics)2 Point (java.awt.Point)1 File (java.io.File)1 IOException (java.io.IOException)1 ClientTaskStatusSupport (org.vcell.util.ClientTaskStatusSupport)1 ProgressDialogListener (org.vcell.util.ProgressDialogListener)1