Search in sources :

Example 21 with FRAPStudy

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

the class LoadFRAPData_PostProcessingDataDescriptor method preNextProcess.

public ArrayList<AsynchClientTask> preNextProcess() {
    final String LOADING_MESSAGE = "Loading variable data " + postProcessingDataPanel.getSelectedVariableName() + "...";
    AsynchClientTask updateUIBeforeLoadTask = new AsynchClientTask("Updating status message...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            if (postProcessingDataPanel.getSelectedVariableName() == null || postProcessingDataPanel.getSelectedDataManager() == null) {
                throw new RuntimeException("Post Processing Data variable not selected");
            }
            VirtualFrapMainFrame.updateStatus(LOADING_MESSAGE);
        }
    };
    AsynchClientTask loadTask = new AsynchClientTask(LOADING_MESSAGE, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            String selectedVariableName = postProcessingDataPanel.getSelectedVariableName();
            int selectedSlice = postProcessingDataPanel.getSelectedSlice();
            DataProcessingOutputInfo dataProcessingOutputInfo = postProcessingDataPanel.getSelectedDataProcessingOutputInfo();
            PDEDataManager pdeDataManager = postProcessingDataPanel.getSelectedDataManager();
            DataOperationResults.DataProcessingOutputDataValues dataProcessingOutputDataValues = (DataOperationResults.DataProcessingOutputDataValues) pdeDataManager.doDataOperation(new DataOperation.DataProcessingOutputDataValuesOP(pdeDataManager.getVCDataIdentifier(), selectedVariableName, TimePointHelper.createAllTimeTimePointHelper(), DataIndexHelper.createSliceDataIndexHelper(selectedSlice), null, null));
            ArrayList<SourceDataInfo> sdiArr = dataProcessingOutputDataValues.createSourceDataInfos(dataProcessingOutputInfo.getVariableISize(selectedVariableName), dataProcessingOutputInfo.getVariableOrigin(selectedVariableName), dataProcessingOutputInfo.getVariableExtent(selectedVariableName));
            FRAPStudy newFRAPStudy = FRAPWorkspace.loadFRAPDataFromDataProcessingOutput(sdiArr, dataProcessingOutputInfo.getVariableTimePoints(), 0, /*data already sliced*/
            65535.0, this.getClientTaskStatusSupport());
            isFileLoaded = true;
            hashTable.put(FRAPStudyPanel.NEW_FRAPSTUDY_KEY, newFRAPStudy);
        }
    };
    AsynchClientTask afterLoadingSwingTask = new AsynchClientTask("Setting FrapWorkspace FrapStudy...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            FRAPStudy newFRAPStudy = (FRAPStudy) hashTable.get(FRAPStudyPanel.NEW_FRAPSTUDY_KEY);
            // setFrapStudy fires property change, so we have to put it in Swing thread.
            getFrapWorkspace().setFrapStudy(newFRAPStudy, true);
            VirtualFrapLoader.mf.setMainFrameTitle("");
            VirtualFrapMainFrame.updateProgress(0);
            if (isFileLoaded) {
                VirtualFrapMainFrame.updateStatus("Loaded " + postProcessingDataPanel.getSelectedVariableName());
            } else {
                VirtualFrapMainFrame.updateStatus("Failed loading " + postProcessingDataPanel.getSelectedVariableName() + ".");
            }
        }
    };
    ArrayList<AsynchClientTask> tasks = new ArrayList<AsynchClientTask>();
    tasks.add(updateUIBeforeLoadTask);
    tasks.add(loadTask);
    tasks.add(afterLoadingSwingTask);
    return tasks;
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) SourceDataInfo(cbit.image.SourceDataInfo) PDEDataManager(cbit.vcell.simdata.PDEDataManager) DataProcessingOutputInfo(cbit.vcell.simdata.DataOperationResults.DataProcessingOutputInfo) DataOperationResults(cbit.vcell.simdata.DataOperationResults) FRAPStudy(cbit.vcell.microscopy.FRAPStudy)

Example 22 with FRAPStudy

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

the class LoadFRAPData_SingleFileDescriptor method preNextProcess.

