Search in sources :

Example 6 with Image

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

the class GenerateCellROIsFromRawPhotoactivationTimeSeriesOp method generate.

public GeometryRoisAndActivationTiming 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+1]/total[n]
    // 
    int indexPostactivation = -1;
    double largestRatio = 0.0;
    for (int tIndex = 0; tIndex < numTimes - 1; tIndex++) {
        double currentRatio = imageStats[tIndex + 1].meanValue / imageStats[tIndex].meanValue;
        if (currentRatio > largestRatio) {
            largestRatio = currentRatio;
            indexPostactivation = 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, 10, wholeDomainImage);
    reverseCell.reverse();
    reverseCell.and(backgroundImage);
    backgroundImage = reverseCell;
    cellImage = new UShortImage(backgroundImage);
    cellImage.reverse();
    ROI cellROI = new ROI(cellImage, "cellROI");
    ROI backgroundROI = new ROI(backgroundImage, "backgroundROI");
    GeometryRoisAndActivationTiming results = new GeometryRoisAndActivationTiming();
    results.cellROI_2D = cellROI;
    results.backgroundROI_2D = backgroundROI;
    results.indexOfFirstPostactivation = indexPostactivation;
    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 7 with Image

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

the class WorkflowObjectsTableModel method getValue.

private String getValue(WorkflowObject workflowObject) {
    if (workflowObject instanceof Task) {
        return "";
    } else {
        Object data = null;
        Class dataType = null;
        if (workflowObject instanceof WorkflowDataSource) {
            WorkflowDataSource dataHolder = (WorkflowDataSource) workflowObject;
            WorkflowDataSource dataSource = taskContext.getWorkflow().getDataSource((DataObject) dataHolder);
            data = taskContext.getRepository().getData(dataSource);
            dataType = dataHolder.getType();
        } else if (workflowObject instanceof DataInput) {
            DataInput dataInput = (DataInput) workflowObject;
            data = taskContext.getData(dataInput);
            dataType = dataInput.getType();
        }
        if (data instanceof RowColumnResultSet) {
            RowColumnResultSet rc = (RowColumnResultSet) data;
            int N = rc.getColumnDescriptionsCount();
            StringBuffer buffer = new StringBuffer(rc.getRowCount() + " rows of " + N + " {");
            int MAX = 3;
            for (int i = 0; i < N; i++) {
                buffer.append("\"" + rc.getColumnDescriptions(i).getDisplayName() + "\"");
                if (i >= MAX - 1) {
                    buffer.append(", ...");
                    break;
                }
                if (i < N - 1) {
                    buffer.append(", ");
                }
            }
            buffer.append("}");
            return buffer.toString();
        } else if (data instanceof String) {
            return "\"" + (String) data + "\"";
        } else if (data instanceof ROI) {
            return "ROI \"" + ((ROI) data).getROIName() + "\"";
        } else if (data instanceof ROI[]) {
            ROI[] rois = (ROI[]) data;
            int N = rois.length;
            int MAX = 3;
            StringBuffer buffer = new StringBuffer("ROI[" + N + "] { ");
            for (int i = 0; i < N; i++) {
                buffer.append("\"" + rois[i].getROIName() + "\"");
                if (i >= MAX - 1) {
                    buffer.append(", ...");
                    break;
                }
                if (i < N - 1) {
                    buffer.append(", ");
                }
            }
            buffer.append("}");
            return buffer.toString();
        } else if (data instanceof Image) {
            Image image = (Image) data;
            return image.getClass().getSimpleName() + " " + image.getISize().toString();
        } else if (data instanceof ImageTimeSeries) {
            ImageTimeSeries ts = (ImageTimeSeries) data;
            int N = ts.getSizeT();
            double[] times = ts.getImageTimeStamps();
            return ts.getType().getSimpleName() + "[" + N + "] " + ts.getISize() + " times=[" + times[0] + "," + times[N - 1] + "]";
        } else if (data != null) {
            return data.toString();
        } else {
            return "null " + dataType.getSimpleName();
        }
    }
}
Also used : Task(org.vcell.workflow.Task) Image(cbit.vcell.VirtualMicroscopy.Image) ROI(cbit.vcell.VirtualMicroscopy.ROI) WorkflowDataSource(org.vcell.workflow.WorkflowDataSource) DataInput(org.vcell.workflow.DataInput) DataObject(org.vcell.workflow.DataObject) WorkflowObject(org.vcell.workflow.WorkflowObject) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet) ImageTimeSeries(org.vcell.vmicro.workflow.data.ImageTimeSeries)

