Search in sources :

Example 1 with FloatImage

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);
}
Also used : FloatImage(cbit.vcell.VirtualMicroscopy.FloatImage) FitBleachSpotOpResults(org.vcell.vmicro.op.FitBleachSpotOp.FitBleachSpotOpResults) NormalizedSampleFunction(org.vcell.vmicro.workflow.data.NormalizedSampleFunction) FitBleachSpotOp(org.vcell.vmicro.op.FitBleachSpotOp)

Example 2 with FloatImage

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);
}
Also used : RunRefSimulationOp(org.vcell.vmicro.op.RunRefSimulationOp) FloatImage(cbit.vcell.VirtualMicroscopy.FloatImage) ROI(cbit.vcell.VirtualMicroscopy.ROI)

Example 3 with FloatImage

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);
}
Also used : FloatImage(cbit.vcell.VirtualMicroscopy.FloatImage) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage)

Example 4 with FloatImage

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;
}
Also used : TimeBounds(cbit.vcell.solver.TimeBounds) FloatImage(cbit.vcell.VirtualMicroscopy.FloatImage)

Example 5 with FloatImage

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;
}
Also used : Origin(org.vcell.util.Origin) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) FloatImage(cbit.vcell.VirtualMicroscopy.FloatImage) ExternalDataInfo(org.vcell.vmicro.workflow.data.ExternalDataInfo) Extent(org.vcell.util.Extent) FieldFunctionArguments(cbit.vcell.field.FieldFunctionArguments) ISize(org.vcell.util.ISize) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) SimDataBlock(cbit.vcell.simdata.SimDataBlock) Expression(cbit.vcell.parser.Expression) BioModel(cbit.vcell.biomodel.BioModel) File(java.io.File) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) ImageTimeSeries(org.vcell.vmicro.workflow.data.ImageTimeSeries)

Aggregations

FloatImage (cbit.vcell.VirtualMicroscopy.FloatImage)18 UShortImage (cbit.vcell.VirtualMicroscopy.UShortImage)6 Extent (org.vcell.util.Extent)6 ROI (cbit.vcell.VirtualMicroscopy.ROI)5 RowColumnResultSet (cbit.vcell.math.RowColumnResultSet)5 ISize (org.vcell.util.ISize)4 Origin (org.vcell.util.Origin)4 ImageTimeSeries (org.vcell.vmicro.workflow.data.ImageTimeSeries)4 ComputeMeasurementErrorOp (org.vcell.vmicro.op.ComputeMeasurementErrorOp)3 NormalizedSampleFunction (org.vcell.vmicro.workflow.data.NormalizedSampleFunction)3 SimDataBlock (cbit.vcell.simdata.SimDataBlock)2 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)2 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)2 File (java.io.File)2 KeyValue (org.vcell.util.document.KeyValue)2 User (org.vcell.util.document.User)2 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)2 FitBleachSpotOp (org.vcell.vmicro.op.FitBleachSpotOp)2 FitBleachSpotOpResults (org.vcell.vmicro.op.FitBleachSpotOp.FitBleachSpotOpResults)2 Generate2DOptContextOp (org.vcell.vmicro.op.Generate2DOptContextOp)2