// load the data before the panel disappears
public ArrayList<AsynchClientTask> preNextProcess() {
    // create AsynchClientTask arraylist
    ArrayList<AsynchClientTask> taskArrayList = new ArrayList<AsynchClientTask>();
    if (singleFilePanel.getFileName().length() > 0) {
        final String fileStr = singleFilePanel.getFileName();
        final String LOADING_MESSAGE = "Loading " + fileStr + "...";
        AsynchClientTask updateUIBeforeLoadTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

            public void run(Hashtable<String, Object> hashTable) throws Exception {
                VirtualFrapMainFrame.updateStatus(LOADING_MESSAGE);
            }
        };
        AsynchClientTask loadTask = new AsynchClientTask(LOADING_MESSAGE, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

            public void run(Hashtable<String, Object> hashTable) throws Exception {
                FRAPStudy newFRAPStudy = null;
                File inFile = new File(fileStr);
                if (inFile != null) {
                    if (// .log (vcell log file)
                    inFile.getName().endsWith(SimDataConstants.LOGFILE_EXTENSION)) {
                        DataIdentifier[] dataIdentifiers = FrapDataUtils.getDataIdentiferListFromVCellSimulationData(inFile, 0);
                        ArrayList<String> selectedIdentifiers = new ArrayList<String>();
                        for (int i = 0; i < dataIdentifiers.length; i++) {
                            if (dataIdentifiers[i].getVariableType().equals(VariableType.VOLUME)) {
                                selectedIdentifiers.add(dataIdentifiers[i].getName());
                            }
                        }
                        String[][] rowData = new String[selectedIdentifiers.size()][1];
                        for (int i = 0; i < selectedIdentifiers.size(); i++) {
                            rowData[i][0] = selectedIdentifiers.get(i);
                        }
                        int[] selectedIndexArr = DialogUtils.showComponentOKCancelTableList(LoadFRAPData_SingleFileDescriptor.this.getPanelComponent(), "Select Volume Variable", new String[] { "Volume Variable Name" }, rowData, ListSelectionModel.SINGLE_SELECTION);
                        if (selectedIndexArr != null && selectedIndexArr.length > 0) {
                            scalePanel = getScalePanelForLoadingLogFile();
                            int choice = DialogUtils.showComponentOKCancelDialog(LoadFRAPData_SingleFileDescriptor.this.getPanelComponent(), scalePanel, "Input image maximum intensity (max: 65535)");
                            if (choice == JOptionPane.OK_OPTION) {
                                Double maxIntensity = null;
                                if (scalePanel.getInputScaleString() != null) {
                                    maxIntensity = new Double(scalePanel.getInputScaleString());
                                }
                                newFRAPStudy = FRAPWorkspace.loadFRAPDataFromVcellLogFile(inFile, selectedIdentifiers.get(selectedIndexArr[0]), null, maxIntensity, true, this.getClientTaskStatusSupport());
                                isFileLoaded = true;
                            } else {
                                throw UserCancelException.CANCEL_GENERIC;
                            }
                        } else {
                            throw UserCancelException.CANCEL_GENERIC;
                        }
                    } else if (inFile.getName().endsWith(SimDataConstants.DATA_PROCESSING_OUTPUT_EXTENSION_HDF5)) {
                        scalePanel = getScalePanelForLoadingLogFile();
                        int choice = DialogUtils.showComponentOKCancelDialog(LoadFRAPData_SingleFileDescriptor.this.getPanelComponent(), scalePanel, "Input data maximum value (max: 65535) which is used to avoid losing double precision when casting it to short.");
                        if (choice == JOptionPane.OK_OPTION) {
                            Double maxIntensity = null;
                            if (scalePanel.getInputScaleString() != null) {
                                maxIntensity = new Double(scalePanel.getInputScaleString());
                            }
                            newFRAPStudy = FRAPWorkspace.loadFRAPDataFromHDF5File(inFile, maxIntensity, this.getClientTaskStatusSupport());
                            isFileLoaded = true;
                        } else {
                            throw UserCancelException.CANCEL_GENERIC;
                        }
                    } else // .lsm or other image formatss
                    {
                        newFRAPStudy = FRAPWorkspace.loadFRAPDataFromImageFile(inFile, this.getClientTaskStatusSupport());
                        isFileLoaded = true;
                    }
                } else {
                    throw new RuntimeException("Input file is null.");
                }
                // for all loaded file
                hashTable.put(FRAPStudyPanel.NEW_FRAPSTUDY_KEY, newFRAPStudy);
            }
        };
        AsynchClientTask afterLoadingSwingTask = new AsynchClientTask(LOADING_MESSAGE, AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

            public void run(Hashtable<String, Object> hashTable) throws Exception {
                FRAPStudy newFRAPStudy = (FRAPStudy) hashTable.get(FRAPStudyPanel.NEW_FRAPSTUDY_KEY);
                // setFrapStudy fires property change, so we have to put it in Swing thread.
                getFrapWorkspace().setFrapStudy(newFRAPStudy, true);
                VirtualFrapLoader.mf.setMainFrameTitle("");
                VirtualFrapMainFrame.updateProgress(0);
                if (isFileLoaded) {
                    VirtualFrapMainFrame.updateStatus("Loaded " + fileStr);
                } else {
                    VirtualFrapMainFrame.updateStatus("Failed loading " + fileStr + ".");
                }
            }
        };
        taskArrayList.add(updateUIBeforeLoadTask);
        taskArrayList.add(loadTask);
        taskArrayList.add(afterLoadingSwingTask);
    } else {
        DialogUtils.showErrorDialog(singleFilePanel, "Load File name is empty. Please input a file name to continue.");
        throw new RuntimeException("Load File name is empty. Please input a file name to continue.");
    }
    return taskArrayList;
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) DataIdentifier(cbit.vcell.simdata.DataIdentifier) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) File(java.io.File)

