Search in sources :

Example 6 with FRAPModel

use of cbit.vcell.microscopy.FRAPModel in project vcell by virtualcell.

the class EstParams_ReactionOffRateDescriptor method preNextProcess.

// save model parameters
public ArrayList<AsynchClientTask> preNextProcess() {
    // create AsynchClientTask arraylist
    ArrayList<AsynchClientTask> taskArrayList = new ArrayList<AsynchClientTask>();
    AsynchClientTask saveParametersTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            Parameter[] params = ((EstParams_ReactionOffRatePanel) getPanelComponent()).getCurrentParameters();
            FRAPModel frapModel = getFrapWorkspace().getWorkingFrapStudy().getFrapModel(FRAPModel.IDX_MODEL_REACTION_OFF_RATE);
            frapModel.setModelParameters(params);
            frapModel.setData(((EstParams_ReactionOffRatePanel) getPanelComponent()).getCurrentEstimationResults());
        }
    };
    taskArrayList.add(saveParametersTask);
    return taskArrayList;
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) Parameter(cbit.vcell.opt.Parameter) FRAPModel(cbit.vcell.microscopy.FRAPModel)

Example 7 with FRAPModel

use of cbit.vcell.microscopy.FRAPModel in project vcell by virtualcell.

the class EstParams_TwoDiffComponentDescriptor method saveModelParameters.

private void saveModelParameters() {
    Parameter[] params = ((EstParams_TwoDiffComponentPanel) getPanelComponent()).getCurrentParameters();
    FRAPModel frapModel = getFrapWorkspace().getWorkingFrapStudy().getFrapModel(FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS);
    frapModel.setModelParameters(params);
    frapModel.setData(((EstParams_TwoDiffComponentPanel) getPanelComponent()).getCurrentEstimationResults());
}
Also used : Parameter(cbit.vcell.opt.Parameter) FRAPModel(cbit.vcell.microscopy.FRAPModel)

Example 8 with FRAPModel

use of cbit.vcell.microscopy.FRAPModel in project vcell by virtualcell.

the class FRAPBatchRunWorkspace method getLoadSingleFilesTask.

// get client task for loading each single vfrap files in a batch run
public AsynchClientTask getLoadSingleFilesTask(LocalWorkspace arg_localWorkspace) {
    final LocalWorkspace localWorkspace = arg_localWorkspace;
    AsynchClientTask openSingleFilesTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            FRAPBatchRunWorkspace tempBatchRunWorkspace = (FRAPBatchRunWorkspace) hashTable.get(BATCH_RUN_WORKSPACE_KEY);
            if (tempBatchRunWorkspace != null) {
                ArrayList<FRAPStudy> fStudyList = tempBatchRunWorkspace.getFrapStudies();
                int size = fStudyList.size();
                for (int i = 0; i < size; i++) {
                    String fileName = fStudyList.get(i).getXmlFilename();
                    File fStudyFile = new File(fileName);
                    if (// .vfrap
                    fileName.endsWith("." + VirtualFrapLoader.VFRAP_EXTENSION) || fileName.endsWith(".xml")) {
                        this.getClientTaskStatusSupport().setMessage("Loading(.vfrap) " + (i + 1) + " of " + size + " : " + fileName);
                        FRAPStudy newFRAPStudy = null;
                        String xmlString = XmlUtil.getXMLString(fStudyFile.getAbsolutePath());
                        MicroscopyXmlReader xmlReader = new MicroscopyXmlReader(true);
                        newFRAPStudy = xmlReader.getFrapStudy(XmlUtil.stringToXML(xmlString, null).getRootElement(), this.getClientTaskStatusSupport());
                        // if((newFRAPStudy.getFrapDataExternalDataInfo() != null || newFRAPStudy.getRoiExternalDataInfo() != null) &&
                        // !FRAPWorkspace.areExternalDataOK(localWorkspace,newFRAPStudy.getFrapDataExternalDataInfo(),newFRAPStudy.getRoiExternalDataInfo()))
                        // {
                        // throw new Exception("External Files of Frap Document " + fStudyFile.getAbsolutePath() + " are corrupted");
                        // }
                        newFRAPStudy.setXmlFilename(fileName);
                        // get dimentsion reduced experimental data
                        newFRAPStudy.getDimensionReducedExpData();
                        // restore the dimension reduced fitting data(2 dimensional array).
                        int selectedModelIdx = tempBatchRunWorkspace.getSelectedModel();
                        FRAPModel frapModel = newFRAPStudy.getFrapModel(selectedModelIdx);
                        // optimization was done but data wasn't save with file, need to restore data
                        if (frapModel != null && frapModel.getModelParameters() != null && frapModel.getModelParameters().length > 0 && frapModel.getData() == null) {
                            if (frapModel.getModelIdentifer().equals(FRAPModel.MODEL_TYPE_ARRAY[FRAPModel.IDX_MODEL_REACTION_OFF_RATE])) {
                                FRAPOptFunctions frapOptFunc = new FRAPOptFunctions(newFRAPStudy);
                                newFRAPStudy.setFrapOptFunc(frapOptFunc);
                                frapModel.setData(frapOptFunc.getFitData(frapModel.getModelParameters()));
                            } else {
                                FRAPOptData optData = new FRAPOptData(newFRAPStudy, frapModel.getModelParameters().length, localWorkspace, newFRAPStudy.getStoredRefData());
                                newFRAPStudy.setFrapOptData(optData);
                                frapModel.setData(optData.getFitData(frapModel.getModelParameters()));
                            }
                        }
                        tempBatchRunWorkspace.getFrapStudies().remove(i);
                        tempBatchRunWorkspace.getFrapStudies().add(i, newFRAPStudy);
                    }
                }
                // save loaded tempBatchRunWorkspace to hashtable
                hashTable.put(BATCH_RUN_WORKSPACE_KEY, tempBatchRunWorkspace);
            }
        }
    };
    return openSingleFilesTask;
}
Also used : LocalWorkspace(cbit.vcell.microscopy.LocalWorkspace) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) FRAPOptFunctions(cbit.vcell.microscopy.FRAPOptFunctions) FRAPModel(cbit.vcell.microscopy.FRAPModel) MicroscopyXmlReader(cbit.vcell.microscopy.MicroscopyXmlReader) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) FRAPOptData(cbit.vcell.microscopy.FRAPOptData) File(java.io.File)

