Search in sources :

Example 11 with Random

use of gdsc.core.utils.Random in project GDSC-SMLM by aherbert.

the class ImageSourceTest method interlacedImageSourceCanReturnCroppedDataWithGet.

@Test
public void interlacedImageSourceCanReturnCroppedDataWithGet() {
    int w = 5;
    int h = 3;
    float[][] data = createData(w, h, 15);
    int start = 4;
    int size = 2;
    int skip = 1;
    Rectangle bounds = new Rectangle(2, 1, 3, 1);
    ImageSource source = new InterlacedImageSource(new MemoryImageSource(w, h, data), start, size, skip);
    int[] frames = new int[data.length];
    for (int i = 0; i < data.length; i++) frames[i] = i + 1;
    Random rand = new Random();
    rand.shuffle(frames);
    int[] expected = new int[] { 4, 5, 7, 8, 10, 11, 13, 14 };
    Assert.assertTrue(source.open());
    for (int i = 0; i < data.length; i++) {
        int frame = frames[i];
        Assert.assertTrue(source.isValid(frame));
        float[] d = source.get(frame, bounds);
        if (isExpected(frame, expected)) {
            Assert.assertEquals(bounds.width * bounds.height, d.length);
            Assert.assertArrayEquals(crop(data[frame - 1], w, bounds), d, 0);
        } else
            Assert.assertNull(d);
    }
    Assert.assertFalse(source.isValid(0));
    Assert.assertFalse(source.isValid(data.length + 1));
}
Also used : Random(gdsc.core.utils.Random) Rectangle(java.awt.Rectangle) Test(org.junit.Test)

Example 12 with Random

use of gdsc.core.utils.Random in project GDSC-SMLM by aherbert.

the class TraceManagerTest method canTraceMultiplePulseWithFixedCoords.

@Test
public void canTraceMultiplePulseWithFixedCoords() {
    Random rand = new Random(30051977);
    int maxOffTime = 5;
    float[] params = createParams(rand);
    Trace trace = new Trace();
    for (int i = 0; i < 5; i++) {
        trace.add(new PeakResult(i, 0, 0, 0, 0, 0, params, null));
    }
    for (int i = 0; i < 5; i++) {
        trace.add(new PeakResult(i + maxOffTime, 0, 0, 0, 0, 0, params, null));
    }
    runTracing(0, maxOffTime + 1, trace);
}
Also used : Random(gdsc.core.utils.Random) Test(org.junit.Test)

Example 13 with Random

use of gdsc.core.utils.Random in project GDSC-SMLM by aherbert.

the class TraceManagerTest method canTraceSinglePulseWithFixedCoords.

@Test
public void canTraceSinglePulseWithFixedCoords() {
    Random rand = new Random(30051977);
    float[] params = createParams(rand);
    Trace trace = new Trace();
    for (int i = 0; i < 5; i++) {
        trace.add(new PeakResult(i, 0, 0, 0, 0, 0, params, null));
    }
    runTracing(0, 1, trace);
}
Also used : Random(gdsc.core.utils.Random) Test(org.junit.Test)

Aggregations

Random (gdsc.core.utils.Random)13 Test (org.junit.Test)11 Rectangle (java.awt.Rectangle)4 StoredDataStatistics (gdsc.core.utils.StoredDataStatistics)2 FitEngine (gdsc.smlm.engine.FitEngine)1 FitJob (gdsc.smlm.engine.FitJob)1 FitConfiguration (gdsc.smlm.fitting.FitConfiguration)1 IJImageSource (gdsc.smlm.ij.IJImageSource)1 ActivationEnergyImageModel (gdsc.smlm.model.ActivationEnergyImageModel)1 CompoundMoleculeModel (gdsc.smlm.model.CompoundMoleculeModel)1 FixedLifetimeImageModel (gdsc.smlm.model.FixedLifetimeImageModel)1 FluorophoreSequenceModel (gdsc.smlm.model.FluorophoreSequenceModel)1 ImageModel (gdsc.smlm.model.ImageModel)1 LocalisationModel (gdsc.smlm.model.LocalisationModel)1 LocalisationModelSet (gdsc.smlm.model.LocalisationModelSet)1 SpatialDistribution (gdsc.smlm.model.SpatialDistribution)1 SpatialIllumination (gdsc.smlm.model.SpatialIllumination)1 AggregatedImageSource (gdsc.smlm.results.AggregatedImageSource)1 ImageSource (gdsc.smlm.results.ImageSource)1 InterlacedImageSource (gdsc.smlm.results.InterlacedImageSource)1