Example 23 with FRAPStudy

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

the class ChooseModel_ModelTypesDescriptor method preNextProcess.

public ArrayList<AsynchClientTask> preNextProcess() {
    ArrayList<AsynchClientTask> tasks = new ArrayList<AsynchClientTask>();
    AsynchClientTask aTask1 = new AsynchClientTask("Saving selected model types...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            FRAPStudy fStudy = frapWorkspace.getWorkingFrapStudy();
            if (fStudy == null) {
                throw new Exception("FRAPStudy is null. Please load data.");
            }
            boolean[] models = modelTypesPanel.getModelTypes();
            // perform checkings...is one selected, is koffRatemodel selected(in this case force to use bleached ROI only)
            if (modelTypesPanel.getNumUserSelectedModelTypes() < 1) {
                throw new Exception("At least one model type has to be selected.");
            }
            // if reaction dominant off rate model is selected, we have to make sure that the bleached ROI should be selected.
            if (models[FRAPModel.IDX_MODEL_REACTION_OFF_RATE] && !fStudy.getSelectedROIsForErrorCalculation()[FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.ordinal()]) {
                String choice = DialogUtils.showWarningDialog(modelTypesPanel, "To evaluate Reaction Dominant Off Rate model, bleached ROI must be selected. \n\nSelecte 'Continue' to have bleached ROI automatically added and proceed. Or,\nSelecte 'Cancel' to stop proceeding.", new String[] { UserMessage.OPTION_CONTINUE, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_CONTINUE);
                if (choice.equals(UserMessage.OPTION_CONTINUE)) {
                    fStudy.getSelectedROIsForErrorCalculation()[FRAPData.VFRAP_ROI_ENUM.ROI_BLEACHED.ordinal()] = true;
                } else {
                    throw UserCancelException.CANCEL_GENERIC;
                }
            }
            // update selected models in FrapStudy
            fStudy.refreshModels(models);
        }
    };
    tasks.add(aTask1);
    return tasks;
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) UserCancelException(org.vcell.util.UserCancelException)

Example 24 with FRAPStudy

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

the class ChooseModel_ModelTypesDescriptor method aboutToDisplayPanel.

public void aboutToDisplayPanel() {
    FRAPStudy fStudy = frapWorkspace.getWorkingFrapStudy();
    // if there are models selected and saved, load the model types. otherwise, apply default(diffusion with one component is selected).
    if (fStudy.getModels() != null && fStudy.getModels().length > 0 && fStudy.getSelectedModels().size() > 0) {
        modelTypesPanel.clearAllSelected();
        FRAPModel[] models = fStudy.getModels();
        if (models[FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT] != null) {
            modelTypesPanel.setDiffOneSelected(true);
        }
        if (models[FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS] != null) {
            modelTypesPanel.setDiffTwoSelected(true);
        }
        if (models[FRAPModel.IDX_MODEL_REACTION_OFF_RATE] != null) {
            modelTypesPanel.setReactionOffRateSelected(true);
        }
    } else // new frap document
    {
        modelTypesPanel.clearAllSelected();
        modelTypesPanel.setDiffOneSelected(true);
    }
}
Also used : FRAPStudy(cbit.vcell.microscopy.FRAPStudy) FRAPModel(cbit.vcell.microscopy.FRAPModel)

Example 25 with FRAPStudy

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

the class BatchRunXmlProducer method getXML.

/**
 * This method returns a XML representation
 * for a frap batch run including
 */
