Search in sources :

Example 1 with Image

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

the class ExportRawTimeSeriesToVFrap method compute0.

@Override
protected void compute0(TaskContext context, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    // get inputs
    File outputFile = context.getData(vfrapFile);
    ImageTimeSeries imageTimeSeries = context.getData(rawTimeSeriesImages);
    // validate that imageTimeSeries is of type ImageTimeSeries<UShortImage>
    Image[] images = imageTimeSeries.getAllImages();
    UShortImage[] usImages = new UShortImage[images.length];
    for (int i = 0; i < usImages.length; i++) {
        if (!(images[i] instanceof UShortImage)) {
            throw new Exception("type mismatch, expecting only UShortImages in time series");
        }
        usImages[i] = (UShortImage) images[i];
    }
    ImageTimeSeries<UShortImage> ushortImageTimeSeries = new ImageTimeSeries<UShortImage>(UShortImage.class, usImages, imageTimeSeries.getImageTimeStamps(), imageTimeSeries.getSizeZ());
    ExportRawTimeSeriesToVFrapOp op = new ExportRawTimeSeriesToVFrapOp();
    op.exportToVFRAP(outputFile, ushortImageTimeSeries, clientTaskStatusSupport);
    // write output (just boolean "done" flag)
    context.setData(written, true);
}
Also used : UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) Image(cbit.vcell.VirtualMicroscopy.Image) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) ExportRawTimeSeriesToVFrapOp(org.vcell.vmicro.op.ExportRawTimeSeriesToVFrapOp) File(java.io.File) ImageTimeSeries(org.vcell.vmicro.workflow.data.ImageTimeSeries)

Example 2 with Image

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

the class WorkflowObjectsPanel method displayData.

private void displayData(TaskContext taskContext, WorkflowObject workflowObject) {
    if (workflowObject instanceof DataInput || workflowObject instanceof DataOutput) {
        String title = parametersFunctionsTableModel.getName(workflowObject);
        WindowListener listener = new WindowAdapter() {
        };
        Object data = null;
        if (workflowObject instanceof WorkflowDataSource) {
            WorkflowDataSource dataHolder = (WorkflowDataSource) workflowObject;
            data = taskContext.getRepository().getData(dataHolder);
        } else if (workflowObject instanceof DataInput) {
            DataInput dataInput = (DataInput) workflowObject;
            data = taskContext.getData(dataInput);
        }
        if (data instanceof RowColumnResultSet) {
            RowColumnResultSet rc = (RowColumnResultSet) data;
            try {
                new DisplayPlotOp().displayPlot(rc, title, listener);
            } catch (ExpressionException e) {
                e.printStackTrace();
            }
        } else if (data instanceof ROI) {
            ROI roi = (ROI) data;
            Image image = roi.getRoiImages()[0];
            new DisplayImageOp().displayImage(image, title, listener);
        } else if (data instanceof ProfileData[]) {
            ProfileData[] profileData = (ProfileData[]) data;
            new DisplayProfileLikelihoodPlotsOp().displayProfileLikelihoodPlots(profileData, title, listener);
        } else if (data instanceof Image) {
            Image image = (Image) data;
            new DisplayImageOp().displayImage(image, title, listener);
        } else if (data instanceof ImageTimeSeries) {
            ImageTimeSeries imageTimeSeries = (ImageTimeSeries) data;
            try {
                DisplayTimeSeries.displayImageTimeSeries(imageTimeSeries, title, listener);
            } catch (ImageException | IOException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : DataOutput(org.vcell.workflow.DataOutput) DisplayProfileLikelihoodPlotsOp(org.vcell.vmicro.op.display.DisplayProfileLikelihoodPlotsOp) WindowListener(java.awt.event.WindowListener) ImageException(cbit.image.ImageException) WindowAdapter(java.awt.event.WindowAdapter) ProfileData(org.vcell.optimization.ProfileData) IOException(java.io.IOException) Image(cbit.vcell.VirtualMicroscopy.Image) ROI(cbit.vcell.VirtualMicroscopy.ROI) WorkflowDataSource(org.vcell.workflow.WorkflowDataSource) ExpressionException(cbit.vcell.parser.ExpressionException) DataInput(org.vcell.workflow.DataInput) DisplayPlotOp(org.vcell.vmicro.op.display.DisplayPlotOp) DisplayImageOp(org.vcell.vmicro.op.display.DisplayImageOp) WorkflowObject(org.vcell.workflow.WorkflowObject) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet) ImageTimeSeries(org.vcell.vmicro.workflow.data.ImageTimeSeries)

Example 3 with Image

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

the class WorkflowObjectsPanel method hasDisplayData.

private boolean hasDisplayData(TaskContext taskContext, WorkflowObject workflowObject) {
    if (workflowObject instanceof DataInput || workflowObject instanceof DataOutput) {
        String title = parametersFunctionsTableModel.getName(workflowObject);
        WindowListener listener = new WindowAdapter() {
        };
        Object data = null;
        if (workflowObject instanceof WorkflowDataSource) {
            WorkflowDataSource dataHolder = (WorkflowDataSource) workflowObject;
            data = taskContext.getRepository().getData(dataHolder);
        } else if (workflowObject instanceof DataInput) {
            DataInput dataInput = (DataInput) workflowObject;
            data = taskContext.getData(dataInput);
        }
        if (data instanceof RowColumnResultSet || data instanceof ROI || data instanceof ProfileData[] || data instanceof Image || data instanceof ImageTimeSeries) {
            return true;
        }
    }
    return false;
}
Also used : DataOutput(org.vcell.workflow.DataOutput) WindowListener(java.awt.event.WindowListener) WindowAdapter(java.awt.event.WindowAdapter) ProfileData(org.vcell.optimization.ProfileData) Image(cbit.vcell.VirtualMicroscopy.Image) ROI(cbit.vcell.VirtualMicroscopy.ROI) WorkflowDataSource(org.vcell.workflow.WorkflowDataSource) DataInput(org.vcell.workflow.DataInput) WorkflowObject(org.vcell.workflow.WorkflowObject) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet) ImageTimeSeries(org.vcell.vmicro.workflow.data.ImageTimeSeries)

Example 4 with Image

use of cbit.vcell.VirtualMicroscopy.Image 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 5 with Image

use of cbit.vcell.VirtualMicroscopy.Image 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)

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