use of org.vcell.vmicro.workflow.data.ImageTimeSeries 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 org.vcell.vmicro.workflow.data.ImageTimeSeries in project vcell by virtualcell.
the class GenerateNormalizedPhotoactivationDataOp method generate.
public NormalizedPhotoactivationDataResults generate(ImageTimeSeries<UShortImage> rawImageTimeSeries, ROI backgroundROI_2D, Integer indexPostactivation, boolean backgroundSubtract, boolean normalizedByPreactivation) throws Exception {
UShortImage preactivationImage = rawImageTimeSeries.getAllImages()[0];
ISize isize = preactivationImage.getISize();
int nX = isize.getX();
int nY = isize.getY();
int nZ = isize.getZ();
int numTimes = rawImageTimeSeries.getSizeT();
Extent extent = preactivationImage.getExtent();
org.vcell.util.Origin origin = preactivationImage.getOrigin();
if (indexPostactivation == 0) {
throw new RuntimeException("no preactivation images found - indexOfFirstPostactivation is 0");
}
//
// find average "dark count" in background of pre-activation images (for background subtraction)
//
float avgBackground = 0.0f;
int numPreactivation = indexPostactivation;
for (int i = 0; i < numPreactivation; i++) {
avgBackground += getAverage(rawImageTimeSeries.getAllImages()[i], backgroundROI_2D);
}
avgBackground /= numPreactivation;
//
// find averaged preactivation image (corrected for background).
//
int numPostactivationImages = numTimes - numPreactivation;
// holds new averaged image pixels
float[] preactivationAveragePixels = new float[nX * nY * nZ];
for (int i = 0; i < numPreactivation; i++) {
short[] currPreactivationImage = rawImageTimeSeries.getAllImages()[i].getPixels();
for (int j = 0; j < isize.getXYZ(); j++) {
float intPixel = 0x0000ffff & ((int) currPreactivationImage[j]);
preactivationAveragePixels[j] += intPixel / numPreactivation;
}
}
FloatImage preactivationAverageImage = new FloatImage(preactivationAveragePixels, origin, extent, nX, nY, nZ);
UShortImage firstPostactivationImage = rawImageTimeSeries.getAllImages()[indexPostactivation];
//
// create normalized dataset
//
// normalized postbleach = (origPostbleach - background)/(prebleach - background)
//
FloatImage[] normalizedImages = new FloatImage[numPostactivationImages];
double[] postactivationTimeStamps = new double[numPostactivationImages];
for (int i = 0; i < numPostactivationImages; i++) {
double[] origTimeStamps = rawImageTimeSeries.getImageTimeStamps();
postactivationTimeStamps[i] = origTimeStamps[indexPostactivation + i] - origTimeStamps[indexPostactivation];
float[] normalizedPixels = new float[isize.getXYZ()];
normalizedImages[i] = new FloatImage(normalizedPixels, origin, extent, nX, nY, nZ);
short[] uncorrectedPixels = rawImageTimeSeries.getAllImages()[i + indexPostactivation].getPixels();
for (int j = 0; j < isize.getXYZ(); j++) {
int intUncorrectedPixel = 0x0000ffff & ((int) uncorrectedPixels[j]);
float background = 0;
if (backgroundSubtract) {
background = avgBackground;
}
if (normalizedByPreactivation) {
int intPreactivationAvgPixel = 0x0000ffff & ((int) preactivationAveragePixels[j]);
normalizedPixels[j] = (intUncorrectedPixel - background) / (Math.max(1, intPreactivationAvgPixel - background));
} else {
normalizedPixels[j] = (intUncorrectedPixel - background);
}
}
normalizedImages[i] = new FloatImage(normalizedPixels, origin, extent, nX, nY, nZ);
}
ImageTimeSeries<FloatImage> normalizedData = new ImageTimeSeries<FloatImage>(FloatImage.class, normalizedImages, postactivationTimeStamps, nZ);
NormalizedPhotoactivationDataResults results = new NormalizedPhotoactivationDataResults();
results.normalizedPhotoactivationData = normalizedData;
results.preactivationAverageImage = preactivationAverageImage;
results.normalizedPostactivationImage = normalizedData.getAllImages()[0];
return results;
}
use of org.vcell.vmicro.workflow.data.ImageTimeSeries in project vcell by virtualcell.
the class GenerateNormalizedFrapDataOp method generate.
public NormalizedFrapDataResults generate(ImageTimeSeries<UShortImage> rawImageTimeSeries, ROI backgroundROI_2D, Integer indexPostbleach) throws Exception {
UShortImage firstImage = rawImageTimeSeries.getAllImages()[0];
ISize isize = firstImage.getISize();
int nX = isize.getX();
int nY = isize.getY();
int nZ = isize.getZ();
int numTimes = rawImageTimeSeries.getSizeT();
Extent extent = firstImage.getExtent();
org.vcell.util.Origin origin = firstImage.getOrigin();
if (indexPostbleach == 0) {
throw new RuntimeException("no prebleach images found - indexOfFirstPostbleach is 0");
}
//
// find average "dark count" in background of pre-bleach images (for background subtraction)
//
float avgBackground = 0.0f;
int numPrebleach = indexPostbleach;
for (int i = 0; i < numPrebleach; i++) {
avgBackground += getAverage(rawImageTimeSeries.getAllImages()[i], backgroundROI_2D);
}
avgBackground /= numPrebleach;
//
// find averaged prebleach image (corrected for background).
//
int numPostbleachImages = numTimes - numPrebleach;
// holds new averaged image pixels
float[] prebleachAveragePixels = new float[nX * nY * nZ];
for (int i = 0; i < numPrebleach; i++) {
short[] currPrebleachImage = rawImageTimeSeries.getAllImages()[i].getPixels();
for (int j = 0; j < isize.getXYZ(); j++) {
float intPixel = 0x0000ffff & ((int) currPrebleachImage[j]);
prebleachAveragePixels[j] += intPixel / numPrebleach;
}
}
FloatImage prebleachAverageImage = new FloatImage(prebleachAveragePixels, origin, extent, nX, nY, nZ);
//
// create normalized dataset
//
// normalized postbleach = (origPostbleach - background)/(prebleach - background)
//
FloatImage[] normalizedImages = new FloatImage[numPostbleachImages];
double[] postbleachTimeStamps = new double[numPostbleachImages];
for (int i = 0; i < numPostbleachImages; i++) {
double[] origTimeStamps = rawImageTimeSeries.getImageTimeStamps();
postbleachTimeStamps[i] = origTimeStamps[indexPostbleach + i] - origTimeStamps[indexPostbleach];
float[] normalizedPixels = new float[isize.getXYZ()];
normalizedImages[i] = new FloatImage(normalizedPixels, origin, extent, nX, nY, nZ);
short[] uncorrectedPixels = rawImageTimeSeries.getAllImages()[i + indexPostbleach].getPixels();
for (int j = 0; j < isize.getXYZ(); j++) {
int intPixel = 0x0000ffff & ((int) uncorrectedPixels[j]);
normalizedPixels[j] = (intPixel - avgBackground) / (Math.max(1, prebleachAveragePixels[j] - avgBackground));
}
normalizedImages[i] = new FloatImage(normalizedPixels, origin, extent, nX, nY, nZ);
}
ImageTimeSeries<FloatImage> normalizedData = new ImageTimeSeries<FloatImage>(FloatImage.class, normalizedImages, postbleachTimeStamps, nZ);
NormalizedFrapDataResults results = new NormalizedFrapDataResults();
results.normalizedFrapData = normalizedData;
results.prebleachAverage = prebleachAverageImage;
return results;
}
use of org.vcell.vmicro.workflow.data.ImageTimeSeries in project vcell by virtualcell.
the class ImportRawTimeSeriesFrom2DVCellConcentrationsOp method importRawTimeSeries.
public ImageTimeSeries<UShortImage> importRawTimeSeries(File vcellSimLogFile, String fluorFunctionName, double maxIntensity, boolean bNoise) throws Exception {
ClientTaskStatusSupport clientTaskStatusSupport = null;
ImageDataset timeRawData = importRawTimeSeries(vcellSimLogFile, fluorFunctionName, maxIntensity, bNoise, clientTaskStatusSupport);
ImageTimeSeries<UShortImage> imageTimeSeries = new ImageTimeSeries<UShortImage>(UShortImage.class, timeRawData.getAllImages(), timeRawData.getImageTimeStamps(), 1);
return imageTimeSeries;
}
use of org.vcell.vmicro.workflow.data.ImageTimeSeries in project vcell by virtualcell.
the class ImportRawTimeSeriesFromExperimentImagesOp method importRawTimeSeries.
public ImageTimeSeries<UShortImage> importRawTimeSeries(File[] expTimeSeriesFiles, double timeInterval) throws Exception {
boolean isTimeSeries = true;
ClientTaskStatusSupport clientTaskStatusSupport = null;
ImageDataset rawTimeData = ImageDatasetReaderService.getInstance().getImageDatasetReader().readImageDatasetFromMultiFiles(expTimeSeriesFiles, clientTaskStatusSupport, isTimeSeries, timeInterval);
ImageTimeSeries<UShortImage> imageTimeSeries = new ImageTimeSeries<UShortImage>(UShortImage.class, rawTimeData.getAllImages(), rawTimeData.getImageTimeStamps(), 1);
return imageTimeSeries;
}
Aggregations