Skip to content

Commit

Permalink
Merged in bugfix/RAM-3927_refinement_error (pull request #457)
Browse files Browse the repository at this point in the history
fix refinement error of a few datasets.

Approved-by: Randy Taylor
  • Loading branch information
jrkerns committed Oct 11, 2024
2 parents 18b2772 + ab45f32 commit bdb7170
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pylinac/ct.py
Original file line number Diff line number Diff line change
Expand Up @@ -2822,6 +2822,9 @@ def refine_origin_slice(self, initial_slice_num: int) -> int:
"angle": angle,
"left width": troi["Left"].long_profile.field_width_px,
"right width": troi["Right"].long_profile.field_width_px,
# the values AT the FWXM
"left center": troi["Left"].long_profile.y_at_x(left_wire),
"right center": troi["Right"].long_profile.y_at_x(right_wire),
"left profile": troi["Left"].long_profile.values,
"right profile": troi["Right"].long_profile.values,
}
Expand Down Expand Up @@ -2857,11 +2860,9 @@ def refine_origin_slice(self, initial_slice_num: int) -> int:
continue
# if the max pixel value of the angle set is closer to the overall median than the max
# it means the wire isn't in the slice; drop it
max_pixel = max(
angle_set["left profile"].max(), angle_set["right profile"].max()
)
delta_median = abs(median_pixel_val - max_pixel)
delta_max = abs(max_pixel_val - max_pixel)
fwxm_pixel = np.mean((angle_set["left center"], angle_set["right center"]))
delta_median = abs(median_pixel_val - fwxm_pixel)
delta_max = abs(max_pixel_val - fwxm_pixel)
if delta_median < delta_max:
angles.remove(angle_set)

Expand Down
80 changes: 80 additions & 0 deletions tests_basic/test_cbct.py
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,86 @@ class CatPhan604CoCr(CatPhan604Mixin, TestCase):
lowcon_visible = 2


@mark.directdensity
@mark.catphan604
class CatPhan604SliceRefinementLocalization(CatPhan604Mixin, TestCase):
"""A crazy scenario where the refinement algorithm failed due to the wire being at the edge of the
"long_profile". Also, this is a direct density scan.
"""

file_name = "CatPhan604 - ramp edge.zip"
hu_origin_variance = 200
origin_slice = 71
hu_values = {
"Poly": -67,
"Acrylic": 94,
"Delrin": 114,
"Air": -997,
"Teflon": 364,
"PMP": -212,
"LDPE": -129,
"50% Bone": 335,
"20% Bone": 104,
}
thickness_slice_straddle = 0
slice_thickness = 2.35
unif_values = {"Center": -18, "Left": -17, "Right": -17, "Top": -17, "Bottom": -18}
mtf_values = {50: 0.30}
lowcon_visible = 6


@mark.directdensity
@mark.catphan604
class CatPhan604DD2(CatPhan604Mixin, TestCase):
"""Direct density scan"""

file_name = "CatPhan604 - DD2.zip"
hu_origin_variance = 200
origin_slice = 74
hu_values = {
"Poly": -36,
"Acrylic": 118,
"Delrin": 191,
"Air": -1017,
"Teflon": 540,
"PMP": -187,
"LDPE": -97,
"50% Bone": 380,
"20% Bone": 124,
}
thickness_slice_straddle = 0
slice_thickness = 2.35
unif_values = {"Center": 9, "Left": 9, "Right": 9, "Top": 9, "Bottom": 9}
mtf_values = {50: 0.30}
lowcon_visible = 6


@mark.directdensity
@mark.catphan604
class CatPhan604DD3(CatPhan604Mixin, TestCase):
"""Direct density scan"""

file_name = "CatPhan604 - DD3.zip"
hu_origin_variance = 200
origin_slice = 71
hu_values = {
"Poly": -65,
"Acrylic": 95,
"Delrin": 115,
"Air": -999,
"Teflon": 363,
"PMP": -212,
"LDPE": -125,
"50% Bone": 335,
"20% Bone": 105,
}
thickness_slice_straddle = 0
slice_thickness = 2.35
unif_values = {"Center": -20, "Left": -20, "Right": -20, "Top": -20, "Bottom": -20}
mtf_values = {50: 0.30}
lowcon_visible = 6


class CatPhan504NearEdge(CatPhan504Mixin, TestCase):
file_name = "phantom_edge.zip"
expected_roll = 1.4
Expand Down

0 comments on commit bdb7170

Please sign in to comment.