Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catphan Modules without background_roi_settings result in nan background_median & background_std values #354

Closed
randlet opened this issue Mar 31, 2021 · 2 comments

Comments

@randlet
Copy link
Contributor

randlet commented Mar 31, 2021

Describe the bug

For Catphan modules without background_roi_settings (CTP486) the background_median/background_std get set to nan in _setup_rois because np.mean([]) == np.std([]) == nan. This throws RuntimeWarnings and / or FloatingPointError's. This nan gets propagated through to cnr calculations for the module rois

To Reproduce

from pylinac import CatPhan604

cbct = CatPhan604.from_zip("CatPhan604.zip")
cbct.analyze()
print([roi.cnr for roi in cbct.ctp486.rois.values()])

# /lib/python3.6/site-packages/numpy/core/fromnumeric.py:3373: RuntimeWarning: Mean of empty slice.
# /lib/python3.6/site-packages/numpy/core/_methods.py:170: RuntimeWarning: invalid value encountered in double_scalars
# /lib/python3.6/site-packages/numpy/core/_methods.py:234: RuntimeWarning: Degrees of freedom <= 0 for slice
# /lib/python3.6/site-packages/numpy/core/_methods.py:195: RuntimeWarning: invalid value encountered in true_divide
# /lib/python3.6/site-packages/numpy/core/_methods.py:226: RuntimeWarning: invalid value encountered in double_scalars

# [nan, nan, nan, nan, nan]
@randlet
Copy link
Contributor Author

randlet commented Mar 31, 2021

Also, somewhat related, should

            background_median = np.mean([roi.pixel_value for roi in self.background_rois.values()])

be

            background_mean = np.mean([roi.pixel_value for roi in self.background_rois.values()])

or

            background_median = np.median([roi.pixel_value for roi in self.background_rois.values()])

?

@jrkerns
Copy link
Owner

jrkerns commented Mar 31, 2021

Quantitatively, mean or median doesn't make a big difference in this context, but for consistency, let's go with mean (middle).

@jrkerns jrkerns closed this as completed Apr 5, 2021
randlet added a commit to qatrackplus/pylinac that referenced this issue May 13, 2021
jrkerns added a commit that referenced this issue Mar 19, 2024
bump version

Approved-by: Randy Taylor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants