Search in sources :

Example 1 with DefineROI_SummaryPanel

use of cbit.vcell.microscopy.gui.defineROIwizard.DefineROI_SummaryPanel in project vcell by virtualcell.

the class ROISummaryDescriptor method preNextProcess.

// save the startingIndex before the panel disappears
public ArrayList<AsynchClientTask> preNextProcess() {
    // create AsynchClientTask arraylist
    ArrayList<AsynchClientTask> taskArrayList = new ArrayList<AsynchClientTask>();
    AsynchClientTask verifyLoadedDataTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            String msg = ((DefineROI_SummaryPanel) getPanelComponent()).checkInputValidity();
            if (msg.equals("")) {
                int startIndex = ((DefineROI_SummaryPanel) getPanelComponent()).getStartingIndex();
                FRAPStudy fStudy = getBatchRunWorkspace().getWorkingFrapStudy();
                // check ROI void/discontinuous location
                Point internalVoidLocation = ROI.findInternalVoid(fStudy.getFrapData().getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name()));
                if (internalVoidLocation != null) {
                    throw new Exception("CELL ROI has unfilled internal void area at image location " + "x=" + internalVoidLocation.x + ",y=" + internalVoidLocation.y + "\n" + "Use ROI editing tools to completely define the CELL ROI");
                }
                Point[] distinctCellAreaLocations = ROI.checkContinuity(fStudy.getFrapData().getRoi(FRAPData.VFRAP_ROI_ENUM.ROI_CELL.name()));
                if (distinctCellAreaLocations != null) {
                    throw new Exception("CELL ROI has at least 2 discontinuous areas at image locations \n" + "x=" + distinctCellAreaLocations[0].x + ",y=" + distinctCellAreaLocations[0].y + " and " + "x=" + distinctCellAreaLocations[1].x + ",y=" + distinctCellAreaLocations[1].y + "\n" + "Use ROI editing tools to define a single continuous CELL ROI");
                }
                /**
                 * check for conflicts of background and bleach ROIs against CellROI.
                 */
                boolean bViolationBleachROI = fStudy.getFrapData().checkBleachROIViolatesConstraints();
                boolean bViolationBackgroundROI = fStudy.getFrapData().checkBackgroundROIViolatesConstraints();
                if (bViolationBleachROI || bViolationBackgroundROI) {
                    final String FIX_AUTO = "Fix Automatically";
                    final String NO_THANKS = "No, Thanks";
                    String result = DialogUtils.showWarningDialog(imgPanel, (bViolationBleachROI ? "Bleach ROI extends beyond Cell ROI" : "") + (bViolationBackgroundROI && bViolationBleachROI ? " and" : "") + (bViolationBackgroundROI ? "Background ROI overlaps Cell ROI" : "") + ".  Ensure that the Bleach ROI is completely inside the Cell ROI and the Background ROI is completely outside the Cell ROI.\nDo you want Virtual Frap to fix it automatically?", new String[] { FIX_AUTO, NO_THANKS }, FIX_AUTO);
                    if (result != null && result.equals(FIX_AUTO)) {
                        if (fStudy.getFrapData().fixROIConstraints()) {
                            fStudy.setStartingIndexForRecovery(startIndex);
                            getBatchRunWorkspace().setWorkingFRAPStudy(fStudy);
                            // generate ROI rings
                            fStudy.refreshDependentROIs();
                        } else {
                            throw new Exception("Please fix the ROI problem or cancel the wizard.");
                        }
                    }
                }
            } else
                throw new Exception(msg);
        }
    };
    taskArrayList.add(verifyLoadedDataTask);
    return taskArrayList;
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) DefineROI_SummaryPanel(cbit.vcell.microscopy.gui.defineROIwizard.DefineROI_SummaryPanel) ArrayList(java.util.ArrayList) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) Point(java.awt.Point) Point(java.awt.Point)

Aggregations

AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 FRAPStudy (cbit.vcell.microscopy.FRAPStudy)1 DefineROI_SummaryPanel (cbit.vcell.microscopy.gui.defineROIwizard.DefineROI_SummaryPanel)1 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 Hashtable (java.util.Hashtable)1