Esempio n. 1
0
class Test_DRGS_demo(VMATMixin, unittest.TestCase):
    """Tests of the result values of the DRGS demo images."""
    def setUp(self):
        self.vmat = VMAT()
        self.vmat.load_demo_image('drgs')
        self.vmat.settings.x_offset = 20

    def test_demo(self):
        """Run the demo; no errors should arise."""
        self.vmat.run_demo_drgs()

    def test_overall_passed(self):
        """Test that the overall pass flag is true for default settings"""
        super().test_overall_passed('drgs')

    def test_segment_positions(self):
        """Test various values of the Segments."""
        self.vmat.analyze('drgs')
        segment_dict = {0: Point(161, 192), 4: Point(314, 192)}
        super().test_segment_positions(segment_dict)

    def test_segment_values(self):
        self.vmat.analyze('drgs')
        segment_dict = {
            0: {'r_dev': 0.965, 'r_corr': 101.85},
            4: {'r_dev': -0.459, 'r_corr': 100.42},
        }
        super().test_segment_values(segment_dict)
Esempio n. 2
0
class Test_MLCS_demo(VMATMixin, unittest.TestCase):
    """Tests of the result values of the DRMLC demo images."""

    def setUp(self):
        self.vmat = VMAT()
        self.vmat.load_demo_image('mlcs')

    def test_demo(self):
        self.vmat.run_demo_mlcs()

    def test_overall_passed(self):
        """Test that the overall pass flag is true for default settings"""
        super().test_overall_passed('mlcs')

    def test_segment_positions(self):
        """Test various values of the Segments."""
        self.vmat.analyze('mlcs')
        segment_dict = {0: Point(170, 192), 2: Point(285, 192)}
        super().test_segment_positions(segment_dict)

    def test_segment_values(self):
        self.vmat.analyze('mlcs')
        segment_dict = {
            0: {'r_dev': 0.437, 'r_corr': 100.89},
            2: {'r_dev': -0.405, 'r_corr': 100.04},
        }
        super().test_segment_values(segment_dict)
Esempio n. 3
0
class TestGeneral(unittest.TestCase):
    """Generic tests for VMAT class."""
    def setUp(self):
        self.vmat = VMAT()

    def test_demo_image_loads(self):
        """Test the that demo images load properly."""
        # shouldn't raise
        self.vmat.load_demo_image('drgs')
        self.vmat.load_demo_image('mlcs')

    def test_analyze_without_both_images_loaded(self):
        """Raise an error if both images aren't loaded when analyzing."""
        self.assertRaises(AttributeError, self.vmat.analyze, 'mlcs')
        self.vmat.load_demo_image('drgs')
        self.vmat.analyze('drgs')  # shouldn't raise

    def test_img_loaded_tags(self):
        """Test the 'is_loaded' type tags."""
        self.assertFalse(self.vmat.open_img_is_loaded)
        self.assertFalse(self.vmat.dmlc_img_is_loaded)
        self.vmat.load_demo_image()
        self.assertTrue(self.vmat.open_img_is_loaded)
        self.assertTrue(self.vmat.dmlc_img_is_loaded)

    def test_number_of_segments(self):
        """Test that the right amount of segments are constructed based on the given test."""
        self.vmat.load_demo_image()
        self.vmat.analyze('drgs')
        self.assertEqual(len(self.vmat.segments), 7)
        self.vmat.analyze('mlcs')
        self.assertEqual(len(self.vmat.segments), 4)

    def test_passing_3_images(self):
        """Test passing the wrong number of images."""
        with self.assertRaises(ValueError):
            self.vmat.load_images(('', '', ''))

    def test_from_urls(self):
        urls = ['https://s3.amazonaws.com/assuranceqa-staging/uploads/imgs/DRGS_dmlc.dcm',
                'https://s3.amazonaws.com/assuranceqa-staging/uploads/imgs/DRGS_open.dcm']
        vmat = VMAT.from_urls(urls)

    def test_img_inversion(self):
        """Check that the demo images indeed get inverted."""
        self.vmat.load_demo_image()
        top_corner_before = self.vmat.image_open.array[:20, :20].mean()
        self.vmat._check_img_inversion()
        top_corner_after = self.vmat.image_open.array[:20, :20].mean()
        self.assertNotEqual(top_corner_before, top_corner_after)
