Skip to content

Commit

Permalink
Merged in bugfix/RAM-4056_direct_density_600 (pull request #454)
Browse files Browse the repository at this point in the history
RAM-4056 fix more direct density scans for the catphan 600

Approved-by: Randy Taylor
  • Loading branch information
jrkerns committed Oct 7, 2024
2 parents 22ac7df + 019a62d commit 00212b0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pylinac/ct.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,18 @@ def _setup_geometry_rois(self) -> None:
xbounds = (int(self.phan_center.x - boxsize), int(self.phan_center.x + boxsize))
ybounds = (int(self.phan_center.y - boxsize), int(self.phan_center.y + boxsize))
geo_img = self.image[ybounds[0] : ybounds[1], xbounds[0] : xbounds[1]]
# clip to the nearest of the two extremes
# this can arise from direct density scans. In that case the
# 1 teflon node will not get detected as the edge intensity is much less than the other nodes (unlike normal)
# So, we clip the sub-image to the nearest extreme to the median.
# This does very little to normal scans. RAM-4056
median = np.median(geo_img)
nearest_extreme = min(abs(median - geo_img.max()), abs(median - geo_img.min()))
geo_clipped = np.clip(
geo_img, a_min=median - nearest_extreme, a_max=median + nearest_extreme
)
larr, regionprops, num_roi = get_regions(
geo_img, fill_holes=True, clear_borders=False
geo_clipped, fill_holes=True, clear_borders=False
)
# check that there is at least 1 ROI
if num_roi < 4:
Expand Down Expand Up @@ -2876,8 +2886,15 @@ def find_phantom_roll(self, func: Callable | None = None) -> float:
It may also find the top air ROI if the water vial isn't there.
We use the below lambda to select the bottom air and teflon ROIs consistently.
These two ROIs are at 75 degrees from cardinal. We thus offset the default outcome by 75.
HOWEVER, for direct density scans, the Teflon ROI might not register because of the reduced
HU. 🤦‍♂️. We make a best guess depending on the detected roll. If it's ~75 degrees,
we have caught the bottom Air and Teflon. If it's near zero, we have
caught the top and bottom Air ROIs.
"""
angle = super().find_phantom_roll(lambda x: -x.centroid[0])
if abs(angle) < 10:
return angle
return angle + 75


Expand Down
27 changes: 27 additions & 0 deletions tests_basic/test_cbct.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,33 @@ def test_vial_roi(self):
self.assertIn("Vial", self.cbct.ctp404.rois)


class CatPhan600DirectDensity(CatPhanMixin, TestCase):
"""Direct density scan."""

catphan = CatPhan600
dir_path = ["CBCT", "CatPhan_600"]
file_name = "Catphan600 direct density.zip"
hu_origin_variance = 200
expected_roll = -0.25
origin_slice = 105
hu_values = {
"Poly": -35,
"Acrylic": 123,
"Delrin": 150,
"Air": -994,
"Teflon": 431,
"PMP": -182,
"LDPE": -92,
"Vial": 63,
}
hu_passed = False
unif_values = {"Center": 11, "Left": 11, "Right": 11, "Top": 11, "Bottom": 11}
mtf_values = {50: 0.31}
avg_line_length = 50
slice_thickness = 2.1
lowcon_visible = 6


@mark.catphan604
class CatPhan604Test(CatPhanMixin, TestCase):
catphan = CatPhan604
Expand Down

0 comments on commit 00212b0

Please sign in to comment.