Search in sources :

Example 1 with BrownianDynamics2DSolver

use of org.vcell.vmicro.op.BrownianDynamics2DSolver 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);
}
Also used : Origin(org.vcell.util.Origin) DisplayImageOp(org.vcell.vmicro.op.display.DisplayImageOp) Extent(org.vcell.util.Extent) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) BrownianDynamics2DSolver(org.vcell.vmicro.op.BrownianDynamics2DSolver)

Example 2 with BrownianDynamics2DSolver

use of org.vcell.vmicro.op.BrownianDynamics2DSolver in project vcell by virtualcell.

the class BrownianDynamicsTest method generateTestData.

private ImageTimeSeries<UShortImage> generateTestData(Origin origin, Extent extent, int numX, int numY, int numParticles, double diffusionRate, double psfVar, double bleachRadius, boolean bNoise, boolean bConvolve, double bleachDuration, double endTime) throws ImageException {
    double detectorGainAndQuantumYeild = 100;
    double totalSampleTime = 0.2;
    int numSampleSteps = 1;
    int numPrebleach = 2;
    ArrayList<UShortImage> images = new ArrayList<UShortImage>();
    ArrayList<Double> times = new ArrayList<Double>();
    final BrownianDynamics2DSolver solver = new BrownianDynamics2DSolver(origin, extent, numParticles);
    boolean initiallyFluorescent = true;
    solver.initializeUniform(initiallyFluorescent);
    // simulate and write prebleach images
    for (int i = 0; i < numPrebleach; i++) {
        images.add(solver.sampleImage(numX, numY, origin, extent, diffusionRate, totalSampleTime, numSampleSteps, psfVar, detectorGainAndQuantumYeild, bConvolve, bNoise));
        times.add(solver.currentTime());
    }
    int numBleachSteps = 1;
    double bleachCenterX = origin.getX() + 0.5 * extent.getX();
    double bleachCenterY = origin.getY() + 0.5 * extent.getY();
    double bleachPsfVariance = bleachRadius;
    double bleachFactor_K = 10 / bleachDuration;
    solver.bleachGuassian(diffusionRate, bleachDuration, numBleachSteps, bleachCenterX, bleachCenterY, bleachPsfVariance, bleachFactor_K);
    // wait
    double postbleachDelay = 0.1;
    solver.step(diffusionRate, postbleachDelay);
    while (solver.currentTime() < endTime) {
        double samplePsfVariance = psfVar;
        images.add(solver.sampleImage(numX, numY, origin, extent, diffusionRate, totalSampleTime, numSampleSteps, psfVar, detectorGainAndQuantumYeild, bConvolve, bNoise));
        times.add(solver.currentTime());
    // solver.step(diffusionRate, 1-totalSampleTime);
    }
    double[] timeArray = new double[times.size()];
    for (int i = 0; i < timeArray.length; i++) {
        timeArray[i] = times.get(i);
    }
    UShortImage[] imageArray = images.toArray(new UShortImage[images.size()]);
    return new ImageTimeSeries<UShortImage>(UShortImage.class, imageArray, timeArray, 1);
}
Also used : ArrayList(java.util.ArrayList) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) BrownianDynamics2DSolver(org.vcell.vmicro.op.BrownianDynamics2DSolver) ImageTimeSeries(org.vcell.vmicro.workflow.data.ImageTimeSeries)

Example 3 with BrownianDynamics2DSolver

use of org.vcell.vmicro.op.BrownianDynamics2DSolver in project vcell by virtualcell.

the class FluorescenceNoiseTest method generateTestData.

private ImageTimeSeries<UShortImage> generateTestData(Origin origin, Extent extent, int numX, int numY, int numParticles, double diffusionRate, double psfVar, double bleachRadius, boolean bNoise, boolean bConvolve) throws ImageException {
    double detectorGainAndQuantumYeild = 100;
    double totalSampleTime = 0.5;
    int numSampleSteps = 1;
    int numPrebleach = 2;
    ArrayList<UShortImage> images = new ArrayList<UShortImage>();
    ArrayList<Double> times = new ArrayList<Double>();
    final BrownianDynamics2DSolver solver = new BrownianDynamics2DSolver(origin, extent, numParticles);
    boolean initiallyFluorescent = true;
    solver.initializeUniform(initiallyFluorescent);
    // simulate and write prebleach images
    for (int i = 0; i < numPrebleach; i++) {
        images.add(solver.sampleImage(numX, numY, origin, extent, diffusionRate, totalSampleTime, numSampleSteps, psfVar, detectorGainAndQuantumYeild, bConvolve, bNoise));
        times.add(solver.currentTime());
    }
    // bleach
    double totalBleachTime = 0.1;
    int numBleachSteps = 5;
    double bleachCenterX = origin.getX() + 0.5 * extent.getX();
    double bleachCenterY = origin.getY() + 0.5 * extent.getY();
    double bleachPsfVariance = bleachRadius;
    double bleachFactor_K = 10;
    solver.bleachGuassian(diffusionRate, totalBleachTime, numBleachSteps, bleachCenterX, bleachCenterY, bleachPsfVariance, bleachFactor_K);
    // wait
    double postbleachDelay = 0.1;
    solver.step(diffusionRate, postbleachDelay);
    while (solver.currentTime() < 5) {
        double samplePsfVariance = psfVar;
        images.add(solver.sampleImage(numX, numY, origin, extent, diffusionRate, totalSampleTime, numSampleSteps, psfVar, detectorGainAndQuantumYeild, bConvolve, bNoise));
        times.add(solver.currentTime());
    // solver.step(diffusionRate, 1-totalSampleTime);
    }
    double[] timeArray = new double[times.size()];
    for (int i = 0; i < timeArray.length; i++) {
        timeArray[i] = times.get(i);
    }
    UShortImage[] imageArray = images.toArray(new UShortImage[images.size()]);
    return new ImageTimeSeries<UShortImage>(UShortImage.class, imageArray, timeArray, 1);
}
Also used : ArrayList(java.util.ArrayList) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) BrownianDynamics2DSolver(org.vcell.vmicro.op.BrownianDynamics2DSolver) ImageTimeSeries(org.vcell.vmicro.workflow.data.ImageTimeSeries)

Aggregations

UShortImage (cbit.vcell.VirtualMicroscopy.UShortImage)3 BrownianDynamics2DSolver (org.vcell.vmicro.op.BrownianDynamics2DSolver)3 ArrayList (java.util.ArrayList)2 ImageTimeSeries (org.vcell.vmicro.workflow.data.ImageTimeSeries)2 Extent (org.vcell.util.Extent)1 Origin (org.vcell.util.Origin)1 DisplayImageOp (org.vcell.vmicro.op.display.DisplayImageOp)1