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);
}
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();
}
}
}
}
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;
}
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);
}
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;
}
Aggregations