From 9457a2ad654acb78711601cc6f1cc842100b6b4f Mon Sep 17 00:00:00 2001 From: James Kerns Date: Tue, 27 Feb 2024 14:47:21 -0600 Subject: [PATCH 1/2] fix window rolling over sample edge --- pylinac/metrics/image.py | 4 ++-- tests_basic/test_winstonlutz.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pylinac/metrics/image.py b/pylinac/metrics/image.py index 00775e44..c84ed6db 100644 --- a/pylinac/metrics/image.py +++ b/pylinac/metrics/image.py @@ -413,9 +413,9 @@ def calculate(self) -> RegionProperties: self.expected_position.x += self.image.shape[1] / 2 self.expected_position.y += self.image.shape[0] / 2 # sample the image in the search window; need to convert to mm - left = math.floor(self.expected_position.x - self.search_window[0] / 2) + left = max(math.floor(self.expected_position.x - self.search_window[0] / 2), 0) right = math.ceil(self.expected_position.x + self.search_window[0] / 2) - top = math.floor(self.expected_position.y - self.search_window[1] / 2) + top = max(math.floor(self.expected_position.y - self.search_window[1] / 2), 0) bottom = math.ceil(self.expected_position.y + self.search_window[1] / 2) sample = self.image[top:bottom, left:right] # we might need to invert the image so that the BB pixel intensity is higher than the background diff --git a/tests_basic/test_winstonlutz.py b/tests_basic/test_winstonlutz.py index 58573ed8..dc0cb789 100644 --- a/tests_basic/test_winstonlutz.py +++ b/tests_basic/test_winstonlutz.py @@ -1231,21 +1231,21 @@ class TIFFImages(WinstonLutzMixin, TestCase): file_name = ["AQA.zip"] num_images = 2 sid = 1000 - dpi = 200 + dpi = 300 # I don't know the actual axis values, this is just to get a result axis_mapping = { "AQA_A_03082023.tif": (0, 0, 0), "AQA_B_03082023.tif": (90, 0, 0), } - bb_size = 30 + bb_size = 20 gantry_iso_size = 0.15 collimator_iso_size = None couch_iso_size = None - cax2bb_max_distance = 1.14 - cax2bb_median_distance = 0.82 - cax2bb_mean_distance = 0.8 + cax2bb_max_distance = 0.75 + cax2bb_median_distance = 0.5 + cax2bb_mean_distance = 0.5 axis_of_rotation = {-1: Axis.GANTRY} - bb_shift_vector = Vector(x=1.1, y=0.34, z=-0.30) + bb_shift_vector = Vector(x=0.74, y=0.16, z=-0.14) class VarianBBkV(WinstonLutzMixin, TestCase): From c3d9c8714ccd4b5c4aa2120311137594931d257f Mon Sep 17 00:00:00 2001 From: James Kerns Date: Thu, 29 Feb 2024 12:13:13 -0600 Subject: [PATCH 2/2] add change note --- docs/source/changelog.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 0d98958d..2ece0772 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -36,6 +36,10 @@ CT Image Metrics ^^^^^^^^^^^^^ +* Disk-finding metrics, such as Winston-Lutz, had a bug that would cause disks to not be found + if the image size was smaller than the search window. This happened if the image size was ~<=3x the + BB size. I.e. if the image was 200x200 pixels and the BB was 70 pixels, the search window sampler would + not correctly size the window. This was only found to affect users of small pieces of film. * The ``SizedDiskRegion`` and ``SizedDiskLocator`` classes now have a ``min_number``, ``max_number``, and ``min_separation_`` parameters, as the ``GlobalSizedDiskLocator`` class does. This allows the user to specify the minimum and maximum number of disks. Previously, the ``SizedDisk`` classes would only find one disk.