示例#1
0
    def test_from_url(self):
        """Test getting a PF image from a URL."""
        url = 'https://s3.amazonaws.com/assuranceqa-staging/uploads/imgs/AS500-UD.dcm'
        pf = PicketFence.from_url(url)
        pf.analyze()

        bad_url = 'https://s3.amazonaws.com/assuranceqa-staging/uploads/imgs/AS500-UD_not_real.dcm'
        with self.assertRaises(ConnectionError):
            pf = PicketFence.from_url(bad_url)
示例#2
0
    def test_from_url(self):
        """Test getting a PF image from a URL."""
        url = 'https://s3.amazonaws.com/assuranceqa-staging/uploads/imgs/AS500-UD.dcm'
        pf = PicketFence.from_url(url)
        pf.analyze()

        bad_url = 'https://s3.amazonaws.com/assuranceqa-staging/uploads/imgs/AS500-UD_not_real.dcm'
        with self.assertRaises(ConnectionError):
            PicketFence.from_url(bad_url)  # shouldn't raise
示例#3
0
    def test_orientation_passing_as(self):
        # below shouldn't raise
        # as enum
        pf = PicketFence.from_demo_image()
        pf.analyze(orientation=Orientation.LEFT_RIGHT)

        # as str
        pf = PicketFence.from_demo_image()
        pf.analyze(orientation="Left-Right")
示例#4
0
 def setUpClass(cls):
     path1 = osp.join(TEST_DIR, 'combo-jaw.dcm')
     path2 = osp.join(TEST_DIR, 'combo-mlc.dcm')
     cls.pf = PicketFence.from_multiple_images([path1, path2],
                                               stretch_each=True)
     cls.pf.analyze(sag_adjustment=cls.sag_adjustment,
                    orientation=Orientation.LEFT_RIGHT)
示例#5
0
 def test_load_from_file_object(self):
     pf_file = osp.join(TEST_DIR, 'PF.dcm')
     ref_pf = PicketFence(pf_file)
     ref_pf.analyze()
     with open(pf_file, 'rb') as f:
         pf = PicketFence(f)
         pf.analyze()
     self.assertIsInstance(pf, PicketFence)
     self.assertEqual(pf.percent_passing, ref_pf.percent_passing)
示例#6
0
 def setUpClass(cls):
     path1 = osp.join(TEST_DIR, 'combo-jaw.dcm')
     path2 = osp.join(TEST_DIR, 'combo-mlc.dcm')
     cls.pf = PicketFence.from_multiple_images([path1, path2])
     cls.pf.analyze(hdmlc=cls.hdmlc,
                    sag_adjustment=cls.sag_adjustment,
                    orientation='left',
                    invert=True)
示例#7
0
 def test_load_from_stream(self):
     pf_file = osp.join(TEST_DIR, 'PF.dcm')
     ref_pf = PicketFence(pf_file)
     ref_pf.analyze()
     with open(pf_file, 'rb') as f:
         s = io.BytesIO(f.read())
         pf = PicketFence(s)
         pf.analyze()
     self.assertIsInstance(pf, PicketFence)
     self.assertEqual(pf.percent_passing, ref_pf.percent_passing)
示例#8
0
 def setUpClass(cls):
     cls.pf = PicketFence(cls.get_filename(), log=cls.get_logfile())
     if cls.pass_num_pickets:
         cls.pf.analyze(sag_adjustment=cls.sag_adjustment,
                        num_pickets=cls.num_pickets,
                        invert=cls.invert)
     else:
         cls.pf.analyze(sag_adjustment=cls.sag_adjustment,
                        invert=cls.invert)
示例#9
0
    def test_mlc_string(self):
        mlc_setup = 'Millennium'

        # pass it in to the mlc parameter
        path = osp.join(TEST_DIR, 'AS500_PF.dcm')
        pf = PicketFence(path, mlc=mlc_setup)

        # shouldn't raise
        pf.analyze()
        pf.results()
        pf.results_data()
示例#10
0
    def test_custom_MLC_arrangement(self):
        mlc_setup = MLCArrangement(leaf_arrangement=[(10, 10), (40, 5), (10,
                                                                         10)])

        # pass it in to the mlc parameter
        path = osp.join(TEST_DIR, 'AS500_PF.dcm')
        pf = PicketFence(path, mlc=mlc_setup)

        # shouldn't raise
        pf.analyze()
        pf.results()
        pf.results_data()