Esempio n. 4
0
class Test_general(unittest.TestCase):
    """Generic tests for VMAT class."""
    def setUp(self):
        self.vmat = VMAT()

    def test_demo_image_loads(self):
        """Test the that demo images load properly."""
        # shouldn't raise
        self.vmat.load_demo_image('drgs')
        self.vmat.load_demo_image('mlcs')

    def test_analyze_without_both_images_loaded(self):
        """Raise an error if both images aren't loaded when analyzing."""
        self.assertRaises(AttributeError, self.vmat.analyze, 'mlcs')
        self.vmat.load_demo_image('drgs')
        self.vmat.analyze('drgs')  # shouldn't raise

    def test_img_loaded_tags(self):
        """Test the 'is_loaded' type tags."""
        self.assertFalse(self.vmat.open_img_is_loaded)
        self.assertFalse(self.vmat.dmlc_img_is_loaded)
        self.vmat.load_demo_image()
        self.assertTrue(self.vmat.open_img_is_loaded)
        self.assertTrue(self.vmat.dmlc_img_is_loaded)

    def test_number_of_segments(self):
        """Test that the right amount of segments are constructed based on the given test."""
        self.vmat.load_demo_image()
        self.vmat.analyze('drgs')
        self.assertEqual(len(self.vmat.segments), 7)
        self.vmat.analyze('mlcs')
        self.assertEqual(len(self.vmat.segments), 4)
Esempio n. 5
0
class TestLoading(TestCase):
    """Tests of the various loading schemas."""
    def setUp(self):
        self.vmat = VMAT()

    def test_load_image(self):
        good_name = osp.join(vmat_test_files_dir, 'no_test_type_dmlc.dcm')
        bad_name = osp.join(vmat_test_files_dir, 'no_test_or_image_type_1.dcm')

        # image type can be determined from a good name
        self.vmat.load_image(good_name)

        # but not a bad one
        with self.assertRaises(ValueError):
            self.vmat.load_image(bad_name)

    def test_from_urls(self):
        urls = [
            'https://s3.amazonaws.com/assuranceqa-staging/uploads/imgs/DRGS_dmlc.dcm',
            'https://s3.amazonaws.com/assuranceqa-staging/uploads/imgs/DRGS_open.dcm'
        ]
        VMAT.from_urls(urls)  # shouldn't raise

    def test_passing_3_images(self):
        """Test passing the wrong number of images."""
        with self.assertRaises(ValueError):
            self.vmat.load_images(('', '', ''))

    def test_demo_image_loads(self):
        """Test the that demo images load properly."""
        # shouldn't raise
        self.vmat.load_demo_image(DRGS)
        self.vmat.load_demo_image(DRMLC)

    def test_from_zip(self):
        path = osp.join(vmat_test_files_dir, 'DRMLC.zip')
        v = VMAT.from_zip(path)
        v.analyze()

    def test_loading_with_bad_names(self):
        one = osp.join(vmat_test_files_dir, 'no_test_or_image_type_1.dcm')
        two = osp.join(vmat_test_files_dir, 'no_test_or_image_type_2.dcm')
        with self.assertRaises(ValueError):
            self.vmat.load_images((one, two))

        # but will work when everything is specified
        self.vmat.load_image(one, OPEN)
        self.vmat.load_image(two, DMLC)
        self.vmat.analyze(DRMLC)
Esempio n. 6
0
class TestLoading(TestCase):
    """Tests of the various loading schemas."""

    def setUp(self):
        self.vmat = VMAT()

    def test_load_image(self):
        good_name = osp.join(vmat_test_files_dir, 'no_test_type_dmlc.dcm')
        bad_name = osp.join(vmat_test_files_dir, 'no_test_or_image_type_1.dcm')

        # image type can be determined from a good name
        self.vmat.load_image(good_name)

        # but not a bad one
        with self.assertRaises(ValueError):
            self.vmat.load_image(bad_name)

    def test_from_urls(self):
        urls = ['https://s3.amazonaws.com/assuranceqa-staging/uploads/imgs/DRGS_dmlc.dcm',
                'https://s3.amazonaws.com/assuranceqa-staging/uploads/imgs/DRGS_open.dcm']
        VMAT.from_urls(urls)  # shouldn't raise

    def test_passing_3_images(self):
        """Test passing the wrong number of images."""
        with self.assertRaises(ValueError):
            self.vmat.load_images(('', '', ''))

    def test_demo_image_loads(self):
        """Test the that demo images load properly."""
        # shouldn't raise
        self.vmat.load_demo_image(DRGS)
        self.vmat.load_demo_image(DRMLC)

    def test_from_zip(self):
        path = osp.join(vmat_test_files_dir, 'DRMLC.zip')
        v = VMAT.from_zip(path)
        v.analyze()

    def test_loading_with_bad_names(self):
        one = osp.join(vmat_test_files_dir, 'no_test_or_image_type_1.dcm')
        two = osp.join(vmat_test_files_dir, 'no_test_or_image_type_2.dcm')
        with self.assertRaises(ValueError):
            self.vmat.load_images((one, two))

        # but will work when everything is specified
        self.vmat.load_image(one, OPEN)
        self.vmat.load_image(two, DMLC)
        self.vmat.analyze(DRMLC)
