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