Example 9 with FRAPModel

use of cbit.vcell.microscopy.FRAPModel in project vcell by virtualcell.

the class FRAPBatchRunWorkspace method refreshStatisticsData.

public void refreshStatisticsData() {
    int studySize = getFrapStudies().size();
    // get parameters array (column-name and column-details should be excluded)
    // parameterVals[0] primaryDiffRates, parameterVals[1] primaryMobiles,parameterVals[2]bwmRates
    // parameterVals[3] secDiffRates,parameterVals[4] secMobiles,parameterVals[5] bs_concentration
    // parameterVals[6] reaction on rate, parameterVals[7] reacton off rate, parameterVals[8] immobile
    double[][] parameterVals = new double[BatchRunResultsParamTableModel.NUM_COLUMNS - 2][studySize];
    for (int i = 0; i < (BatchRunResultsParamTableModel.NUM_COLUMNS - 2); i++) {
        // fill all elements with 1e8 first
        Arrays.fill(parameterVals[i], FRAPOptimizationUtils.largeNumber);
    }
    for (int i = 0; i < studySize; i++) {
        FRAPStudy fStudy = getFrapStudies().get(i);
        if (selectedModel == FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT) {
            FRAPModel fModel = fStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT];
            parameterVals[0][i] = fModel.getModelParameters()[FRAPModel.INDEX_PRIMARY_DIFF_RATE].getInitialGuess();
            parameterVals[1][i] = fModel.getModelParameters()[FRAPModel.INDEX_PRIMARY_FRACTION].getInitialGuess();
            parameterVals[2][i] = fModel.getModelParameters()[FRAPModel.INDEX_BLEACH_MONITOR_RATE].getInitialGuess();
            // immobile fraction
            parameterVals[8][i] = Math.max(0, (1 - parameterVals[1][i]));
        } else if (selectedModel == FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS) {
            FRAPModel fModel = fStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS];
            parameterVals[0][i] = fModel.getModelParameters()[FRAPModel.INDEX_PRIMARY_DIFF_RATE].getInitialGuess();
            parameterVals[1][i] = fModel.getModelParameters()[FRAPModel.INDEX_PRIMARY_FRACTION].getInitialGuess();
            parameterVals[2][i] = fModel.getModelParameters()[FRAPModel.INDEX_BLEACH_MONITOR_RATE].getInitialGuess();
            parameterVals[3][i] = fModel.getModelParameters()[FRAPModel.INDEX_SECONDARY_DIFF_RATE].getInitialGuess();
            parameterVals[4][i] = fModel.getModelParameters()[FRAPModel.INDEX_SECONDARY_FRACTION].getInitialGuess();
            // immobile fraction
            parameterVals[8][i] = Math.max(0, (1 - parameterVals[1][i] - parameterVals[4][i]));
        } else if (selectedModel == FRAPModel.IDX_MODEL_REACTION_OFF_RATE) {
            FRAPModel fModel = fStudy.getModels()[FRAPModel.IDX_MODEL_REACTION_OFF_RATE];
            parameterVals[2][i] = fModel.getModelParameters()[FRAPModel.INDEX_BLEACH_MONITOR_RATE].getInitialGuess();
            parameterVals[5][i] = fModel.getModelParameters()[FRAPModel.INDEX_BINDING_SITE_CONCENTRATION].getInitialGuess();
            parameterVals[7][i] = fModel.getModelParameters()[FRAPModel.INDEX_OFF_RATE].getInitialGuess();
        }
    }
    double[][] oldStatData = statisticsData;
    // stores statistics for each parameters . (column-name and column-details should be excluded)
    statisticsData = new double[BatchRunResultsStatTableModel.NUM_STATISTICS][BatchRunResultsParamTableModel.NUM_COLUMNS - 2];
    for (int i = 0; i < BatchRunResultsStatTableModel.NUM_STATISTICS; i++) {
        // fill all elements with 1e8 first
        Arrays.fill(statisticsData[i], FRAPOptimizationUtils.largeNumber);
    }
    for (int i = 0; i < BatchRunResultsParamTableModel.NUM_COLUMNS - 2; i++) {
        // statistics for parameters exist(which is not saved as 1e8)
        if (parameterVals[i][0] != FRAPOptimizationUtils.largeNumber) {
            DescriptiveStatistics stat = DescriptiveStatistics.CreateBasicStatistics(parameterVals[i]);
            statisticsData[BatchRunResultsStatTableModel.ROW_IDX_AVERAGE][i] = stat.getMean();
            statisticsData[BatchRunResultsStatTableModel.ROW_IDX_STD][i] = stat.getStandardDeviation();
            statisticsData[BatchRunResultsStatTableModel.ROW_IDX_MEDIAN][i] = stat.getMedian();
            statisticsData[BatchRunResultsStatTableModel.ROW_IDX_MIN][i] = stat.getMin();
            statisticsData[BatchRunResultsStatTableModel.ROW_IDX_MAX][i] = stat.getMax();
        }
    }
    updateAverageParameters();
    firePropertyChange(PROPERTY_CHANGE_BATCHRUN_UPDATE_STATISTICS, oldStatData, statisticsData);
}
Also used : DescriptiveStatistics(org.vcell.util.DescriptiveStatistics) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) FRAPModel(cbit.vcell.microscopy.FRAPModel)