private static Element getXML(FRAPBatchRunWorkspace param) throws XmlParseException, cbit.vcell.parser.ExpressionException {
    Element batchRunNode = new Element(MicroscopyXMLTags.FrapBatchRunTag);
    // Get selected model index
    Element selectedModelIdxElem = new Element(MicroscopyXMLTags.BatchRunSelectedModelTypeTag);
    selectedModelIdxElem.setText(mangle(param.getSelectedModel() + ""));
    batchRunNode.addContent(selectedModelIdxElem);
    // Get average model parameters
    Element parametersNode = new Element(MicroscopyXMLTags.ModelParametersTag);
    Parameter[] avgParams = param.getAverageParameters();
    if (avgParams != null) {
        if (param.getSelectedModel() == FRAPModel.IDX_MODEL_DIFF_ONE_COMPONENT && avgParams.length == FRAPModel.NUM_MODEL_PARAMETERS_ONE_DIFF) {
            parametersNode.setAttribute(MicroscopyXMLTags.PrimaryRateAttrTag, avgParams[FRAPModel.INDEX_PRIMARY_DIFF_RATE].getInitialGuess() + "");
            parametersNode.setAttribute(MicroscopyXMLTags.PrimaryFractionAttTag, avgParams[FRAPModel.INDEX_PRIMARY_FRACTION].getInitialGuess() + "");
            parametersNode.setAttribute(MicroscopyXMLTags.BleachWhileMonitoringTauAttrTag, avgParams[FRAPModel.INDEX_BLEACH_MONITOR_RATE].getInitialGuess() + "");
        } else if (param.getSelectedModel() == FRAPModel.IDX_MODEL_DIFF_TWO_COMPONENTS && avgParams.length == FRAPModel.NUM_MODEL_PARAMETERS_TWO_DIFF) {
            parametersNode.setAttribute(MicroscopyXMLTags.PrimaryRateAttrTag, avgParams[FRAPModel.INDEX_PRIMARY_DIFF_RATE].getInitialGuess() + "");
            parametersNode.setAttribute(MicroscopyXMLTags.PrimaryFractionAttTag, avgParams[FRAPModel.INDEX_PRIMARY_FRACTION].getInitialGuess() + "");
            parametersNode.setAttribute(MicroscopyXMLTags.BleachWhileMonitoringTauAttrTag, avgParams[FRAPModel.INDEX_BLEACH_MONITOR_RATE].getInitialGuess() + "");
            parametersNode.setAttribute(MicroscopyXMLTags.SecondRateAttrTag, avgParams[FRAPModel.INDEX_SECONDARY_DIFF_RATE].getInitialGuess() + "");
            parametersNode.setAttribute(MicroscopyXMLTags.SecondFractionAttTag, avgParams[FRAPModel.INDEX_SECONDARY_FRACTION].getInitialGuess() + "");
        } else if (param.getSelectedModel() == FRAPModel.IDX_MODEL_REACTION_OFF_RATE && avgParams.length == FRAPModel.NUM_MODEL_PARAMETERS_REACTION_OFF_RATE) {
            parametersNode.setAttribute(MicroscopyXMLTags.BleachWhileMonitoringTauAttrTag, avgParams[FRAPModel.INDEX_BLEACH_MONITOR_RATE].getInitialGuess() + "");
            parametersNode.setAttribute(MicroscopyXMLTags.BindingSiteConcentrationAttTag, avgParams[FRAPModel.INDEX_BINDING_SITE_CONCENTRATION].getInitialGuess() + "");
            parametersNode.setAttribute(MicroscopyXMLTags.ReactionOffRateAttTag, avgParams[FRAPModel.INDEX_OFF_RATE].getInitialGuess() + "");
        }
    }
    batchRunNode.addContent(parametersNode);
    // Get frap study file lists
    if (param.getFrapStudies() != null && param.getFrapStudies().size() > 0) {
        Element frapStudyListNode = new Element(MicroscopyXMLTags.FrapStudyListTag);
        frapStudyListNode.setAttribute(MicroscopyXMLTags.NumFrapStudyListAttrTag, Integer.toString(param.getFrapStudies().size()));
        ArrayList<FRAPStudy> frapList = param.getFrapStudies();
        for (int i = 0; i < frapList.size(); i++) {
            if (frapList.get(i).getXmlFilename() != null) {
                Element fileNameNode = new Element(MicroscopyXMLTags.FrapFileNameTag);
                fileNameNode.addContent(frapList.get(i).getXmlFilename());
                frapStudyListNode.addContent(fileNameNode);
            }
        }
        batchRunNode.addContent(frapStudyListNode);
    }
    return batchRunNode;
}
Also used : Element(org.jdom.Element) Parameter(cbit.vcell.opt.Parameter) FRAPStudy(cbit.vcell.microscopy.FRAPStudy)

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