Search in sources :

Example 26 with ROI

use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.

the class GenerateReducedData method compute0.

@Override
protected void compute0(TaskContext context, final ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    // get input
    ROI[] rois = context.getData(imageDataROIs);
    ImageTimeSeries<? extends Image> simData = (ImageTimeSeries<? extends Image>) context.getData(imageTimeSeries);
    // do op
    GenerateReducedDataOp op = new GenerateReducedDataOp();
    RowColumnResultSet reducedData = op.generateReducedData(simData, rois);
    // set output
    context.setData(reducedROIData, reducedData);
}
Also used : Image(cbit.vcell.VirtualMicroscopy.Image) GenerateReducedDataOp(org.vcell.vmicro.op.GenerateReducedDataOp) ROI(cbit.vcell.VirtualMicroscopy.ROI) ImageTimeSeries(org.vcell.vmicro.workflow.data.ImageTimeSeries) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet)

Example 27 with ROI

use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.

the class RunRefSimulation method compute0.

@Override
protected void compute0(TaskContext context, final ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    // get input
    ImageTimeSeries<FloatImage> normTimeSeries = context.getData(normalizedTimeSeries);
    ROI cellROI = context.getData(cellROI_2D);
    double referenceDiffusionRate = 1.0;
    // do op
    RunRefSimulationOp op = new RunRefSimulationOp();
    ImageTimeSeries<FloatImage> solution = op.compute0(cellROI, normTimeSeries, referenceDiffusionRate, context.getLocalWorkspace(), clientTaskStatusSupport);
    // set output
    context.setData(refSimTimeSeries, solution);
    context.setData(refSimDiffusionRate, referenceDiffusionRate);
}
Also used : RunRefSimulationOp(org.vcell.vmicro.op.RunRefSimulationOp) FloatImage(cbit.vcell.VirtualMicroscopy.FloatImage) ROI(cbit.vcell.VirtualMicroscopy.ROI)

Example 28 with ROI

use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.

the class GenerateActivationRoiOp method generateActivatedRoi.

public ROI generateActivatedRoi(Image firstPostactivation, ROI cellROI_2D, Double activationThreshold) throws ImageException {
    int numPixels = firstPostactivation.getNumXYZ();
    short[] scaledActivatedDataShort = new short[numPixels];
    short[] erodedCellUShort = cellROI_2D.getRoiImages()[0].getBinaryPixels(1);
    // input is already normalized to 1.0 ... if relative to max, then crazy values from outside cell can interfere.
    double activationThresholdValue = activationThreshold;
    double[] firstPostactivationImage = firstPostactivation.getDoublePixels();
    for (int j = 0; j < numPixels; j++) {
        boolean isCell = (erodedCellUShort[j] == 1);
        boolean isActivation = firstPostactivationImage[j] > activationThresholdValue;
        if (isCell && isActivation) {
            scaledActivatedDataShort[j] = 1;
        }
    }
    UShortImage activatedImage = new UShortImage(scaledActivatedDataShort, firstPostactivation.getOrigin(), firstPostactivation.getExtent(), firstPostactivation.getNumX(), firstPostactivation.getNumY(), firstPostactivation.getNumZ());
    ROI bleachedROI = new ROI(activatedImage, "bleachedROI");
    return bleachedROI;
}
Also used : UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) ROI(cbit.vcell.VirtualMicroscopy.ROI)

Example 29 with ROI

use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.

the class GenerateCellROIsFromRawFrapTimeSeriesOp method generate.

