Search in sources :

Example 1 with SampleStatistics

use of org.vcell.vmicro.workflow.data.NormalizedSampleFunction.SampleStatistics in project vcell by virtualcell.

the class FluorescenceNoiseTest method doit.

private void doit() throws ImageException {
    int[] sizes = new int[] { 1, 2, 4, 8, 16, 32, 64, 128, 256 };
    for (int imageSize : sizes) {
        ISize size = new ISize(imageSize, imageSize, 1);
        Extent extent = new Extent(1, 1, 1);
        Origin origin = new Origin(0, 0, 0);
        // NormalizedSampleFunction sampleFunction = NormalizedSampleFunction.createUniform("uniformROI", origin, extent, size);
        NormalizedSampleFunction sampleFunction = NormalizedSampleFunction.fromGaussian("testGaussian", origin, extent, size, 0.5, 0.2, 0.1);
        SampleStatistics[] samples = new SampleStatistics[NUM_TRIALS];
        for (int i = 0; i < NUM_TRIALS; i++) {
            UShortImage rawImage = getUniformFluorescenceImage(size, extent, origin, MEAN_INTENSITY);
            samples[i] = sampleFunction.sample(rawImage);
        }
        Mean mean = new Mean();
        Variance var = new Variance();
        double[] weightedMeans = getWeightedMeans(samples);
        double[] weightedVariances = getWeightedVariances(samples);
        double weightedMeansVariance = var.evaluate(weightedMeans);
        double weightedMeansMean = mean.evaluate(weightedMeans);
        double weightedVarVariance = var.evaluate(weightedVariances);
        double weightedVarMean = mean.evaluate(weightedVariances);
        double V1 = samples[0].sumOfWeights;
        double V2 = samples[0].sumOfWeightsSquared;
        System.out.println("image is " + imageSize + "x" + imageSize + ", V1=" + V1 + ", V2=" + V2 + ", numTrials=" + NUM_TRIALS + ", sample means (mu=" + weightedMeansMean + ",s=" + weightedMeansVariance + "), sample variances (mu=" + weightedVarMean + ",s=" + weightedVarVariance);
    }
}
Also used : Origin(org.vcell.util.Origin) Mean(org.apache.commons.math3.stat.descriptive.moment.Mean) Extent(org.vcell.util.Extent) ISize(org.vcell.util.ISize) SampleStatistics(org.vcell.vmicro.workflow.data.NormalizedSampleFunction.SampleStatistics) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) Variance(org.apache.commons.math3.stat.descriptive.moment.Variance) NormalizedSampleFunction(org.vcell.vmicro.workflow.data.NormalizedSampleFunction)

Example 2 with SampleStatistics

use of org.vcell.vmicro.workflow.data.NormalizedSampleFunction.SampleStatistics in project vcell by virtualcell.

the class GenerateReducedDataOp method generateReducedData.

public RowColumnResultSet generateReducedData(ImageTimeSeries<? extends Image> imageTimeSeries, NormalizedSampleFunction[] rois) throws Exception {
    int numROIs = rois.length;
    int numTimes = imageTimeSeries.getSizeT();
    String[] roiNames = new String[numROIs + 1];
    roiNames[0] = "t";
    for (int i = 0; i < numROIs; i++) {
        roiNames[i + 1] = rois[i].getName();
    }
    RowColumnResultSet reducedData = new RowColumnResultSet(roiNames);
    for (int t = 0; t < numTimes; t++) {
        double[] row = new double[numROIs + 1];
        row[0] = imageTimeSeries.getImageTimeStamps()[t];
        for (int r = 0; r < numROIs; r++) {
            SampleStatistics result = rois[r].sample(imageTimeSeries.getAllImages()[t]);
            row[r + 1] = result.weightedMean;
        }
        reducedData.addRow(row);
    }
    return reducedData;
}
Also used : SampleStatistics(org.vcell.vmicro.workflow.data.NormalizedSampleFunction.SampleStatistics) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet)

Aggregations

SampleStatistics (org.vcell.vmicro.workflow.data.NormalizedSampleFunction.SampleStatistics)2 UShortImage (cbit.vcell.VirtualMicroscopy.UShortImage)1 RowColumnResultSet (cbit.vcell.math.RowColumnResultSet)1 Mean (org.apache.commons.math3.stat.descriptive.moment.Mean)1 Variance (org.apache.commons.math3.stat.descriptive.moment.Variance)1 Extent (org.vcell.util.Extent)1 ISize (org.vcell.util.ISize)1 Origin (org.vcell.util.Origin)1 NormalizedSampleFunction (org.vcell.vmicro.workflow.data.NormalizedSampleFunction)1