Search in sources :

Example 26 with FRAPStudy

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

the class FRAPBatchRunWorkspace method updateDisplayForTreeSelection.

public void updateDisplayForTreeSelection(Object selection) {
    String oldString = null;
    if (// doc
    displaySelection instanceof File) {
        oldString = ((File) displaySelection).getAbsolutePath();
    } else if (// results
    displaySelection instanceof String) {
        oldString = ((String) displaySelection);
    }
    displaySelection = selection;
    if (// doc
    selection instanceof File) {
        String newString = ((File) selection).getAbsolutePath();
        FRAPStudy selectedFrapStudy = getFRAPStudy(newString);
        setWorkingFRAPStudy(selectedFrapStudy);
        firePropertyChange(PROPERTY_CHANGE_BATCHRUN_DISPLAY_IMG, oldString, newString);
    } else if (// results
    selection instanceof String) {
        firePropertyChange(PROPERTY_CHANGE_BATCHRUN_DISPLAY_PARAM, oldString, (selection));
    }
}
Also used : FRAPStudy(cbit.vcell.microscopy.FRAPStudy) File(java.io.File)

Example 27 with FRAPStudy

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

the class FRAPBatchRunWorkspace method addFrapStudy.

public void addFrapStudy(FRAPStudy newFrapStudy) {
    File newFile = new File(newFrapStudy.getXmlFilename());
    ArrayList<FRAPStudy> frapStudies = getFrapStudies();
    int size = frapStudies.size();
    int insertIdx = size;
    for (int i = 0; i < size; i++) {
        File xmlFile = new File(frapStudies.get(i).getXmlFilename());
        if (newFile.getName().compareTo(xmlFile.getName()) == 0) {
            if (newFile.getAbsolutePath().compareTo(xmlFile.getAbsolutePath()) < 0) {
                insertIdx = i;
                break;
            }
        } else if (newFile.getName().compareTo(xmlFile.getName()) < 0) {
            insertIdx = i;
            break;
        }
    }
    if (insertIdx == size) {
        frapStudies.add(newFrapStudy);
    } else {
        frapStudies.add(insertIdx, newFrapStudy);
    }
    // enable save button
    VirtualFrapBatchRunFrame.enableSave(frapStudies != null && frapStudies.size() > 0);
}
Also used : FRAPStudy(cbit.vcell.microscopy.FRAPStudy) File(java.io.File)

Example 28 with FRAPStudy

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

the class FRAPBatchRunWorkspace method getSaveSingleFilesTask.

// get client task for saving single vfrap files
public AsynchClientTask getSaveSingleFilesTask() {
    AsynchClientTask saveSingleFileTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            int size = getFrapStudies().size();
            for (int i = 0; i < getFrapStudies().size(); i++) {
                FRAPStudy fStudy = getFrapStudies().get(i);
                File outFile = new File(fStudy.getXmlFilename());
                this.getClientTaskStatusSupport().setMessage("Saving file " + (i + 1) + " of " + size + " :" + outFile.getAbsolutePath() + " ...");
                saveProcedure(outFile, fStudy, this.getClientTaskStatusSupport());
            }
        }
    };
    return saveSingleFileTask;
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) File(java.io.File)

Example 29 with FRAPStudy

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

the class BatchRunDetailsPanel method actionPerformed.

