Exemple #1
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)
Exemple #2
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)
Exemple #3
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()
Exemple #4
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()
Exemple #5
0
    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_()
Exemple #6
0
    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')
Exemple #7
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)
Exemple #8
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)
Exemple #9
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)