Search in sources :

Example 1 with TDoubleArrayList

use of gnu.trove.list.array.TDoubleArrayList in project GDSC-SMLM by aherbert.

the class DensityImage method calculateLScores.

private double[][] calculateLScores(DensityManager dm) {
    TDoubleArrayList x = new TDoubleArrayList();
    TDoubleArrayList y = new TDoubleArrayList();
    x.add(0.0);
    y.add(0.0);
    for (double r = minR; r < maxR; r += incrementR) {
        double l = dm.ripleysLFunction(r);
        x.add(r);
        double score = (r > 0) ? (l - r) / r : 0;
        y.add(score);
    }
    double[][] values = new double[2][];
    values[0] = x.toArray();
    values[1] = y.toArray();
    return values;
}
Also used : TDoubleArrayList(gnu.trove.list.array.TDoubleArrayList)

Example 2 with TDoubleArrayList

use of gnu.trove.list.array.TDoubleArrayList in project GDSC-SMLM by aherbert.

the class StandardFluorophoreSequenceModel method init.

private void init(double t, double tOn, double tOff, double tOff2, double nBlinks, double nBlinks2, boolean useGeometricBlinkingDistribution, RandomDataGenerator rand) {
    // Model two dark states: short and long. The second tOff and nBlinks is for the long dark state:
    //
    // ++-+-+++-+.................+-+--++-+................................+--+++-+
    //
    // + = on
    // - = Short dark state
    // . = Long dark state
    // Note: 1+nBlinks is the number of on-states
    TDoubleArrayList sequence = new TDoubleArrayList();
    // Perform a set number of long blinks
    int nLongBlinks = getBlinks(useGeometricBlinkingDistribution, rand, nBlinks2);
    for (int n = 0; n <= nLongBlinks; n++) {
        // For each burst between long blinks perform a number of short blinks
        int nShortBlinks = getBlinks(useGeometricBlinkingDistribution, rand, nBlinks);
        // Starts on the current time
        sequence.add(t);
        // Stops after the on-time
        t += rand.nextExponential(tOn);
        sequence.add(t);
        // Remaining bursts
        for (int i = 0; i < nShortBlinks; i++) {
            // Next burst starts after the short off-time
            t += rand.nextExponential(tOff);
            sequence.add(t);
            // Stops after the on-time
            t += rand.nextExponential(tOn);
            sequence.add(t);
        }
        // Add the long dark state if there are more bursts.
        t += rand.nextExponential(tOff2);
    }
    // Convert the sequence to the burst sequence array
    setBurstSequence(sequence.toArray());
}
Also used : TDoubleArrayList(gnu.trove.list.array.TDoubleArrayList)

Example 3 with TDoubleArrayList

use of gnu.trove.list.array.TDoubleArrayList in project GDSC-SMLM by aherbert.

the class FIRE method showFrcTimeEvolution.

private void showFrcTimeEvolution(String name, double fireNumber, ThresholdMethod thresholdMethod, double fourierImageScale, int imageSize) {
    IJ.showStatus("Calculating FRC time evolution curve...");
    List<PeakResult> list = results.getResults();
    int nSteps = 10;
    int maxT = list.get(list.size() - 1).getFrame();
    if (maxT == 0)
        maxT = list.size();
    int step = maxT / nSteps;
    TDoubleArrayList x = new TDoubleArrayList();
    TDoubleArrayList y = new TDoubleArrayList();
    double yMin = fireNumber;
    double yMax = fireNumber;
    MemoryPeakResults newResults = new MemoryPeakResults();
    newResults.copySettings(results);
    int i = 0;
    for (int t = step; t <= maxT - step; t += step) {
        while (i < list.size()) {
            if (list.get(i).getFrame() <= t) {
                newResults.add(list.get(i));
                i++;
            } else
                break;
        }
        x.add((double) t);
        FIRE f = this.copy();
        FireResult result = f.calculateFireNumber(fourierMethod, samplingMethod, thresholdMethod, fourierImageScale, imageSize);
        double fire = (result == null) ? 0 : result.fireNumber;
        y.add(fire);
        yMin = FastMath.min(yMin, fire);
        yMax = FastMath.max(yMax, fire);
    }
    // Add the final fire number
    x.add((double) maxT);
    y.add(fireNumber);
    double[] xValues = x.toArray();
    double[] yValues = y.toArray();
    String units = "px";
    if (results.getCalibration() != null) {
        nmPerPixel = results.getNmPerPixel();
        units = "nm";
    }
    String title = name + " FRC Time Evolution";
    Plot2 plot = new Plot2(title, "Frames", "Resolution (" + units + ")", (float[]) null, (float[]) null);
    double range = Math.max(1, yMax - yMin) * 0.05;
    plot.setLimits(xValues[0], xValues[xValues.length - 1], yMin - range, yMax + range);
    plot.setColor(Color.red);
    plot.addPoints(xValues, yValues, Plot.CONNECTED_CIRCLES);
    Utils.display(title, plot);
}
Also used : TDoubleArrayList(gnu.trove.list.array.TDoubleArrayList) MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults) Plot2(ij.gui.Plot2) PeakResult(gdsc.smlm.results.PeakResult) WeightedObservedPoint(org.apache.commons.math3.fitting.WeightedObservedPoint)

Example 4 with TDoubleArrayList

use of gnu.trove.list.array.TDoubleArrayList in project GDSC-SMLM by aherbert.

the class OptimiserFunction method addPoint.

public void addPoint(double x, double y) {
    if (this.x == null) {
        this.x = new TDoubleArrayList();
        this.y = new TDoubleArrayList();
    }
    this.x.add(x);
    this.y.add(y);
}
Also used : TDoubleArrayList(gnu.trove.list.array.TDoubleArrayList)

Example 5 with TDoubleArrayList

use of gnu.trove.list.array.TDoubleArrayList in project GDSC-SMLM by aherbert.

the class OptimiserFunction method addData.

public void addData(double[] x, double[] y) {
    this.x = new TDoubleArrayList();
    this.y = new TDoubleArrayList();
    for (int i = 0; i < x.length; i++) {
        this.x.add(x[i]);
        this.y.add(y[i]);
    }
}
Also used : TDoubleArrayList(gnu.trove.list.array.TDoubleArrayList)

Aggregations

TDoubleArrayList (gnu.trove.list.array.TDoubleArrayList)6 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)1 PeakResult (gdsc.smlm.results.PeakResult)1 Plot2 (ij.gui.Plot2)1 WeightedObservedPoint (org.apache.commons.math3.fitting.WeightedObservedPoint)1