jrkerns / pylinac

An image analysis library for medical physics
https://pylinac.readthedocs.io/en/latest/
MIT License
157 stars 99 forks source link

CTP404 module doesn't always respect 'clear_borders' setting #448

Closed ckswilliams closed 1 year ago

ckswilliams commented 1 year ago

Describe the bug When running analysis on CTP404, the 'clear_borders' setting is ignored. This results in the script failing to localise the phantom, which causes subsequent errors.

To Reproduce Steps to reproduce the behavior:

  1. Have a CatPhan image set that isn't well segmented by the get_regions algorithm
  2. ctp = CatPhan404(folder)
  3. ctp.clear_borders=False
  4. ctp.analyze()
  5. See error
  Cell In[81], line 1
    ctp504_5.analyze()

  File ~\Anaconda3\envs\gp\lib\site-packages\pylinac\ct.py:1994 in analyze
    self.ctp404 = ctp404(

  File ~\Anaconda3\envs\gp\lib\site-packages\pylinac\ct.py:594 in __init__
    super().__init__(catphan, tolerance=hu_tolerance, offset=offset)

  File ~\Anaconda3\envs\gp\lib\site-packages\pylinac\ct.py:367 in __init__
    self._setup_rois()

  File ~\Anaconda3\envs\gp\lib\site-packages\pylinac\ct.py:610 in _setup_rois
    super()._setup_rois()

  File ~\Anaconda3\envs\gp\lib\site-packages\pylinac\ct.py:416 in _setup_rois
    self.background_rois[name] = HUDiskROI(

  File ~\Anaconda3\envs\gp\lib\site-packages\pylinac\ct.py:183 in __init__
    super().__init__(array, angle, roi_radius, dist_from_center, phantom_center)

  File ~\Anaconda3\envs\gp\lib\site-packages\pylinac\core\roi.py:67 in __init__
    center = self._get_shifted_center(angle, dist_from_center, phantom_center)

  File ~\Anaconda3\envs\gp\lib\site-packages\pylinac\core\roi.py:80 in _get_shifted_center
    return Point(phantom_center.x + x_shift, phantom_center.y + y_shift)

AttributeError: 'NoneType' object has no attribute 'x'

Proposed solution Add a new line at line 607, in CTP404CP504.preprocess: clear_borders = self.clear_borders,

I'll try to make a pull request for this.

jrkerns commented 1 year ago

Closing as this was fixed in referenced PR.