1515
1616import odl
1717from odl .util .testutils import all_almost_equal , all_equal , simple_fixture
18+ from odl .tomo .util .source_detector_shifts import flying_focal_spot
1819
1920
2021# --- pytest fixtures --- #
@@ -561,10 +562,13 @@ def test_fanbeam_flying_focal_spot():
561562 shift1 = np .array ([2 , - 3 ])
562563 shift2 = np .array ([- 2 , 3 ])
563564 init = np .array ([1 , 0 ], dtype = np .float32 )
564- geom_ffs = odl .tomo .FanBeamGeometry (apart , dpart , src_rad , det_rad ,
565- src_to_det_init = init ,
566- flying_focal_spot = [shift1 ,
567- shift2 ])
565+ geom_ffs = odl .tomo .FanBeamGeometry (
566+ apart , dpart ,
567+ src_rad , det_rad ,
568+ src_to_det_init = init ,
569+ src_shift_func = lambda angle : flying_focal_spot (
570+ angle , apart = apart ,
571+ shifts = [shift1 , shift2 ]))
568572 # angles must be shifted to match discretization of apart
569573 ang1 = - full_angle / 20
570574 apart1 = odl .uniform_partition (ang1 , full_angle + ang1 , 5 )
@@ -583,7 +587,7 @@ def test_fanbeam_flying_focal_spot():
583587
584588 sp1 = geom1 .src_position (geom1 .angles )
585589 sp2 = geom2 .src_position (geom2 .angles )
586- sp = geom_ffs .src_position (geom_ffs .angles , geom_ffs . flying_focal_spot )
590+ sp = geom_ffs .src_position (geom_ffs .angles )
587591 assert all_almost_equal (sp [0 ::2 ], sp1 )
588592 assert all_almost_equal (sp [1 ::2 ], sp2 )
589593
@@ -737,10 +741,13 @@ def test_conebeam_flying_focal_spot():
737741 shift1 = np .array ([2 , - 3 , 1 ])
738742 shift2 = np .array ([- 2 , 3 , - 1 ])
739743 init = np .array ([1 , 0 , 0 ], dtype = np .float32 )
740- geom_ffs = odl .tomo .ConeBeamGeometry (apart , dpart , src_rad , det_rad ,
741- src_to_det_init = init ,
742- flying_focal_spot = [shift1 ,
743- shift2 ])
744+ geom_ffs = odl .tomo .ConeBeamGeometry (
745+ apart , dpart ,
746+ src_rad , det_rad ,
747+ src_to_det_init = init ,
748+ src_shift_func = lambda angle : flying_focal_spot (
749+ angle , apart = apart ,
750+ shifts = [shift1 , shift2 ]))
744751 # angles must be shifted to match discretization of apart
745752 ang1 = - full_angle / 20
746753 apart1 = odl .uniform_partition (ang1 , full_angle + ang1 , 5 )
@@ -761,7 +768,7 @@ def test_conebeam_flying_focal_spot():
761768
762769 sp1 = geom1 .src_position (geom1 .angles )
763770 sp2 = geom2 .src_position (geom2 .angles )
764- sp = geom_ffs .src_position (geom_ffs .angles , geom_ffs . flying_focal_spot )
771+ sp = geom_ffs .src_position (geom_ffs .angles )
765772 assert all_almost_equal (sp [0 ::2 ], sp1 )
766773 assert all_almost_equal (sp [1 ::2 ], sp2 )
767774
0 commit comments