Search in sources :

Example 1 with Trajectory

use of uk.ac.sussex.gdsc.smlm.results.DynamicMultipleTargetTracing.Trajectory in project GDSC-SMLM by aherbert.

the class DynamicMultipleTargetTracingTest method testTrajectoryWithNoOnFrames.

@Test
void testTrajectoryWithNoOnFrames() {
    final PeakResult p1 = new PeakResult(0, 1, 2);
    final PeakResult p2 = new PeakResult(1, 2, 3);
    final PeakResult p3 = new PeakResult(2, 3, 4);
    final PeakResult p4 = new PeakResult(3, 4, 5);
    final Trajectory t = new Trajectory(42, p1);
    Assertions.assertEquals(42, t.getId());
    Assertions.assertSame(p1, t.getLast(-1));
    Assertions.assertEquals(1, t.size());
    Assertions.assertThrows(NullPointerException.class, () -> t.onSize());
    t.add(p2);
    t.add(p3);
    t.add(p4);
    Assertions.assertSame(p4, t.getLast(-1));
    Assertions.assertSame(p3, t.getLast(-2));
    Assertions.assertSame(p2, t.getLast(-3));
    Assertions.assertSame(p1, t.getLast(-4));
    Assertions.assertEquals(4, t.size());
    final LocalList<PeakResult> list = new LocalList<>();
    t.forLast(2, list::add);
    Assertions.assertEquals(2, list.size());
    Assertions.assertSame(p3, list.pop());
    Assertions.assertSame(p4, list.pop());
    final Trace trace = t.toTrace();
    Assertions.assertEquals(4, trace.size());
    Assertions.assertEquals(42, trace.getId());
    // Test setting the gap
    final int frame = t.getLast(-1).getFrame();
    for (int i = 1; i <= 3; i++) {
        t.reset(frame + i);
        Assertions.assertEquals(i - 1, t.gap);
    }
    // Test setting the local statistics
    Assertions.assertFalse(t.isLocalIntensity);
    t.setLocalDiffusion(10, 9);
    Assertions.assertEquals(10, t.r2);
    Assertions.assertFalse(t.isLocalDiffusion);
    t.setLocalDiffusion(9, 10);
    Assertions.assertEquals(9, t.r2);
    Assertions.assertTrue(t.isLocalDiffusion);
}
Also used : LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) Trajectory(uk.ac.sussex.gdsc.smlm.results.DynamicMultipleTargetTracing.Trajectory) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest) Test(org.junit.jupiter.api.Test)

Example 2 with Trajectory

use of uk.ac.sussex.gdsc.smlm.results.DynamicMultipleTargetTracing.Trajectory in project GDSC-SMLM by aherbert.

the class DynamicMultipleTargetTracingTest method testTrajectory.

@Test
void testTrajectory() {
    final PeakResult p1 = new PeakResult(0, 1, 2);
    final PeakResult p2 = new PeakResult(1, 2, 3);
    final PeakResult p3 = new PeakResult(2, 3, 4);
    final PeakResult p4 = new PeakResult(3, 4, 5);
    final Trajectory t = new Trajectory(42, p1, true);
    Assertions.assertEquals(42, t.getId());
    Assertions.assertSame(p1, t.getLast(-1));
    Assertions.assertEquals(1, t.size());
    Assertions.assertEquals(1, t.onSize());
    t.add(p2, false);
    t.add(p3, false);
    t.add(p4, true);
    Assertions.assertSame(p4, t.getLast(-1));
    Assertions.assertSame(p3, t.getLast(-2));
    Assertions.assertSame(p2, t.getLast(-3));
    Assertions.assertSame(p1, t.getLast(-4));
    Assertions.assertEquals(4, t.size());
    Assertions.assertEquals(2, t.onSize());
    final LocalList<PeakResult> list = new LocalList<>();
    t.forLast(2, list::add);
    Assertions.assertEquals(2, list.size());
    Assertions.assertSame(p3, list.pop());
    Assertions.assertSame(p4, list.pop());
    t.forLastOn(2, list::add);
    Assertions.assertEquals(2, list.size());
    Assertions.assertSame(p1, list.pop());
    Assertions.assertSame(p4, list.pop());
    final Trace trace = t.toTrace();
    Assertions.assertEquals(4, trace.size());
    Assertions.assertEquals(42, trace.getId());
    // Test setting the gap
    final int frame = t.getLast(-1).getFrame();
    for (int i = 1; i <= 3; i++) {
        t.reset(frame + i);
        Assertions.assertEquals(i - 1, t.gap);
    }
    // Test setting the local statistics
    t.setLocalIntensity(10, 0);
    Assertions.assertEquals(10, t.meanI);
    Assertions.assertEquals(0, t.sdI);
    Assertions.assertFalse(t.isLocalIntensity);
    t.setLocalIntensity(9, 1);
    Assertions.assertEquals(9, t.meanI);
    Assertions.assertEquals(1, t.sdI);
    Assertions.assertTrue(t.isLocalIntensity);
    t.setLocalDiffusion(10, 9);
    Assertions.assertEquals(10, t.r2);
    Assertions.assertFalse(t.isLocalDiffusion);
    t.setLocalDiffusion(9, 10);
    Assertions.assertEquals(9, t.r2);
    Assertions.assertTrue(t.isLocalDiffusion);
}
Also used : LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) Trajectory(uk.ac.sussex.gdsc.smlm.results.DynamicMultipleTargetTracing.Trajectory) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 LocalList (uk.ac.sussex.gdsc.core.utils.LocalList)2 Trajectory (uk.ac.sussex.gdsc.smlm.results.DynamicMultipleTargetTracing.Trajectory)2 SeededTest (uk.ac.sussex.gdsc.test.junit5.SeededTest)2