Search in sources :

Example 41 with FRAPStudy

use of cbit.vcell.microscopy.FRAPStudy 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 42 with FRAPStudy

use of cbit.vcell.microscopy.FRAPStudy 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 43 with FRAPStudy

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

the class FRAPBatchRunWorkspace method setSelectedROIForReactionOffRate.

// If users select reaction off rate model for batch run, the only ROI applied must be bleached ROI
public void setSelectedROIForReactionOffRate() {
    ArrayList<FRAPStudy> frapStudies = this.getFrapStudies();
    boolean[] selectedROIs = FRAPStudy.createSelectedROIsForReactionOffRateModel();
    for (FRAPStudy fStudy : frapStudies) {
        fStudy.setSelectedROIsForErrorCalculation(selectedROIs);
    }
}
Also used : FRAPStudy(cbit.vcell.microscopy.FRAPStudy)

Example 44 with FRAPStudy

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

the class FRAPBatchRunWorkspace method clearWorkingSingleWorkspace.

public void clearWorkingSingleWorkspace() {
    FRAPStudy newFrapStudy = new FRAPStudy();
    getWorkingSingleWorkspace().setFrapStudy(newFrapStudy, true, true);
    String oldString = "Before clear all";
    String newString = "After clear all";
    firePropertyChange(PROPERTY_CHANGE_BATCHRUN_DISPLAY_IMG, oldString, newString);
}
Also used : FRAPStudy(cbit.vcell.microscopy.FRAPStudy)

Example 45 with FRAPStudy

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

the class BatchRunDetailsPanel method updateViewTreeForNewBatchRunFile.

public void updateViewTreeForNewBatchRunFile(FRAPBatchRunWorkspace batchRunWorkspace) {
    frapBatchRunViewTree.clearAll();
    ArrayList<FRAPStudy> fStudyList = batchRunWorkspace.getFrapStudies();
    DefaultMutableTreeNode firstDocNode = null;
    for (int i = 0; i < fStudyList.size(); i++) {
        // update tree
        if (i == 0) {
            firstDocNode = frapBatchRunViewTree.addBatchRunDocNode(new File(fStudyList.get(i).getXmlFilename()));
        } else {
            frapBatchRunViewTree.addBatchRunDocNode(new File(fStudyList.get(i).getXmlFilename()));
        }
    }
    if (batchRunWorkspace.isBatchRunResultsAvailable()) {
        updateResultsInfo(false);
    }
    // set fist doc selected when opening a new Batch Run file
    frapBatchRunViewTree.setSelectionPath(new TreePath(firstDocNode.getPath()));
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreePath(javax.swing.tree.TreePath) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) File(java.io.File)

Aggregations

FRAPStudy (cbit.vcell.microscopy.FRAPStudy)51 Hashtable (java.util.Hashtable)19 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)18 File (java.io.File)17 ArrayList (java.util.ArrayList)13 Parameter (cbit.vcell.opt.Parameter)11 Point (java.awt.Point)8 FRAPModel (cbit.vcell.microscopy.FRAPModel)7 UserCancelException (org.vcell.util.UserCancelException)7 ImageException (cbit.image.ImageException)6 MicroscopyXmlReader (cbit.vcell.microscopy.MicroscopyXmlReader)5 FRAPData (cbit.vcell.microscopy.FRAPData)4 FRAPOptData (cbit.vcell.microscopy.FRAPOptData)4 FRAPOptFunctions (cbit.vcell.microscopy.FRAPOptFunctions)4 FileNotFoundException (java.io.FileNotFoundException)4 IOException (java.io.IOException)4 CannotUndoException (javax.swing.undo.CannotUndoException)4 PDEDataManager (cbit.vcell.simdata.PDEDataManager)3 Simulation (cbit.vcell.solver.Simulation)3 Wizard (org.vcell.wizard.Wizard)3