use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class ROIAssistPanel method resolveCurrentROI.
private void resolveCurrentROI() {
final String CELL_ROI = "CELL_ROI";
AsynchClientTask keepRegionsTask = new AsynchClientTask("Pick Region", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
// TODO Auto-generated method stub
RegionInfo[] keepRegionInfos = pickKeepRegionInfoFromCurrentROI();
if (keepRegionInfos == null) {
throw UserCancelException.CANCEL_GENERIC;
}
// dataToThreshold.getCurrentlyDisplayedROI().getPixelsXYZ();
short[] keepPixels = new short[dataToThreshold.getCurrentlyDisplayedROI().getISize().getXYZ()];
for (int i = 0; i < keepPixels.length; i++) {
for (int j = 0; j < keepRegionInfos.length; j++) {
if (keepRegionInfos[j].isIndexInRegion(i)) {
keepPixels[i] = 1;
}
}
}
UShortImage ushortImage = new UShortImage(keepPixels, originalROI.getRoiImages()[0].getOrigin(), originalROI.getRoiImages()[0].getExtent(), originalROI.getISize().getX(), originalROI.getISize().getY(), originalROI.getISize().getZ());
ROI newCellROI = new ROI(ushortImage, originalROI.getROIName());
hashTable.put(CELL_ROI, newCellROI);
}
};
AsynchClientTask updateDisplayTask = new AsynchClientTask("Updating display", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
dataToThreshold.addReplaceRoi((ROI) hashTable.get(CELL_ROI));
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { keepRegionsTask, updateDisplayTask }, false, false, null, true);
}
use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class ROIMultiPaintManager method initImageDataSet.
private void initImageDataSet(short[][] dataToSegmentChannels, ISize uncroppedISize) throws Exception {
initImageDataSetChannels = new ImageDataset[(dataToSegmentChannels != null ? dataToSegmentChannels.length : 1)];
for (int c = 0; c < initImageDataSetChannels.length; c++) {
UShortImage[] zImageSet = new UShortImage[uncroppedISize.getZ()];
for (int i = 0; i < zImageSet.length; i++) {
short[] shortData = new short[uncroppedISize.getX() * uncroppedISize.getY()];
if (dataToSegmentChannels != null) {
System.arraycopy(dataToSegmentChannels[c], shortData.length * i, shortData, 0, shortData.length);
}
zImageSet[i] = new UShortImage(shortData, DEFAULT_ORIGIN, DEFAULT_EXTENT, uncroppedISize.getX(), uncroppedISize.getY(), 1);
}
initImageDataSetChannels[c] = new ImageDataset(zImageSet, new double[] { 0.0 }, uncroppedISize.getZ());
}
}
use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class ROIMultiPaintManager method calculateAllPixelValuesRangeChannels0.
private static OverlayEditorPanelJAI.AllPixelValuesRange[] calculateAllPixelValuesRangeChannels0(ImageDataset[] sourceImageDatasetChannels) {
OverlayEditorPanelJAI.AllPixelValuesRange[] pixelValuesRangeChannels = new OverlayEditorPanelJAI.AllPixelValuesRange[sourceImageDatasetChannels.length];
for (int c = 0; c < sourceImageDatasetChannels.length; c++) {
UShortImage[] allImages = sourceImageDatasetChannels[c].getAllImages();
double min = 0;
double max = min;
for (int i = 0; i < allImages.length; i++) {
ImageStatistics imageStats = allImages[i].getImageStatistics();
if (i == 0 || imageStats.minValue < min) {
min = imageStats.minValue;
}
if (i == 0 || imageStats.maxValue > max) {
max = imageStats.maxValue;
}
}
pixelValuesRangeChannels[c] = new OverlayEditorPanelJAI.AllPixelValuesRange((int) min, (int) max);
}
return pixelValuesRangeChannels;
}
use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class FluorescenceNoiseTest method testBrownianDynamics.
private void testBrownianDynamics() throws ImageException {
Origin origin = new Origin(0, 0, 0);
Extent extent = new Extent(10, 10, 1);
double psfVar = 0.25 * 0.25;
// typically 10000 or 100000;
int numParticles = 10000;
double diffusionRate = 1;
double bleachRadius = 0.25;
final double bleachAmplitude = 0.5;
final double bleachRadius2 = bleachRadius * bleachRadius;
double endTime = 10;
int numTimes = 1000;
final BrownianDynamics2DSolver solver = new BrownianDynamics2DSolver(origin, extent, numParticles);
boolean initiallyFluorescent = true;
solver.initializeUniform(initiallyFluorescent);
double totalBleachTime = 0.00001;
int numBleachSteps = 1;
double bleachCenterX = origin.getX() + 0.5 * extent.getX();
double bleachCenterY = origin.getY() + 0.5 * extent.getY();
double bleachPsfVariance = psfVar;
double bleachFactor_K = 1000000;
solver.bleachGuassian(diffusionRate, totalBleachTime, numBleachSteps, bleachCenterX, bleachCenterY, bleachPsfVariance, bleachFactor_K);
// ParticleVisitor bleachGaussian = new ParticleVisitor() {
// UniformRealDistribution uniform = new UniformRealDistribution();
//
// @Override
// public void visit(double x, double y, boolean bFluorescent, int index) {
// // TODO Auto-generated method stub
// double radius2 = x*x + y*y;
// double bleachProb = bleachAmplitude * FastMath.exp(-radius2/bleachRadius2);
// if (uniform.sample() < bleachProb){
// solver.setFluorescence(index,false);
// }else{
// solver.setFluorescence(index,true);
// }
// }
// };
// solver.visit(bleachGaussian);
double totalSampleTime = 0.1;
int numSampleSteps = 1;
double samplePsfVariance = psfVar;
double detectorGainAndQuantumYeild = 100;
boolean bNoise = true;
boolean bConvolve = true;
UShortImage sampledImage = solver.sampleImage(100, 100, origin, extent, diffusionRate, totalSampleTime, numSampleSteps, samplePsfVariance, detectorGainAndQuantumYeild, bConvolve, bNoise);
new DisplayImageOp().displayImage(sampledImage, "initialBleach", null);
}
use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class VFrapProcess method main.
public static void main(String[] args) {
try {
File baseDir = new File(".");
// File baseDir = new File("/Users/schaff/Documents/workspace/VCell_5.4");
// initialize computing environment
//
File workingDirectory = new File(baseDir, "workingDir");
LocalWorkspace localWorkspace = new LocalWorkspace(workingDirectory);
//
// import raw image time series data from VFRAP file format (can have noise, background, etc ... can be actual microscopy data)
//
ClientTaskStatusSupport progressListener = new ClientTaskStatusSupport() {
String message = "";
int progress = 0;
@Override
public void setProgress(int progress) {
this.progress = progress;
}
@Override
public void setMessage(String message) {
this.message = message;
}
@Override
public boolean isInterrupted() {
return false;
}
@Override
public int getProgress() {
return progress;
}
@Override
public void addProgressDialogListener(ProgressDialogListener progressDialogListener) {
}
};
//
// generate fake data (and save?)
//
// ImageTimeSeries<UShortImage> simulatedFluorescence = generateFakeData(localWorkspace, progressListener);
// new ExportRawTimeSeriesToVFrapOp().exportToVFRAP(vfrapFile, simulatedFluorescence, null);
//
// analyze raw data (from file?) using Keyworthy method.
//
File vfrapFile = new File(baseDir, "vfrapPaper/rawData/sim3/workflow.txt.save");
ImageTimeSeries<UShortImage> fluorTimeSeriesImages = new ImportRawTimeSeriesFromVFrapOp().importRawTimeSeriesFromVFrap(vfrapFile);
VFrapProcessResults results = compute(fluorTimeSeriesImages, 0.85, 0.4, localWorkspace, progressListener);
new DisplayTimeSeriesOp().displayImageTimeSeries(fluorTimeSeriesImages, "raw data", null);
new DisplayImageOp().displayImage(results.cellROI_2D.getRoiImages()[0], "cell ROI", null);
new DisplayImageOp().displayImage(results.bleachROI_2D.getRoiImages()[0], "bleach ROI", null);
new DisplayDependentROIsOp().displayDependentROIs(results.imageDataROIs, results.cellROI_2D, "data rois", null);
new DisplayTimeSeriesOp().displayImageTimeSeries(results.normalizedTimeSeries, "normalized data", null);
new DisplayProfileLikelihoodPlotsOp().displayProfileLikelihoodPlots(results.profileDataOne, "one fluorescent pool", null);
new DisplayProfileLikelihoodPlotsOp().displayProfileLikelihoodPlots(results.profileDataTwoWithPenalty, "too pools", null);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
Aggregations