public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();
    if (source == addButton) {
        // check file before loading into batch run, if the file has .vfrap extension
        // check if it has the model that is required by the batch run, if no, run the reference simulation and get the parameters
        final Wizard loadWizard = getAddFRAPDataWizard();
        if (loadWizard != null) {
            loadWizard.showModalDialog(new Dimension(550, 640));
            // code return
            if (loadWizard.getReturnCode() == Wizard.FINISH_RETURN_CODE) {
                // get newly added frapstudy
                FRAPStudy fStudy = getBatchRunWorkspace().getWorkingFrapStudy();
                // check if the batch run has results already and the newly loaded data should have same model ready
                int batchRunSelectedModel = getBatchRunWorkspace().getSelectedModel();
                if (getBatchRunWorkspace().isBatchRunResultsAvailable() && fStudy.getModels()[batchRunSelectedModel] != null && fStudy.getFrapModel(batchRunSelectedModel).getModelParameters() != null) {
                    Parameter[] parameters = fStudy.getFrapModel(batchRunSelectedModel).getModelParameters();
                    double[][] fitData = null;
                    if (batchRunSelectedModel == FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT || batchRunSelectedModel == FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS) {
                        FRAPOptData optData = fStudy.getFrapOptData();
                        // newly loaded frapstudy doesn't have estimation data ready, generate the data
                        if (optData == null) {
                            try {
                                optData = new FRAPOptData(fStudy, parameters.length, getLocalWorkspace(), fStudy.getStoredRefData());
                                fStudy.setFrapOptData(optData);
                                fitData = optData.getFitData(parameters);
                            } catch (Exception ex) {
                                ex.printStackTrace(System.out);
                                DialogUtils.showErrorDialog(BatchRunDetailsPanel.this, ex.getMessage());
                            }
                        }
                    } else if (batchRunSelectedModel == FRAPModel.IDX_MODEL_REACTION_OFF_RATE) {
                        FRAPOptFunctions optFunc = fStudy.getFrapOptFunc();
                        if (optFunc == null) {
                            try {
                                optFunc = new FRAPOptFunctions(fStudy);
                                fStudy.setFrapOptFunc(optFunc);
                                fitData = optFunc.getFitData(parameters);
                            } catch (Exception ex2) {
                                ex2.printStackTrace();
                                DialogUtils.showErrorDialog(BatchRunDetailsPanel.this, ex2.getMessage());
                            }
                        }
                    }
                    fStudy.getModels()[batchRunSelectedModel].setData(fitData);
                    // add new data into the frapStudy list in batch run.
                    getBatchRunWorkspace().addFrapStudy(fStudy);
                    // refresh the results
                    getBatchRunWorkspace().refreshBatchRunResults();
                } else // batch run has no results, simply add the frapStudy into
                {
                    getBatchRunWorkspace().addFrapStudy(fStudy);
                }
                // set save flag true when a doc has been added successfully
                getBatchRunWorkspace().setSaveNeeded(true);
                // update tree
                DefaultMutableTreeNode newNode = frapBatchRunViewTree.addBatchRunDocNode(new File(getBatchRunWorkspace().getWorkingFrapStudy().getXmlFilename()));
                // get the new tree node after sorting
                newNode = frapBatchRunViewTree.orderFRAPDocChildren(newNode);
                frapBatchRunViewTree.setSelectionPath(new TreePath(newNode.getPath()));
            } else {
                // load data unsuccessfully, remove the displayed image
                getBatchRunWorkspace().clearWorkingSingleWorkspace();
                // clear tree selection
                frapBatchRunViewTree.clearSelection();
                // clear stored tree selection
                batchRunWorkspace.clearStoredTreeSelection();
            }
        }
    } else if (source == deleteButton) {
        AsynchClientTask deleteFromWorkspaceTask = new AsynchClientTask("deleting file ...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

            public void run(Hashtable<String, Object> hashTable) throws Exception {
                // remove tree node(doc node removable only)
                DefaultMutableTreeNode parent = frapBatchRunViewTree.removeCurrentNode();
                // handle differently for doc node and results node
                if (// doc node
                parent.equals(BatchRunTree.FRAP_BATCHRUN_DOC_NODE)) {
                    // remove the data & displayed image
                    getBatchRunWorkspace().removeFrapStudy(getBatchRunWorkspace().getWorkingFrapStudy());
                } else if (// results node
                parent.equals(BatchRunTree.FRAP_BATCHRUN_RESULT_NODE)) {
                    getBatchRunWorkspace().clearResultData();
                }
                getBatchRunWorkspace().clearWorkingSingleWorkspace();
            }
        };
        AsynchClientTask deleteFromUITask = new AsynchClientTask("deleting file ...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

            public void run(Hashtable<String, Object> hashTable) throws Exception {
                // clear tree selection
                frapBatchRunViewTree.clearSelection();
                if (batchRunWorkspace.getFrapStudies() == null || batchRunWorkspace.getFrapStudies().size() < 1) {
                    frapBatchRunViewTree.clearAll();
                } else // if doc has been deleted successfully and frapStudyList still has doc, set save flag true.
                {
                    batchRunWorkspace.setSaveNeeded(true);
                }
                batchRunWorkspace.clearStoredTreeSelection();
                // clear parameter display
                clearParameterDisplay();
            }
        };
        ClientTaskDispatcher.dispatch(BatchRunDetailsPanel.this, new Hashtable<String, Object>(), new AsynchClientTask[] { deleteFromWorkspaceTask, deleteFromUITask }, false, false, false, null, true);
    } else if (source == delAllButton) {
        deleteAllBatchrunDocs();
    }
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) FRAPOptFunctions(cbit.vcell.microscopy.FRAPOptFunctions) Hashtable(java.util.Hashtable) Dimension(java.awt.Dimension) TreePath(javax.swing.tree.TreePath) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) Parameter(cbit.vcell.opt.Parameter) FRAPOptData(cbit.vcell.microscopy.FRAPOptData) Wizard(org.vcell.wizard.Wizard) File(java.io.File)

