use of org.vcell.vmicro.op.GenerateTrivial2DPsfOp in project vcell by virtualcell.
the class VFrapProcess method compute.
public static VFrapProcessResults compute(ImageTimeSeries rawTimeSeriesImages, double bleachThreshold, double cellThreshold, LocalWorkspace localWorkspace, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
GenerateCellROIsFromRawFrapTimeSeriesOp generateCellROIs = new GenerateCellROIsFromRawFrapTimeSeriesOp();
GeometryRoisAndBleachTiming geometryAndTiming = generateCellROIs.generate(rawTimeSeriesImages, cellThreshold);
GenerateNormalizedFrapDataOp generateNormalizedFrapData = new GenerateNormalizedFrapDataOp();
NormalizedFrapDataResults normalizedFrapResults = generateNormalizedFrapData.generate(rawTimeSeriesImages, geometryAndTiming.backgroundROI_2D, geometryAndTiming.indexOfFirstPostbleach);
GenerateBleachRoiOp generateROIs = new GenerateBleachRoiOp();
ROI bleachROI = generateROIs.generateBleachRoi(normalizedFrapResults.normalizedFrapData.getAllImages()[0], geometryAndTiming.cellROI_2D, bleachThreshold);
GenerateDependentImageROIsOp generateDependentROIs = new GenerateDependentImageROIsOp();
ROI[] dataROIs = generateDependentROIs.generate(geometryAndTiming.cellROI_2D, bleachROI);
NormalizedSampleFunction[] roiSampleFunctions = new NormalizedSampleFunction[dataROIs.length];
for (int i = 0; i < dataROIs.length; i++) {
roiSampleFunctions[i] = NormalizedSampleFunction.fromROI(dataROIs[i]);
}
GenerateReducedDataOp generateReducedNormalizedData = new GenerateReducedDataOp();
RowColumnResultSet reducedData = generateReducedNormalizedData.generateReducedData(normalizedFrapResults.normalizedFrapData, roiSampleFunctions);
ComputeMeasurementErrorOp computeMeasurementError = new ComputeMeasurementErrorOp();
RowColumnResultSet measurementError = computeMeasurementError.computeNormalizedMeasurementError(roiSampleFunctions, geometryAndTiming.indexOfFirstPostbleach, rawTimeSeriesImages, normalizedFrapResults.prebleachAverage, clientTaskStatusSupport);
GenerateTrivial2DPsfOp psf_2D = new GenerateTrivial2DPsfOp();
UShortImage psf = psf_2D.generateTrivial2D_Psf();
// RunRefSimulationOp runRefSimulationFull = new RunRefSimulationOp();
// GenerateReducedROIDataOp generateReducedRefSimData = new GenerateReducedROIDataOp();
RunRefSimulationFastOp runRefSimulationFast = new RunRefSimulationFastOp();
RowColumnResultSet refData = runRefSimulationFast.runRefSimFast(geometryAndTiming.cellROI_2D, normalizedFrapResults.normalizedFrapData, dataROIs, psf, localWorkspace, clientTaskStatusSupport);
final double refDiffusionRate = 1.0;
double[] refSimTimePoints = refData.extractColumn(0);
int numRois = refData.getDataColumnCount() - 1;
int numRefSimTimes = refData.getRowCount();
double[][] refSimData = new double[numRois][numRefSimTimes];
for (int roi = 0; roi < numRois; roi++) {
double[] roiData = refData.extractColumn(roi + 1);
for (int t = 0; t < numRefSimTimes; t++) {
refSimData[roi][t] = roiData[t];
}
}
ErrorFunction errorFunction = new ErrorFunctionNoiseWeightedL2();
OptModelOneDiff optModelOneDiff = new OptModelOneDiff(refSimData, refSimTimePoints, refDiffusionRate);
Generate2DOptContextOp generate2DOptContextOne = new Generate2DOptContextOp();
OptContext optContextOneDiff = generate2DOptContextOne.generate2DOptContext(optModelOneDiff, reducedData, measurementError, errorFunction);
RunProfileLikelihoodGeneralOp runProfileLikelihoodOne = new RunProfileLikelihoodGeneralOp();
ProfileData[] profileDataOne = runProfileLikelihoodOne.runProfileLikihood(optContextOneDiff, clientTaskStatusSupport);
// OptModelTwoDiffWithoutPenalty optModelTwoDiffWithoutPenalty = new OptModelTwoDiffWithoutPenalty(refSimData, refSimTimePoints, refDiffusionRate);
// Generate2DOptContextOp generate2DOptContextTwoWithoutPenalty = new Generate2DOptContextOp();
// OptContext optContextTwoDiffWithoutPenalty = generate2DOptContextTwoWithoutPenalty.generate2DOptContext(optModelTwoDiffWithoutPenalty, reducedData, measurementError);
// RunProfileLikelihoodGeneralOp runProfileLikelihoodTwoWithoutPenalty = new RunProfileLikelihoodGeneralOp();
// ProfileData[] profileDataTwoWithoutPenalty = runProfileLikelihoodTwoWithoutPenalty.runProfileLikihood(optContextTwoDiffWithoutPenalty, clientTaskStatusSupport);
OptModelTwoDiffWithPenalty optModelTwoDiffWithPenalty = new OptModelTwoDiffWithPenalty(refSimData, refSimTimePoints, refDiffusionRate);
Generate2DOptContextOp generate2DOptContextTwoWithPenalty = new Generate2DOptContextOp();
OptContext optContextTwoDiffWithPenalty = generate2DOptContextTwoWithPenalty.generate2DOptContext(optModelTwoDiffWithPenalty, reducedData, measurementError, errorFunction);
RunProfileLikelihoodGeneralOp runProfileLikelihoodTwoWithPenalty = new RunProfileLikelihoodGeneralOp();
ProfileData[] profileDataTwoWithPenalty = runProfileLikelihoodTwoWithPenalty.runProfileLikihood(optContextTwoDiffWithPenalty, clientTaskStatusSupport);
//
// SLOW WAY
//
// runRefSimulationFull.cellROI_2D,generateCellROIs.cellROI_2D);
// runRefSimulationFull.normalizedTimeSeries,generateNormalizedFrapData.normalizedFrapData);
// workflow.addTask(runRefSimulationFull);
// generateReducedRefSimData.imageTimeSeries,runRefSimulationFull.refSimTimeSeries);
// generateReducedRefSimData.imageDataROIs,generateDependentROIs.imageDataROIs);
// workflow.addTask(generateReducedRefSimData);
// DataHolder<RowColumnResultSet> reducedROIData = generateReducedRefSimData.reducedROIData;
// DataHolder<Double> refSimDiffusionRate = runRefSimulationFull.refSimDiffusionRate;
VFrapProcessResults results = new VFrapProcessResults(dataROIs, geometryAndTiming.cellROI_2D, bleachROI, normalizedFrapResults.normalizedFrapData, reducedData, profileDataOne, profileDataTwoWithPenalty);
return results;
}
use of org.vcell.vmicro.op.GenerateTrivial2DPsfOp in project vcell by virtualcell.
the class GenerateTrivial2DPsf method compute0.
@Override
protected void compute0(TaskContext context, final ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
// do op
GenerateTrivial2DPsfOp op = new GenerateTrivial2DPsfOp();
UShortImage psf = op.generateTrivial2D_Psf();
// set output
context.setData(psf_2D, psf);
}
Aggregations