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);
}
}
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;
}
Aggregations