public GeometryRoisAndBleachTiming generate(ImageTimeSeries rawTimeSeriesImages, double cellThreshold) throws Exception {
    Image[] allImages = rawTimeSeriesImages.getAllImages();
    int numPixels = allImages[0].getNumXYZ();
    int numTimes = allImages.length;
    ImageStatistics[] imageStats = new ImageStatistics[numTimes];
    for (int i = 0; i < numTimes; i++) {
        imageStats[i] = allImages[i].getImageStatistics();
    }
    // 
    // find largest change in fluorescence (ratio of total[n]/total[n+1]
    // 
    int indexPostbleach = -1;
    double largestRatio = 0.0;
    for (int tIndex = 0; tIndex < numTimes - 1; tIndex++) {
        double currentRatio = imageStats[tIndex].meanValue / imageStats[tIndex + 1].meanValue;
        if (currentRatio > largestRatio) {
            largestRatio = currentRatio;
            indexPostbleach = tIndex + 1;
        }
    }
    double[] firstImagePixels = allImages[0].getDoublePixels();
    short[] scaledCellDataShort = new short[numPixels];
    short[] scaledBackgoundDataShort = new short[numPixels];
    short[] wholeDomainDataShort = new short[numPixels];
    // 
    // find cell and background by thresholding the first image
    // 
    double cellThresholdValue = cellThreshold * imageStats[0].maxValue;
    for (int j = 0; j < numPixels; j++) {
        boolean isCell = firstImagePixels[j] > cellThresholdValue;
        if (isCell) {
            scaledCellDataShort[j] = 1;
        } else {
            scaledBackgoundDataShort[j] = 1;
        }
    }
    UShortImage cellImage = new UShortImage(scaledCellDataShort, allImages[0].getOrigin(), allImages[0].getExtent(), allImages[0].getNumX(), allImages[0].getNumY(), allImages[0].getNumZ());
    UShortImage backgroundImage = new UShortImage(scaledBackgoundDataShort, allImages[0].getOrigin(), allImages[0].getExtent(), allImages[0].getNumX(), allImages[0].getNumY(), allImages[0].getNumZ());
    Arrays.fill(wholeDomainDataShort, (short) 1);
    UShortImage wholeDomainImage = new UShortImage(wholeDomainDataShort, allImages[0].getOrigin(), allImages[0].getExtent(), allImages[0].getNumX(), allImages[0].getNumY(), allImages[0].getNumZ());
    UShortImage reverseCell = UShortImage.fastDilate(cellImage, 15, wholeDomainImage);
    reverseCell.reverse();
    reverseCell.and(backgroundImage);
    backgroundImage = reverseCell;
    ROI cellROI = new ROI(cellImage, "cellROI");
    ROI backgroundROI = new ROI(backgroundImage, "backgroundROI");
    GeometryRoisAndBleachTiming results = new GeometryRoisAndBleachTiming();
    results.cellROI_2D = cellROI;
    results.backgroundROI_2D = backgroundROI;
    results.indexOfFirstPostbleach = indexPostbleach;
    return results;
}
Also used : ImageStatistics(cbit.vcell.VirtualMicroscopy.Image.ImageStatistics) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) Image(cbit.vcell.VirtualMicroscopy.Image) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) ROI(cbit.vcell.VirtualMicroscopy.ROI)

Example 30 with ROI

use of cbit.vcell.VirtualMicroscopy.ROI in project vcell by virtualcell.

the class GenerateDependentImageROIsOp method generate.

