use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class FluorescenceNoiseTest method getUniformFluorescenceImage.
private UShortImage getUniformFluorescenceImage(ISize size, Extent extent, Origin origin, double mean) throws ImageException {
ExponentialDistribution expDistribution = new ExponentialDistribution(mean);
short[] shortPixels = new short[size.getXYZ()];
for (int i = 0; i < shortPixels.length; i++) {
// consider that we have unsigned short (must use 32 bit integer first)
double sample = expDistribution.sample();
if (sample > 65535) {
sample = 65535;
System.err.println("sample " + sample + " overflows 16 bit unsigned");
}
shortPixels[i] = (short) (0xffff & ((int) Math.round(sample)));
}
UShortImage rawImage = new UShortImage(shortPixels, origin, extent, size.getX(), size.getY(), size.getZ());
return rawImage;
}
use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class KenworthyWorkflowTest method generateFakeData.
private static ImageTimeSeries<UShortImage> generateFakeData(LocalWorkspace localWorkspace, ClientTaskStatusSupport progressListener) throws Exception {
//
// technical simulation parameters
//
double deltaX = 0.3;
double outputTimeStep = 0.3;
//
// circular 2D cell geometry
//
double cellRadius = 50.0;
String extracellularName = "ec";
String cytosolName = "cytosol";
//
// bleaching experimental protocol
//
double bleachRadius = 1.5;
double bleachDuration = 0.003;
double bleachRate = 500.0;
double postbleachDelay = 0.001;
double postbleachDuration = 25.0;
double psfSigma = 0.01;
//
// underlying physiological model
//
double primaryDiffusionRate = 2.0;
double primaryFraction = 1.0;
double bleachMonitorRate = 0.0000005;
double secondaryDiffusionRate = 0.0;
double secondaryFraction = 0.0;
//
// generate corresponding BioModel with Application and Simulation ready for simulation.
//
Context context = new Context() {
@Override
public User getDefaultOwner() {
return LocalWorkspace.getDefaultOwner();
}
@Override
public KeyValue createNewKeyValue() {
return LocalWorkspace.createNewKeyValue();
}
};
GeneratedModelResults results = new Generate2DExpModel_GaussianBleachOp().generateModel(deltaX, bleachRadius, cellRadius, bleachDuration, bleachRate, postbleachDelay, postbleachDuration, psfSigma, outputTimeStep, primaryDiffusionRate, primaryFraction, bleachMonitorRate, secondaryDiffusionRate, secondaryFraction, extracellularName, cytosolName, context);
Simulation simulation = results.simulation_2D;
double bleachBlackoutStartTime = results.bleachBlackoutBeginTime;
double bleachBlackoutStopTime = results.bleachBlackoutEndTime;
//
// run simulation to get simulated fluorescence (with noise)
//
boolean hasNoise = true;
double maxIntensity = 60000.0;
ImageTimeSeries<UShortImage> simulatedFluorescence = new RunFakeSimOp().runRefSimulation(localWorkspace, simulation, maxIntensity, bleachBlackoutStartTime, bleachBlackoutStopTime, hasNoise, progressListener);
return simulatedFluorescence;
}
use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class KenworthyWorkflowTest 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");
// File vfrapFile = new File(baseDir, "tryit.vfrap");
ImageTimeSeries<UShortImage> fluorTimeSeriesImages = new ImportRawTimeSeriesFromVFrapOp().importRawTimeSeriesFromVFrap(vfrapFile);
analyzeKeyworthy(fluorTimeSeriesImages, localWorkspace);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class KenworthyParticleTest 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);
//
// analyze raw data (from file?) using Keyworthy method.
//
// File vfrapFile = new File(baseDir, "vfrapPaper/rawData/sim3/workflow.txt.save");
File vfrapFile = new File(baseDir, "tryit.vfrap");
ImageTimeSeries<UShortImage> fluorTimeSeriesImages = new ImportRawTimeSeriesFromVFrapOp().importRawTimeSeriesFromVFrap(vfrapFile);
RowColumnResultSet reducedData = new CSV().importFrom(new FileReader(new File(baseDir, "tryit.csv")));
analyzeKeyworthy(fluorTimeSeriesImages, reducedData, localWorkspace);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class PhotoactivationExperimentTest method generateFakeData.
private static ImageTimeSeries<UShortImage> generateFakeData(LocalWorkspace localWorkspace, ClientTaskStatusSupport progressListener) throws Exception {
//
// technical simulation parameters
//
double deltaX = 0.3;
double outputTimeStep = 0.3;
//
// circular 2D cell geometry
//
double cellRadius = 50.0;
String extracellularName = "ec";
String cytosolName = "cytosol";
//
// bleaching experimental protocol
//
double bleachRadius = 1.5;
double bleachDuration = 0.003;
double bleachRate = 500.0;
double postbleachDelay = 0.001;
double postbleachDuration = 25.0;
double psfSigma = 0.01;
//
// underlying physiological model
//
double primaryDiffusionRate = 2.0;
double primaryFraction = 1.0;
double bleachMonitorRate = 0.0000005;
double secondaryDiffusionRate = 0.0;
double secondaryFraction = 0.0;
//
// generate corresponding BioModel with Application and Simulation ready for simulation.
//
Context context = new Context() {
@Override
public User getDefaultOwner() {
return LocalWorkspace.getDefaultOwner();
}
@Override
public KeyValue createNewKeyValue() {
return LocalWorkspace.createNewKeyValue();
}
};
GeneratedModelResults results = new Generate2DExpModel_GaussianBleachOp().generateModel(deltaX, bleachRadius, cellRadius, bleachDuration, bleachRate, postbleachDelay, postbleachDuration, psfSigma, outputTimeStep, primaryDiffusionRate, primaryFraction, bleachMonitorRate, secondaryDiffusionRate, secondaryFraction, extracellularName, cytosolName, context);
Simulation simulation = results.simulation_2D;
double bleachBlackoutStartTime = results.bleachBlackoutBeginTime;
double bleachBlackoutStopTime = results.bleachBlackoutEndTime;
//
// run simulation to get simulated fluorescence (with noise)
//
boolean hasNoise = true;
double maxIntensity = 60000.0;
ImageTimeSeries<UShortImage> simulatedFluorescence = new RunFakeSimOp().runRefSimulation(localWorkspace, simulation, maxIntensity, bleachBlackoutStartTime, bleachBlackoutStopTime, hasNoise, progressListener);
return simulatedFluorescence;
}
Aggregations