use of cbit.vcell.VirtualMicroscopy.FloatImage in project vcell by virtualcell.
the class FitBleachSpot method compute0.
@Override
protected void compute0(TaskContext context, final ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
// get inputs
NormalizedSampleFunction bleach_roi = context.getData(bleachROI);
FloatImage normImage = (FloatImage) context.getData(normalizedImages).getAllImages()[0];
// do operation
FitBleachSpotOp fitBleachSpotOp = new FitBleachSpotOp();
FitBleachSpotOpResults opResults = fitBleachSpotOp.fit(bleach_roi, normImage);
// set outputs
context.setData(bleachRadius_ROI, opResults.bleachRadius_ROI);
context.setData(centerX_ROI, opResults.centerX_ROI);
context.setData(centerY_ROI, opResults.centerY_ROI);
context.setData(bleachFactorK_GaussianFit, opResults.bleachFactorK_GaussianFit);
context.setData(bleachRadius_GaussianFit, opResults.bleachRadius_ROI);
context.setData(centerX_GaussianFit, opResults.centerX_GaussianFit);
context.setData(centerY_GaussianFit, opResults.centerY_GaussianFit);
}
use of cbit.vcell.VirtualMicroscopy.FloatImage in project vcell by virtualcell.
the class RunRefSimulation method compute0.
@Override
protected void compute0(TaskContext context, final ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
// get input
ImageTimeSeries<FloatImage> normTimeSeries = context.getData(normalizedTimeSeries);
ROI cellROI = context.getData(cellROI_2D);
double referenceDiffusionRate = 1.0;
// do op
RunRefSimulationOp op = new RunRefSimulationOp();
ImageTimeSeries<FloatImage> solution = op.compute0(cellROI, normTimeSeries, referenceDiffusionRate, context.getLocalWorkspace(), clientTaskStatusSupport);
// set output
context.setData(refSimTimeSeries, solution);
context.setData(refSimDiffusionRate, referenceDiffusionRate);
}
use of cbit.vcell.VirtualMicroscopy.FloatImage in project vcell by virtualcell.
the class NormalizedSampleFunction method fromROI.
public static NormalizedSampleFunction fromROI(ROI roi) throws ImageException {
if (roi.getISize().getZ() > 1) {
throw new RuntimeException("ROISampleFunction doesn't yet support 3D ROIs");
}
float[] normalizedPixels = new float[roi.getISize().getXYZ()];
int nonzeroPixelCount = roi.getNonzeroPixelsCount();
if (nonzeroPixelCount == 0) {
throw new RuntimeException("empty ROI \"" + roi.getROIName() + "\"");
}
float pixelValue = 1.0f;
for (int i = 0; i < normalizedPixels.length; i++) {
if (roi.getRoiImages()[0].getPixels()[i] > 0) {
normalizedPixels[i] = pixelValue;
}
}
UShortImage roiImage = roi.getRoiImages()[0];
FloatImage sample = new FloatImage(normalizedPixels, roiImage.getOrigin(), roiImage.getExtent(), roi.getISize().getX(), roi.getISize().getY(), roi.getISize().getZ());
return new NormalizedSampleFunction(roi.getROIName(), sample);
}
use of cbit.vcell.VirtualMicroscopy.FloatImage in project vcell by virtualcell.
the class RunRefSimulationOp method compute0.
public ImageTimeSeries<FloatImage> compute0(ROI cellROI_2D, ImageTimeSeries<FloatImage> normTimeSeries, double refSimDiffusionRate, LocalWorkspace localWorkspace, final ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
double[] timeStamps = normTimeSeries.getImageTimeStamps();
TimeBounds timeBounds = new TimeBounds(0, 20 * timeStamps[timeStamps.length - 1]);
FloatImage initRefConc = normTimeSeries.getAllImages()[0];
double timeStepVal = timeStamps[1] - timeStamps[0];
// arbitrary for now.
double baseDiffusionRate = 1.0;
ImageTimeSeries<FloatImage> solution = runRefSimulation(localWorkspace, cellROI_2D, timeStepVal, timeBounds, initRefConc, baseDiffusionRate, clientTaskStatusSupport);
return solution;
}
use of cbit.vcell.VirtualMicroscopy.FloatImage in project vcell by virtualcell.
the class RunRefSimulationOp method runRefSimulation.
private static ImageTimeSeries<FloatImage> runRefSimulation(LocalWorkspace localWorkspace, ROI cellROI, double timeStepVal, TimeBounds timeBounds, FloatImage initRefConc, double baseDiffusionRate, ClientTaskStatusSupport progressListener) throws Exception {
String INITCONC_EXTDATA_NAME = "initConc";
String INITCONC_EXTDATA_VARNAME = "conc";
String VAR_NAME = "species";
User owner = LocalWorkspace.getDefaultOwner();
KeyValue simKey = LocalWorkspace.createNewKeyValue();
ExternalDataInfo initialConcentrationExtData = createNewExternalDataInfo(localWorkspace, INITCONC_EXTDATA_NAME);
Extent extent = initRefConc.getExtent();
Origin origin = initRefConc.getOrigin();
ISize isize = new ISize(initRefConc.getNumX(), initRefConc.getNumY(), initRefConc.getNumZ());
saveExternalData(initRefConc, INITCONC_EXTDATA_VARNAME, initialConcentrationExtData.getExternalDataIdentifier(), localWorkspace);
FieldFunctionArguments initConditionFFA = new FieldFunctionArguments(INITCONC_EXTDATA_NAME, INITCONC_EXTDATA_VARNAME, new Expression(0.0), VariableType.VOLUME);
BioModel bioModel = createRefSimBioModel(simKey, owner, origin, extent, cellROI, timeStepVal, timeBounds, VAR_NAME, new Expression(initConditionFFA.infix()), baseDiffusionRate);
if (progressListener != null) {
progressListener.setMessage("Running Reference Simulation...");
}
// run simulation
runFVSolverStandalone(new File(localWorkspace.getDefaultSimDataDirectory()), bioModel.getSimulation(0), initialConcentrationExtData.getExternalDataIdentifier(), progressListener, true);
VCDataIdentifier vcDataIdentifier = new VCSimulationDataIdentifier(new VCSimulationIdentifier(simKey, owner), 0);
double[] dataTimes = localWorkspace.getDataSetControllerImpl().getDataSetTimes(vcDataIdentifier);
FloatImage[] solutionImages = new FloatImage[dataTimes.length];
for (int i = 0; i < dataTimes.length; i++) {
SimDataBlock simDataBlock = localWorkspace.getDataSetControllerImpl().getSimDataBlock(null, vcDataIdentifier, VAR_NAME, dataTimes[i]);
double[] doubleData = simDataBlock.getData();
float[] floatPixels = new float[doubleData.length];
for (int j = 0; j < doubleData.length; j++) {
floatPixels[j] = (float) doubleData[j];
}
solutionImages[i] = new FloatImage(floatPixels, origin, extent, isize.getX(), isize.getY(), isize.getZ());
}
ImageTimeSeries<FloatImage> solution = new ImageTimeSeries<FloatImage>(FloatImage.class, solutionImages, dataTimes, 1);
return solution;
}
Aggregations