示例#11
0
文件: Start.py 项目: Jothy/RTQA
    def AnalysePicketFence0(self):
        if self.Mode=="Manual":
            files=QFileDialog(self)
            files.setWindowTitle('Picket Fence 0')
            self.CurrentImages=files.getOpenFileNames(self,caption='Continuous Stripes (1)')

        ContStripesDlg1=ContStripesDlg.ContStripesWidget(self)
        #ContStripesDlg1.Img=DCMReader.ReadDCMFile(str(self.CurrentImages[0]))

        mypf = PicketFence(str(self.CurrentImages[0]))

        mypf.image.check_inversion()
        mypf.analyze(tolerance=0.5, action_tolerance=0.3,hdmlc=False)
        mypf.save_analyzed_image('PicketFence0',gaurd_rails=True,mlc_peaks=True,overlay=True,leaf_error_subplot=True)
        #print(mypf.num_pickets,'No. of pickets found')
        #print(mypf.return_results())
        #mypf.plot_analyzed_image()


        AnalyzedImage=pl.imread('PicketFence0.png')
        ContStripesDlg1.Stripes.axes.imshow(AnalyzedImage)
        ContStripesDlg1.ResultsLabel.setText(mypf.return_results())
        #mypf.plot_analyzed_image(ContStripesDlg1.Stripes)
        numPickets=str(mypf.num_pickets)
        ContStripesDlg1.Stripes.axes.set_title("No. of pickets found: "+numPickets+"Gantry=0")
        ContStripesDlg1.Stripes.axes.text(5,25,"Tol=0.5mm,Act_Tol=0.3mm",color='g')
        ContStripesDlg1.Stripes.axes.text(5,60,"Warning:Picket & leaf indexing starts with 0",color='r')
        self.SaveWidgetScreenShot(ContStripesDlg1,'PicketFence0.jpg')

        ContStripesDlg1.Stripes.axes.arrow(25,550, 50,0, head_width=10, head_length=25, fc='b', ec='b')
        ContStripesDlg1.Stripes.axes.arrow(25,550,0,-50, head_width=10, head_length=25, fc='b', ec='b')
        ContStripesDlg1.Stripes.axes.text(35,570,"Count",color='gray')
        ContStripesDlg1.Stripes.axes.text(5,515,"Count",color='gray',rotation=90)

        ContStripesDlg1.Stripes.axes.set_xlabel("Pixel No. G-T")
        ContStripesDlg1.Stripes.axes.set_ylabel("Pixel No. A-B")

        if self.Mode=="Manual":
            ContStripesDlg1.Stripes.draw()
            ContStripesDlg1.exec_()
示例#12
0
文件: Start.py 项目: Jothy/RTQA
    def AnalyseContStripes(self):
        files=QFileDialog(self)
        files.setWindowTitle('Picket Fence')
        self.CurrentImages=files.getOpenFileNames(self,caption='Picket Fence')

        ContStripesDlg1=ContStripesDlg.ContStripesWidget(self)
        ContStripesDlg1.Img=DCMReader.ReadDCMFile(str(self.CurrentImages[0]))

        mypf = PicketFence(str(self.CurrentImages[0]))
        mypf.image.check_inversion()
        mypf.analyze(tolerance=0.50, action_tolerance=0.3,hdmlc=False)
        mypf.save_analyzed_image('PicketFence',gaurd_rails=True,mlc_peaks=True,overlay=True)
        #print(mypf.num_pickets,'No. of pickets found')
        print("SID:",mypf.image.SID)


        AnalyzedImage=pl.imread('PicketFence.png')
        ContStripesDlg1.Stripes.axes.imshow(AnalyzedImage)
        ContStripesDlg1.ResultsLabel.setText(mypf.return_results())
        #mypf.plot_analyzed_image(ContStripesDlg1.Stripes)
        ContStripesDlg1.Stripes.draw()
        ContStripesDlg1.exec_()

        self.SaveWidgetScreenShot(ContStripesDlg1,'PicketFence.jpg')
示例#13
0
 def test_bad_tolerance_values(self):
     pf = PicketFence.from_demo_image()
     self.assertRaises(ValueError, pf.analyze, 0.2, 0.3)
示例#14
0
 def setUpClass(cls):
     cls.pf = PicketFence.from_demo_image()
     cls.pf.analyze()
     cls.pf_updown = PicketFence.from_demo_image()
     cls.pf_updown.image.rot90()
     cls.pf_updown.analyze()
示例#15
0
 def setUpClass(cls):
     cls.pf = PicketFence(cls.get_filename(), log=cls.get_logfile())
     if cls.pass_num_pickets:
         cls.pf.analyze(hdmlc=cls.hdmlc, sag_adjustment=cls.sag_adjustment, num_pickets=cls.num_pickets)
     else:
         cls.pf.analyze(hdmlc=cls.hdmlc, sag_adjustment=cls.sag_adjustment)