Example 30 with FRAPStudy

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

the class BatchRunResultsParamTablePanel method propertyChange.

public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals(FRAPBatchRunWorkspace.PROPERTY_CHANGE_BATCHRUN_DETAILS)) {
        int rowNum = ((Integer) evt.getNewValue()).intValue();
        String fileName = ((File) table_param.getValueAt(rowNum, BatchRunResultsParamTableModel.COLUMN_FILE_NAME)).getAbsolutePath();
        // System.out.println("FileName---" + fileName);
        FRAPStudy selectedFrapStudy = batchRunWorkspace.getFRAPStudy(fileName);
        // display estimation result for each selected frapStudy based on model type
        if (batchRunWorkspace.getSelectedModel() == FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT) {
            try {
                batchRunWorkspace.getWorkingSingleWorkspace().setFrapStudy(selectedFrapStudy, false, true);
                getOneDiffComponentPanel().setFrapWorkspace(batchRunWorkspace.getWorkingSingleWorkspace());
                getOneDiffComponentPanel().setData(selectedFrapStudy.getFrapOptData(), selectedFrapStudy.getFrapData(), selectedFrapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT].getModelParameters(), selectedFrapStudy.getFrapData().getImageDataset().getImageTimeStamps(), selectedFrapStudy.getStartingIndexForRecovery(), selectedFrapStudy.getSelectedROIsForErrorCalculation());
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            int choice = DialogUtils.showComponentOKCancelDialog(JOptionPane.getFrameForComponent(BatchRunResultsParamTablePanel.this), getOneDiffComponentPanel(), "Estimation Details for " + selectedFrapStudy.getXmlFilename());
            if (choice == JOptionPane.OK_OPTION) {
                selectedFrapStudy.getFrapModel(FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT).setModelParameters(getOneDiffComponentPanel().getCurrentParameters());
                batchRunWorkspace.refreshStatisticsData();
            }
        } else if (batchRunWorkspace.getSelectedModel() == FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS) {
            try {
                batchRunWorkspace.getWorkingSingleWorkspace().setFrapStudy(selectedFrapStudy, false, true);
                getTwoDiffComponentPanel().setFrapWorkspace(batchRunWorkspace.getWorkingSingleWorkspace());
                getTwoDiffComponentPanel().setData(selectedFrapStudy.getFrapOptData(), selectedFrapStudy.getFrapData(), selectedFrapStudy.getModels()[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS].getModelParameters(), selectedFrapStudy.getFrapData().getImageDataset().getImageTimeStamps(), selectedFrapStudy.getStartingIndexForRecovery(), selectedFrapStudy.getSelectedROIsForErrorCalculation());
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            int choice = DialogUtils.showComponentOKCancelDialog(JOptionPane.getFrameForComponent(BatchRunResultsParamTablePanel.this), getTwoDiffComponentPanel(), "Estimation Details for " + selectedFrapStudy.getXmlFilename());
            if (choice == JOptionPane.OK_OPTION) {
                selectedFrapStudy.getFrapModel(FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS).setModelParameters(getTwoDiffComponentPanel().getCurrentParameters());
                batchRunWorkspace.refreshStatisticsData();
            }
        } else if (batchRunWorkspace.getSelectedModel() == FRAPModel.IDX_MODEL_REACTION_OFF_RATE) {
            try {
                batchRunWorkspace.getWorkingSingleWorkspace().setFrapStudy(selectedFrapStudy, false, true);
                getOffRatePanel().setFrapWorkspace(batchRunWorkspace.getWorkingSingleWorkspace());
                getOffRatePanel().setData(selectedFrapStudy.getModels()[FRAPModel.IDX_MODEL_REACTION_OFF_RATE].getModelParameters(), selectedFrapStudy.getFrapData(), selectedFrapStudy.getStartingIndexForRecovery());
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            int choice = DialogUtils.showComponentOKCancelDialog(JOptionPane.getFrameForComponent(BatchRunResultsParamTablePanel.this), getOffRatePanel(), "Estimation Details for " + selectedFrapStudy.getXmlFilename());
            if (choice == JOptionPane.OK_OPTION) {
                selectedFrapStudy.getFrapModel(FRAPModel.IDX_MODEL_REACTION_OFF_RATE).setModelParameters(getOffRatePanel().getCurrentParameters());
                batchRunWorkspace.refreshStatisticsData();
            }
        }
    }
}
Also used : 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