Search in sources :

Example 6 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 7 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 8 with FloatImage

use of cbit.vcell.VirtualMicroscopy.FloatImage in project vcell by virtualcell.

the class NormalizedSampleFunction method fromGaussian.

public static NormalizedSampleFunction fromGaussian(String name, Origin origin, Extent extent, ISize size, double muX, double muY, double sigma) throws ImageException {
    if (size.getZ() > 1) {
        throw new RuntimeException("NormalizedSampleFunction doesn't yet support 3D functions");
    }
    double var = sigma * sigma;
    int numX = size.getX();
    int numY = size.getY();
    double oX = origin.getX();
    double oY = origin.getY();
    double eX = extent.getX();
    double eY = extent.getY();
    float[] pixels = new float[size.getXYZ()];
    if (sigma < eX / numX) {
        throw new RuntimeException("psf not properly sampled, sigma=" + sigma + ", pixelSize=" + (eX / numX));
    }
    // 
    // set unnormalized Gaussian (don't bother dividing by 2*pi*sigma, need the sampled version to sum to 1.0 anyway).
    // record sum for normalization
    // 
    int index = 0;
    double sum = 0.0;
    double max = Double.NEGATIVE_INFINITY;
    for (int j = 0; j < numY; j++) {
        double y = (j + 0.5) * eY / (numY - 1);
        double rY_squared = (y - muY) * (y - muY);
        for (int i = 0; i < numX; i++) {
            double x = (i + 0.5) * eX / (numX - 1);
            double rX_squared = (x - muX) * (x - muX);
            double distanceSquared = rX_squared + rY_squared;
            double unnormalizedGaussian = FastMath.exp(-distanceSquared / var);
            sum += unnormalizedGaussian;
            max = Math.max(unnormalizedGaussian, max);
            pixels[index++] = (float) unnormalizedGaussian;
        }
    }
    // 
    if (sum <= 0.0) {
        throw new RuntimeException("Gaussian sample summed to " + sum + ", unexpected - cannot normalize");
    }
    for (index = 0; index < pixels.length; index++) {
        pixels[index] /= max;
    }
    FloatImage sample = new FloatImage(pixels, origin, extent, size.getX(), size.getY(), size.getZ());
    return new NormalizedSampleFunction(name, sample);
}
Also used : FloatImage(cbit.vcell.VirtualMicroscopy.FloatImage)

Example 9 with FloatImage

use of cbit.vcell.VirtualMicroscopy.FloatImage in project vcell by virtualcell.

the class NormalizedSampleFunction method createUniform.

public static NormalizedSampleFunction createUniform(String name, Origin origin, Extent extent, ISize size) throws ImageException {
    if (size.getZ() > 1) {
        throw new RuntimeException("NormalizedSampleFunction doesn't yet support 3D functions");
    }
    float[] pixels = new float[size.getXYZ()];
    Arrays.fill(pixels, 1.0f);
    // double sum = size.getXYZ(); // each element is initially 1.0f
    // //
    // // normalize so that sampled image sums to one
    // //
    // for (int index=0; index<pixels.length; index++){
    // pixels[index] /= sum;
    // }
    FloatImage sample = new FloatImage(pixels, origin, extent, size.getX(), size.getY(), size.getZ());
    return new NormalizedSampleFunction(name, sample);
}
Also used : FloatImage(cbit.vcell.VirtualMicroscopy.FloatImage)

Example 10 with FloatImage

use of cbit.vcell.VirtualMicroscopy.FloatImage in project vcell by virtualcell.

the class RunRefSimulationFastOp method runRefSimFast.

public RowColumnResultSet runRefSimFast(ROI cellROI_2D, ImageTimeSeries<FloatImage> normalizedTimeSeries, ROI[] imageDataROIs, UShortImage psf, LocalWorkspace localWorkspace, final ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    double[] timeStamps = normalizedTimeSeries.getImageTimeStamps();
    FloatImage initRefConc = normalizedTimeSeries.getAllImages()[0];
    double experimentalRecoveryTime = timeStamps[timeStamps.length - 1] - timeStamps[0];
    RowColumnResultSet reducedData = runRefSimulation(cellROI_2D, imageDataROIs, psf, initRefConc, experimentalRecoveryTime, localWorkspace, clientTaskStatusSupport);
    return reducedData;
}
Also used : FloatImage(cbit.vcell.VirtualMicroscopy.FloatImage) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet)

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