Example 10 with FRAPModel

use of cbit.vcell.microscopy.FRAPModel in project vcell by virtualcell.

the class FRAPStudyPanel method updateAnalysisResult.

private void updateAnalysisResult(FRAPStudy frapStudy) {
    Integer bestIdx = frapStudy.getBestModelIndex();
    clearBestModelData();
    getAnalysisResultsPanel().clearBestModelDisplay();
    if (bestIdx != null) {
        FRAPModel bestModel = frapStudy.getFrapModel(bestIdx);
        if (bestModel != null) {
            getAnalysisResultsPanel().setBestModel(bestIdx, getLocalWorkspace());
        }
    } else {
        getAnalysisResultsPanel().clearResultTable();
    }
}
Also used : FRAPModel(cbit.vcell.microscopy.FRAPModel)

Aggregations

FRAPModel (cbit.vcell.microscopy.FRAPModel)13 FRAPStudy (cbit.vcell.microscopy.FRAPStudy)7 Parameter (cbit.vcell.opt.Parameter)6 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)4 Hashtable (java.util.Hashtable)4 ArrayList (java.util.ArrayList)3 FRAPOptData (cbit.vcell.microscopy.FRAPOptData)2 FRAPOptFunctions (cbit.vcell.microscopy.FRAPOptFunctions)2 LocalWorkspace (cbit.vcell.microscopy.LocalWorkspace)1 MicroscopyXmlReader (cbit.vcell.microscopy.MicroscopyXmlReader)1 DataSource (cbit.vcell.modelopt.DataSource)1 ReferenceData (cbit.vcell.opt.ReferenceData)1 ODESolverResultSet (cbit.vcell.solver.ode.ODESolverResultSet)1 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1 File (java.io.File)1 ConfidenceInterval (org.vcell.optimization.ConfidenceInterval)1 ProfileData (org.vcell.optimization.ProfileData)1 DescriptiveStatistics (org.vcell.util.DescriptiveStatistics)1 Wizard (org.vcell.wizard.Wizard)1