示例#16
0
 def setUpClass(cls):
     cls.pf = PicketFence(cls.im_path)
     cls.pf.analyze(hdmlc=cls.hdmlc, sag_adjustment=cls.sag_adjustment)
示例#17
0
 def setUpClass(cls):
     cls.pf = PicketFence.from_demo_image()
     cls.pf.analyze()
示例#18
0
 def test_load_with_log(self):
     log_file = osp.join(TEST_DIR, 'PF_log.bin')
     pf_file = osp.join(TEST_DIR, 'PF.dcm')
     pf = PicketFence(pf_file, log=log_file)
     pf.analyze(hdmlc=True)
示例#19
0
 def setUpClass(cls):
     cls.pf = PicketFence.from_demo_image()
     cls.pf.analyze()
示例#20
0
 def setUpClass(cls):
     path1 = osp.join(test_file_dir, 'combo-jaw.dcm')
     path2 = osp.join(test_file_dir, 'combo-mlc.dcm')
     cls.pf = PicketFence.from_multiple_images([path1, path2])
     cls.pf.analyze(hdmlc=cls.hdmlc, sag_adjustment=cls.sag_adjustment)
示例#21
0
 def setUpClass(cls):
     cls.pf = PicketFence.from_demo_image()
     cls.pf.analyze(hdmlc=cls.hdmlc, sag_adjustment=cls.sag_adjustment)
示例#22
0
 def setUpClass(cls):
     path1 = osp.join(test_file_dir, 'combo-jaw.dcm')
     path2 = osp.join(test_file_dir, 'combo-mlc.dcm')
     cls.pf = PicketFence.from_multiple_images([path1, path2])
     cls.pf.analyze(hdmlc=cls.hdmlc, sag_adjustment=cls.sag_adjustment)
示例#23
0
 def test_no_measurements_suggests_inversion(self):
     file_loc = osp.join(TEST_DIR, 'noisy-FFF-wide-gap-pf.dcm')
     pf = PicketFence(file_loc)
     with self.assertRaises(ValueError):
         pf.analyze(invert=False)
示例#24
0
 def setUpClass(cls):
     cls.pf = PicketFence(cls.get_filename(), log=cls.get_logfile())
     cls.pf.image.rot90()
     cls.pf.analyze(sag_adjustment=cls.sag_adjustment)
示例#25
0
 def test_demo_lower_tolerance(self):
     pf = PicketFence.from_demo_image()
     pf.analyze(0.15, action_tolerance=0.05)
     pf.plot_analyzed_image()
     self.assertAlmostEqual(pf.percent_passing, 95, delta=1)
示例#26
0
 def setUpClass(cls):
     cls.pf = PicketFence.from_demo_image()
     cls.pf.analyze(hdmlc=cls.hdmlc, sag_adjustment=cls.sag_adjustment)
示例#27
0
 def test_demo_lower_tolerance(self):
     pf = PicketFence.from_demo_image()
     pf.analyze(0.15, action_tolerance=0.05)
     pf.plot_analyzed_image()
     self.assertAlmostEqual(pf.percent_passing, 94, delta=1)
示例#28
0
 def setUpClass(cls):
     path1 = osp.join(TEST_DIR, 'combo-jaw.dcm')
     path2 = osp.join(TEST_DIR, 'combo-mlc.dcm')
     cls.pf = PicketFence.from_multiple_images([path1, path2])
     cls.pf.analyze(hdmlc=cls.hdmlc, sag_adjustment=cls.sag_adjustment, orientation='left', invert=True)
示例#29
0
 def test_filter_on_load(self):
     PicketFence(self.constructor_input, filter=3)  # shouldn't raise
示例#30
0
 def test_load_with_log(self):
     log_file = osp.join(TEST_DIR, 'PF_log.bin')
     pf_file = osp.join(TEST_DIR, 'PF.dcm')
     pf = PicketFence(pf_file, log=log_file)
     pf.analyze(hdmlc=True)
示例#31
0
 def test_demo(self):
     PicketFence.run_demo()
示例#32
0
 def test_demo(self):
     PicketFence.run_demo()
示例#33
0
 def setUpClass(cls):
     cls.pf = PicketFence(cls.get_filename(), log=cls.get_logfile())
     cls.pf.analyze(hdmlc=cls.hdmlc, sag_adjustment=cls.sag_adjustment)
示例#34
0
 def test_filter_on_load(self):
     PicketFence(osp.join(osp.dirname(osp.dirname(__file__)), 'pylinac',
                          'demo_files', 'picket_fence', 'EPID-PF-LR.dcm'),
                 filter=3)