Example 8 with Image

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

the class GenerateBleachROI method compute0.

@Override
protected void compute0(TaskContext context, final ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    // get input
    Image firstPostbleachImage = context.getData(normalizedTimeSeries).getAllImages()[0];
    ROI cellROI = context.getData(cellROI_2D);
    double bleachThresholdValue = context.getData(bleachThreshold);
    // do op
    GenerateBleachRoiOp op = new GenerateBleachRoiOp();
    ROI bleachedROI = op.generateBleachRoi(firstPostbleachImage, cellROI, bleachThresholdValue);
    // set output
    context.setData(bleachedROI_2D, bleachedROI);
    context.setData(bleachedROI_2D_array, new ROI[] { bleachedROI });
}
Also used : GenerateBleachRoiOp(org.vcell.vmicro.op.GenerateBleachRoiOp) Image(cbit.vcell.VirtualMicroscopy.Image) ROI(cbit.vcell.VirtualMicroscopy.ROI)

Example 9 with Image

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

the class DisplayTimeSeries method compute0.

@Override
protected void compute0(TaskContext context, final ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    // set input
    ImageTimeSeries<Image> imageDataset = context.getData(imageTimeSeries);
    String titleString = "no title - not connected";
    titleString = context.getDataWithDefault(title, "no title");
    WindowListener listener = null;
    // do op
    DisplayTimeSeriesOp op = new DisplayTimeSeriesOp();
    op.displayImageTimeSeries(imageDataset, titleString, listener);
    // set output
    context.setData(displayed, true);
}
Also used : WindowListener(java.awt.event.WindowListener) DisplayTimeSeriesOp(org.vcell.vmicro.op.display.DisplayTimeSeriesOp) Image(cbit.vcell.VirtualMicroscopy.Image) VCImage(cbit.image.VCImage) RegionImage(cbit.vcell.geometry.RegionImage)

Example 10 with Image

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

the class GenerateCellROIsFromRawTimeSeries method compute0.

@Override
protected void compute0(TaskContext context, final ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    // get inputs
    ImageTimeSeries<Image> imageTimeSeries = context.getData(rawTimeSeriesImages);
    double cellThresholdValue = context.getData(cellThreshold);
    // do op
    GenerateCellROIsFromRawFrapTimeSeriesOp op = new GenerateCellROIsFromRawFrapTimeSeriesOp();
    GeometryRoisAndBleachTiming results = op.generate(imageTimeSeries, cellThresholdValue);
    // set output
    context.setData(cellROI_2D, results.cellROI_2D);
    context.setData(backgroundROI_2D, results.backgroundROI_2D);
    context.setData(indexOfFirstPostbleach, results.indexOfFirstPostbleach);
}
Also used : GenerateCellROIsFromRawFrapTimeSeriesOp(org.vcell.vmicro.op.GenerateCellROIsFromRawFrapTimeSeriesOp) GeometryRoisAndBleachTiming(org.vcell.vmicro.op.GenerateCellROIsFromRawFrapTimeSeriesOp.GeometryRoisAndBleachTiming) Image(cbit.vcell.VirtualMicroscopy.Image)

Aggregations

Image (cbit.vcell.VirtualMicroscopy.Image)10 ROI (cbit.vcell.VirtualMicroscopy.ROI)7 ImageTimeSeries (org.vcell.vmicro.workflow.data.ImageTimeSeries)5 RowColumnResultSet (cbit.vcell.math.RowColumnResultSet)4 UShortImage (cbit.vcell.VirtualMicroscopy.UShortImage)3 WindowListener (java.awt.event.WindowListener)3 DataInput (org.vcell.workflow.DataInput)3 WorkflowDataSource (org.vcell.workflow.WorkflowDataSource)3 WorkflowObject (org.vcell.workflow.WorkflowObject)3 ImageStatistics (cbit.vcell.VirtualMicroscopy.Image.ImageStatistics)2 WindowAdapter (java.awt.event.WindowAdapter)2 ProfileData (org.vcell.optimization.ProfileData)2 DataOutput (org.vcell.workflow.DataOutput)2 ImageException (cbit.image.ImageException)1 VCImage (cbit.image.VCImage)1 RegionImage (cbit.vcell.geometry.RegionImage)1 ExpressionException (cbit.vcell.parser.ExpressionException)1 File (java.io.File)1 IOException (java.io.IOException)1 ExportRawTimeSeriesToVFrapOp (org.vcell.vmicro.op.ExportRawTimeSeriesToVFrapOp)1