Skip to content

Commit

Permalink
Merged in bugfix/RAM-3338_window_size (pull request #347)
Browse files Browse the repository at this point in the history
RAM-3338 fix window rolling over sample edge

Approved-by: Randy Taylor
  • Loading branch information
jrkerns committed Mar 1, 2024
2 parents 4547351 + c3d9c87 commit c5a8734
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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_<pixels|mm>`` parameters,
as the ``GlobalSizedDiskLocator`` class does. This allows the user to specify the minimum and maximum number of disks.
Previously, the ``SizedDisk<Region|Locator>`` classes would only find one disk.
Expand Down
4 changes: 2 additions & 2 deletions pylinac/metrics/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ def calculate(self) -> list[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
Expand Down
12 changes: 6 additions & 6 deletions tests_basic/test_winstonlutz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c5a8734

Please sign in to comment.