public ROI[] generate(ROI cellROI_2d, ROI bleachedROI_2d) throws Exception {
    UShortImage cellROI_2D = null;
    UShortImage bleachedROI_2D = null;
    UShortImage dilatedROI_2D_1 = null;
    UShortImage dilatedROI_2D_2 = null;
    UShortImage dilatedROI_2D_3 = null;
    UShortImage dilatedROI_2D_4 = null;
    UShortImage dilatedROI_2D_5 = null;
    UShortImage erodedROI_2D_0 = null;
    UShortImage erodedROI_2D_1 = null;
    UShortImage erodedROI_2D_2 = null;
    cellROI_2D = cellROI_2d.getRoiImages()[0];
    bleachedROI_2D = bleachedROI_2d.getRoiImages()[0];
    dilatedROI_2D_1 = UShortImage.fastDilate(bleachedROI_2D, 4, cellROI_2D);
    dilatedROI_2D_2 = UShortImage.fastDilate(bleachedROI_2D, 10, cellROI_2D);
    dilatedROI_2D_3 = UShortImage.fastDilate(bleachedROI_2D, 18, cellROI_2D);
    dilatedROI_2D_4 = UShortImage.fastDilate(bleachedROI_2D, 28, cellROI_2D);
    dilatedROI_2D_5 = UShortImage.fastDilate(bleachedROI_2D, 40, cellROI_2D);
    erodedROI_2D_0 = new UShortImage(bleachedROI_2D);
    // The erode always causes problems if eroding without checking the bleached length and height.
    // we have to check the min length of the bleached area to make sure erode within the length.
    Rectangle bleachRect = bleachedROI_2D.getNonzeroBoundingBox();
    if (bleachRect == null || bleachRect.isEmpty()) {
        throw new RuntimeException("bleach ROI is null or empty");
    }
    int minLen = Math.min(bleachRect.height, bleachRect.width);
    if ((minLen / 2.0) < 5) {
        erodedROI_2D_1 = UShortImage.erodeDilate(bleachedROI_2D, UShortImage.createCircularBinaryKernel(1), bleachedROI_2D, true);
        erodedROI_2D_2 = UShortImage.erodeDilate(bleachedROI_2D, UShortImage.createCircularBinaryKernel(2), bleachedROI_2D, true);
    } else {
        erodedROI_2D_1 = UShortImage.erodeDilate(bleachedROI_2D, UShortImage.createCircularBinaryKernel(2), bleachedROI_2D, true);
        erodedROI_2D_2 = UShortImage.erodeDilate(bleachedROI_2D, UShortImage.createCircularBinaryKernel(5), bleachedROI_2D, true);
    }
    UShortImage reverseErodeROI_2D_1 = new UShortImage(erodedROI_2D_1);
    reverseErodeROI_2D_1.reverse();
    erodedROI_2D_0.and(reverseErodeROI_2D_1);
    UShortImage reverseErodeROI_2D_2 = new UShortImage(erodedROI_2D_2);
    reverseErodeROI_2D_2.reverse();
    erodedROI_2D_1.and(reverseErodeROI_2D_2);
    UShortImage reverseDilateROI_2D_4 = new UShortImage(dilatedROI_2D_4);
    reverseDilateROI_2D_4.reverse();
    dilatedROI_2D_5.and(reverseDilateROI_2D_4);
    UShortImage reverseDilateROI_2D_3 = new UShortImage(dilatedROI_2D_3);
    reverseDilateROI_2D_3.reverse();
    dilatedROI_2D_4.and(reverseDilateROI_2D_3);
    UShortImage reverseDilateROI_2D_2 = new UShortImage(dilatedROI_2D_2);
    reverseDilateROI_2D_2.reverse();
    dilatedROI_2D_3.and(reverseDilateROI_2D_2);
    UShortImage reverseDilateROI_2D_1 = new UShortImage(dilatedROI_2D_1);
    reverseDilateROI_2D_1.reverse();
    dilatedROI_2D_2.and(reverseDilateROI_2D_1);
    UShortImage reverseBleach_2D = new UShortImage(bleachedROI_2D);
    reverseBleach_2D.reverse();
    dilatedROI_2D_1.and(reverseBleach_2D);
    ArrayList<ROI> rois = new ArrayList<ROI>();
    // rois.add(new ROI(this.bleachedROI_2D.getData())); // copy this one through
    rois.add(new ROI(erodedROI_2D_2, VFRAP_ROI_ENUM.ROI_BLEACHED_RING1.name()));
    rois.add(new ROI(erodedROI_2D_1, VFRAP_ROI_ENUM.ROI_BLEACHED_RING2.name()));
    rois.add(new ROI(erodedROI_2D_0, VFRAP_ROI_ENUM.ROI_BLEACHED_RING3.name()));
    rois.add(new ROI(dilatedROI_2D_1, VFRAP_ROI_ENUM.ROI_BLEACHED_RING4.name()));
    rois.add(new ROI(dilatedROI_2D_2, VFRAP_ROI_ENUM.ROI_BLEACHED_RING5.name()));
    rois.add(new ROI(dilatedROI_2D_3, VFRAP_ROI_ENUM.ROI_BLEACHED_RING6.name()));
    rois.add(new ROI(dilatedROI_2D_4, VFRAP_ROI_ENUM.ROI_BLEACHED_RING7.name()));
    rois.add(new ROI(dilatedROI_2D_5, VFRAP_ROI_ENUM.ROI_BLEACHED_RING8.name()));
    Iterator<ROI> roiIter = rois.iterator();
    while (roiIter.hasNext()) {
        ROI roi = roiIter.next();
        short[] roiPixels = roi.getBinaryPixelsXYZ(1);
        int numPixels = roiPixels.length;
        int count = 0;
        for (int p = 0; p < numPixels; p++) {
            if (roiPixels[p] != 0) {
                count++;
            }
        }
        if (count == 0) {
            roiIter.remove();
        }
    }
    return rois.toArray(new ROI[0]);
}
Also used : Rectangle(java.awt.Rectangle) ArrayList(java.util.ArrayList) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) ROI(cbit.vcell.VirtualMicroscopy.ROI)

Aggregations

ROI (cbit.vcell.VirtualMicroscopy.ROI)72 UShortImage (cbit.vcell.VirtualMicroscopy.UShortImage)26 RowColumnResultSet (cbit.vcell.math.RowColumnResultSet)10 ArrayList (java.util.ArrayList)10 UserCancelException (org.vcell.util.UserCancelException)10 ImageDataset (cbit.vcell.VirtualMicroscopy.ImageDataset)9 ImageException (cbit.image.ImageException)8 Image (cbit.vcell.VirtualMicroscopy.Image)7 FRAPData (cbit.vcell.microscopy.FRAPData)7 BioModel (cbit.vcell.biomodel.BioModel)6 FloatImage (cbit.vcell.VirtualMicroscopy.FloatImage)5 FieldFunctionArguments (cbit.vcell.field.FieldFunctionArguments)5 RegionInfo (cbit.vcell.geometry.RegionImage.RegionInfo)5 File (java.io.File)5 Hashtable (java.util.Hashtable)5 Element (org.jdom.Element)5 Extent (org.vcell.util.Extent)5 VCImage (cbit.image.VCImage)4 VCImageUncompressed (cbit.image.VCImageUncompressed)4 Expression (cbit.vcell.parser.Expression)4