Exemple #1
0
class ODLProjectorOldTestCase(unittest.TestCase):
    """Test case for ASTRA projector in ODL."""

    def setUp(self):
        # Timing
        self.start_time = time.time()

        # Geometry
        self.geom = Geometry()

    def tearDown(self):
        # Timing
        t = time.time() - self.start_time
        print "%s: %.3f" % (self.id(), t)
        self.projector.clear_astra_memory()

    def test_odlprojector_instance(self):

        # Create cubic unit volume
        vol_rn = Rn(self.geom.vol_size)
        vol = np.ones(self.geom.vol_shape)
        vol_rn_vec = vol_rn.element(vol.ravel())

        # Create projections
        proj_rn = Rn(self.geom.proj_size)
        proj = np.ones(self.geom.proj_size)
        proj_rn_vec = proj_rn.element(proj.ravel())

        vol_norm_0 = vol_rn_vec.norm()
        self.assertEqual(vol_norm_0**2, np.sqrt(self.geom.vol_size)**2)
        proj_norm_0 = proj_rn_vec.norm()
        self.assertEqual(proj_norm_0**2, np.sqrt(self.geom.proj_size)**2)

        # ODLProjector instance
        self.projector = ProjectorOld(self.geom, vol_rn_vec, proj_rn_vec)
        self.projector.forward()
        proj_norm_1 = proj_rn_vec.norm()
        self.assertNotEqual(proj_norm_0, proj_norm_1)

        self.projector.backward()
        vol_norm_1 = vol_rn_vec.norm()
        self.assertNotEqual(vol_norm_0, vol_norm_1)

        self.projector.forward(vol_rn_vec)
        proj_norm_2 = proj_rn_vec.norm()
        self.assertNotEqual(proj_norm_1, proj_norm_2)
        self.projector.backward(proj_rn_vec)
        vol_norm_2 = vol_rn_vec.norm()
        self.assertNotEqual(vol_norm_2, vol_norm_1)

        print 'vol norms:', vol_norm_0, vol_norm_1, vol_norm_2
        print 'proj norms', proj_norm_0, proj_norm_1, proj_norm_2
Exemple #2
0
class ODLProjectorOldTestCase(unittest.TestCase):
    """Test case for ASTRA projector in ODL."""
    def setUp(self):
        # Timing
        self.start_time = time.time()

        # Geometry
        self.geom = Geometry()

    def tearDown(self):
        # Timing
        t = time.time() - self.start_time
        print "%s: %.3f" % (self.id(), t)
        self.projector.clear_astra_memory()

    def test_odlprojector_instance(self):

        # Create cubic unit volume
        vol_rn = Rn(self.geom.vol_size)
        vol = np.ones(self.geom.vol_shape)
        vol_rn_vec = vol_rn.element(vol.ravel())

        # Create projections
        proj_rn = Rn(self.geom.proj_size)
        proj = np.ones(self.geom.proj_size)
        proj_rn_vec = proj_rn.element(proj.ravel())

        vol_norm_0 = vol_rn_vec.norm()
        self.assertEqual(vol_norm_0**2, np.sqrt(self.geom.vol_size)**2)
        proj_norm_0 = proj_rn_vec.norm()
        self.assertEqual(proj_norm_0**2, np.sqrt(self.geom.proj_size)**2)

        # ODLProjector instance
        self.projector = ProjectorOld(self.geom, vol_rn_vec, proj_rn_vec)
        self.projector.forward()
        proj_norm_1 = proj_rn_vec.norm()
        self.assertNotEqual(proj_norm_0, proj_norm_1)

        self.projector.backward()
        vol_norm_1 = vol_rn_vec.norm()
        self.assertNotEqual(vol_norm_0, vol_norm_1)

        self.projector.forward(vol_rn_vec)
        proj_norm_2 = proj_rn_vec.norm()
        self.assertNotEqual(proj_norm_1, proj_norm_2)
        self.projector.backward(proj_rn_vec)
        vol_norm_2 = vol_rn_vec.norm()
        self.assertNotEqual(vol_norm_2, vol_norm_1)

        print 'vol norms:', vol_norm_0, vol_norm_1, vol_norm_2
        print 'proj norms', proj_norm_0, proj_norm_1, proj_norm_2
Exemple #3
0
    def test_odlprojector_instance(self):

        # Create cubic unit volume
        vol_rn = Rn(self.geom.vol_size)
        vol = np.ones(self.geom.vol_shape)
        vol_rn_vec = vol_rn.element(vol.ravel())

        # Create projections
        proj_rn = Rn(self.geom.proj_size)
        proj = np.ones(self.geom.proj_size)
        proj_rn_vec = proj_rn.element(proj.ravel())

        vol_norm_0 = vol_rn_vec.norm()
        self.assertEqual(vol_norm_0**2, np.sqrt(self.geom.vol_size)**2)
        proj_norm_0 = proj_rn_vec.norm()
        self.assertEqual(proj_norm_0**2, np.sqrt(self.geom.proj_size)**2)

        # ODLProjector instance
        self.projector = ProjectorOld(self.geom, vol_rn_vec, proj_rn_vec)
        self.projector.forward()
        proj_norm_1 = proj_rn_vec.norm()
        self.assertNotEqual(proj_norm_0, proj_norm_1)

        self.projector.backward()
        vol_norm_1 = vol_rn_vec.norm()
        self.assertNotEqual(vol_norm_0, vol_norm_1)

        self.projector.forward(vol_rn_vec)
        proj_norm_2 = proj_rn_vec.norm()
        self.assertNotEqual(proj_norm_1, proj_norm_2)
        self.projector.backward(proj_rn_vec)
        vol_norm_2 = vol_rn_vec.norm()
        self.assertNotEqual(vol_norm_2, vol_norm_1)

        print 'vol norms:', vol_norm_0, vol_norm_1, vol_norm_2
        print 'proj norms', proj_norm_0, proj_norm_1, proj_norm_2
Exemple #4
0
    def test_odlprojector_instance(self):

        # Create cubic unit volume
        vol_rn = Rn(self.geom.vol_size)
        vol = np.ones(self.geom.vol_shape)
        vol_rn_vec = vol_rn.element(vol.ravel())

        # Create projections
        proj_rn = Rn(self.geom.proj_size)
        proj = np.ones(self.geom.proj_size)
        proj_rn_vec = proj_rn.element(proj.ravel())

        vol_norm_0 = vol_rn_vec.norm()
        self.assertEqual(vol_norm_0**2, np.sqrt(self.geom.vol_size)**2)
        proj_norm_0 = proj_rn_vec.norm()
        self.assertEqual(proj_norm_0**2, np.sqrt(self.geom.proj_size)**2)

        # ODLProjector instance
        self.projector = ProjectorOld(self.geom, vol_rn_vec, proj_rn_vec)
        self.projector.forward()
        proj_norm_1 = proj_rn_vec.norm()
        self.assertNotEqual(proj_norm_0, proj_norm_1)

        self.projector.backward()
        vol_norm_1 = vol_rn_vec.norm()
        self.assertNotEqual(vol_norm_0, vol_norm_1)

        self.projector.forward(vol_rn_vec)
        proj_norm_2 = proj_rn_vec.norm()
        self.assertNotEqual(proj_norm_1, proj_norm_2)
        self.projector.backward(proj_rn_vec)
        vol_norm_2 = vol_rn_vec.norm()
        self.assertNotEqual(vol_norm_2, vol_norm_1)

        print 'vol norms:', vol_norm_0, vol_norm_1, vol_norm_2
        print 'proj norms', proj_norm_0, proj_norm_1, proj_norm_2