Пример #1
0
    def test_rotate_imgs_ok(self):
        import IMAT.tomorec.reconstruction_command as cmd
        cmd = cmd.ReconstructionCommand()

        import IMAT.tomorec.configs as cfgs
        pre_conf = cfgs.PreProcConfig()
        pre_conf.rotation = 1

        (rotated, white, dark) = cmd.rotate_stack(self.data_vol, pre_conf)
        np.testing.assert_allclose(rotated, self.data_vol,
                                   err_msg="Epected rotated data volume not to change when "
                                   "the rotation option is disabled")
        self.assertEquals(white, None, msg="When the white stack is None, it should still be "
                          "None after rotation")
        self.assertEquals(dark, None, msg="When the dark stack is None, it should still be "
                          "None after rotation")

        pre_conf.rotation = 1
        (rotated_90, white, dark) = cmd.rotate_stack(self.data_vol, pre_conf)
        coordinates =  [(3, 510, 0), (2,2,3), (1,0,0), (0, 500, 5)]
        expected_vals = [-0.810005187988, 0.656108379364, -0.531451165676, 0.430478185415]
        for coord, expected in zip(coordinates, expected_vals):
            real_val = rotated_90[coord]
            self.assertAlmostEquals(real_val, expected,
                                    msg="Rotation: wrong value found at coordinate {0},{1},{2}. "
                                    "Expected: {3}, found: {4}".format(coord[0], coord[1], coord[2],
                                                                       expected, real_val))
Пример #2
0
    def test_rotate_imgs_ok(self):
        import IMAT.tomorec.reconstruction_command as cmd
        cmd = cmd.ReconstructionCommand()

        import IMAT.tomorec.configs as cfgs
        pre_conf = cfgs.PreProcConfig()
        pre_conf.rotation = 1

        (rotated, white, dark) = cmd.rotate_stack(self.data_vol, pre_conf)
        np.testing.assert_allclose(
            rotated,
            self.data_vol,
            err_msg="Epected rotated data volume not to change when "
            "the rotation option is disabled")
        self.assertEquals(
            white,
            None,
            msg="When the white stack is None, it should still be "
            "None after rotation")
        self.assertEquals(
            dark,
            None,
            msg="When the dark stack is None, it should still be "
            "None after rotation")

        pre_conf.rotation = 1
        (rotated_90, white, dark) = cmd.rotate_stack(self.data_vol, pre_conf)
        coordinates = [(3, 510, 0), (2, 2, 3), (1, 0, 0), (0, 500, 5)]
        expected_vals = [
            -0.810005187988, 0.656108379364, -0.531451165676, 0.430478185415
        ]
        for coord, expected in zip(coordinates, expected_vals):
            real_val = rotated_90[coord]
            self.assertAlmostEquals(
                real_val,
                expected,
                msg="Rotation: wrong value found at coordinate {0},{1},{2}. "
                "Expected: {3}, found: {4}".format(coord[0], coord[1],
                                                   coord[2], expected,
                                                   real_val))
Пример #3
0
    def test_rotate_raises(self):
        import IMAT.tomorec.reconstruction_command as cmd
        cmd = cmd.ReconstructionCommand()

        import IMAT.tomorec.configs as cfgs
        pre_conf = cfgs.PreProcConfig()
        alg_conf = cfgs.ToolAlgorithmConfig()
        post_conf = cfgs.PostProcConfig()
        conf = cfgs.ReconstructionConfig(pre_conf, alg_conf, post_conf)

        pre_conf.rotation = 1
        # absolutely invalid data
        with self.assertRaises(ValueError):
            cmd.rotate_stack([], pre_conf)

        # wrong data type or dimensions (for samples / flats / darks
        with self.assertRaises(ValueError):
            cmd.rotate_stack(np.ones((3, 2)), pre_conf)

        with self.assertRaises(ValueError):
            cmd.rotate_stack(self.data_vol, pre_conf, [1])

        with self.assertRaises(ValueError):
            cmd.rotate_stack(self.data_vol, pre_conf, None, np.zeros((3, 3)))

        with self.assertRaises(ValueError):
            cmd.rotate_stack(self.data_vol, pre_conf, None, [0, 1])

        # invalid configurations
        with self.assertRaises(ValueError):
            cmd.rotate_stack(self.data_vol, None)

        with self.assertRaises(ValueError):
            cmd.rotate_stack(self.data_vol, [])

        with self.assertRaises(ValueError):
            cmd.rotate_stack(self.data_vol, conf)
Пример #4
0
    def test_rotate_raises(self):
        import IMAT.tomorec.reconstruction_command as cmd
        cmd = cmd.ReconstructionCommand()

        import IMAT.tomorec.configs as cfgs
        pre_conf = cfgs.PreProcConfig()
        alg_conf = cfgs.ToolAlgorithmConfig()
        post_conf = cfgs.PostProcConfig()
        conf = cfgs.ReconstructionConfig(pre_conf, alg_conf, post_conf)

        pre_conf.rotation = 1
        # absolutely invalid data
        with self.assertRaises(ValueError):
            cmd.rotate_stack([], pre_conf)

        # wrong data type or dimensions (for samples / flats / darks
        with self.assertRaises(ValueError):
            cmd.rotate_stack(np.ones((3, 2)), pre_conf)

        with self.assertRaises(ValueError):
            cmd.rotate_stack(self.data_vol, pre_conf, [1])

        with self.assertRaises(ValueError):
            cmd.rotate_stack(self.data_vol, pre_conf, None, np.zeros((3, 3)))

        with self.assertRaises(ValueError):
            cmd.rotate_stack(self.data_vol, pre_conf, None, [0, 1])

        # invalid configurations
        with self.assertRaises(ValueError):
            cmd.rotate_stack(self.data_vol, None)

        with self.assertRaises(ValueError):
            cmd.rotate_stack(self.data_vol, [])

        with self.assertRaises(ValueError):
            cmd.rotate_stack(self.data_vol, conf)