Esempio n. 7
0
class TestGeneral(TestCase):
    """Generic tests for VMAT class."""
    def setUp(self):
        self.vmat = VMAT()

    def test_analyze_without_both_images_loaded(self):
        """Raise an error if both images aren't loaded when analyzing."""
        self.assertRaises(AttributeError, self.vmat.analyze, DRMLC)
        self.vmat.load_demo_image('drgs')
        self.vmat.analyze('drgs')  # shouldn't raise

    def test_img_loaded_tags(self):
        """Test the 'is_loaded' type tags."""
        self.assertFalse(self.vmat.open_img_is_loaded)
        self.assertFalse(self.vmat.dmlc_img_is_loaded)
        self.vmat.load_demo_image()
        self.assertTrue(self.vmat.open_img_is_loaded)
        self.assertTrue(self.vmat.dmlc_img_is_loaded)

    def test_img_inversion(self):
        """Check that the demo images indeed get inverted."""
        self.vmat.load_demo_image()
        top_corner_before = self.vmat.image_open.array[:20, :20].mean()
        self.vmat._check_img_inversion()
        top_corner_after = self.vmat.image_open.array[:20, :20].mean()
        self.assertNotEqual(top_corner_before, top_corner_after)

    def test_analyze_without_test_type(self):
        dmlc = osp.join(vmat_test_files_dir, 'no_test_type_dmlc.dcm')
        opn = osp.join(vmat_test_files_dir, 'no_test_type_open.dcm')
        self.vmat.load_images((dmlc, opn))

        with self.assertRaises(ValueError):
            self.vmat.analyze()

        # but will run when test type is passed
        self.vmat.analyze('drmlc')

    def test_failure_with_tight_tolerance(self):
        self.vmat.load_demo_image()
        self.vmat.analyze(tolerance=0.1)
        self.vmat.return_results()
Esempio n. 8
0
class TestGeneral(TestCase):
    """Generic tests for VMAT class."""
    def setUp(self):
        self.vmat = VMAT()

    def test_analyze_without_both_images_loaded(self):
        """Raise an error if both images aren't loaded when analyzing."""
        self.assertRaises(AttributeError, self.vmat.analyze, DRMLC)
        self.vmat.load_demo_image('drgs')
        self.vmat.analyze('drgs')  # shouldn't raise

    def test_img_loaded_tags(self):
        """Test the 'is_loaded' type tags."""
        self.assertFalse(self.vmat.open_img_is_loaded)
        self.assertFalse(self.vmat.dmlc_img_is_loaded)
        self.vmat.load_demo_image()
        self.assertTrue(self.vmat.open_img_is_loaded)
        self.assertTrue(self.vmat.dmlc_img_is_loaded)

    def test_img_inversion(self):
        """Check that the demo images indeed get inverted."""
        self.vmat.load_demo_image()
        top_corner_before = self.vmat.image_open.array[:20, :20].mean()
        self.vmat._check_img_inversion()
        top_corner_after = self.vmat.image_open.array[:20, :20].mean()
        self.assertNotEqual(top_corner_before, top_corner_after)

    def test_analyze_without_test_type(self):
        dmlc = osp.join(vmat_test_files_dir, 'no_test_type_dmlc.dcm')
        opn = osp.join(vmat_test_files_dir, 'no_test_type_open.dcm')
        self.vmat.load_images((dmlc, opn))

        with self.assertRaises(ValueError):
            self.vmat.analyze()

        # but will run when test type is passed
        self.vmat.analyze('drmlc')

    def test_failure_with_tight_tolerance(self):
        self.vmat.load_demo_image()
        self.vmat.analyze(tolerance=0.1)
        self.vmat.return_results()