Skip to content

Commit

Permalink
warning/small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrkerns committed Jul 26, 2021
1 parent 1d6777f commit 8de1b54
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Planar Imaging
The default is 1000mm, but if you set it on your panel you can pass something like 1400mm.
* The phantom-finding algorithm has been refactored to be more extensible. This does not affect normal users, but reduces the amount of duplicate code.
It also makes adding new phantoms easier.
* Generally speaking, the phantoms should all be centered along the CAX. Previously, the phantom could be offset from the CAX.
* Generally speaking, the phantoms should all be roughly centered along the CAX. Previously, the phantom could be offset from the CAX.
Due to general difficulty in finding the phantom reliably for the majority of clinics, I am enforcing this as a restriction.
This shouldn't affect too many people but should make the ROI-finding algorithm better.
* The low contrast background ROI (i.e. the base level of contrast) has been adjusted for some phantoms (QC-3 and Doselab). Previously, it
Expand Down
6 changes: 3 additions & 3 deletions pylinac/core/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def equate_images(image1: ImageLike, image2: ImageLike) -> Tuple[ImageLike, Imag

# resize images to be of the same shape
zoom_factor = image1.shape[1] / image2.shape[1]
image2_array = ndimage.interpolation.zoom(image2.as_type(np.float), zoom_factor)
image2_array = ndimage.interpolation.zoom(image2.as_type(float), zoom_factor)
image2 = load(image2_array, dpi=image2.dpi * zoom_factor)

return image1, image2
Expand Down Expand Up @@ -131,7 +131,7 @@ def load(path: Union[str, ImageLike, np.ndarray, BinaryIO], **kwargs) -> ImageLi
Load an image from a file and then apply a filter::
>>> from pylinac.core.image import load
>>> my_image = "C:\QA\image.tif"
>>> my_image = r"C:\QA\image.tif"
>>> img = load(my_image) # returns a FileImage
>>> img.filter(5)
Expand Down Expand Up @@ -836,7 +836,7 @@ def _get_axis_value(self, axis_str: str, axis_dcm_attr: str) -> float:
axis_found = True
# if it is, then make sure it follows the naming convention of <axis###>
else:
match = re.search('(?<={})\d+'.format(axis_str.lower()), filename.lower())
match = re.search(r'(?<={})\d+'.format(axis_str.lower()), filename.lower())
if match is None:
raise ValueError(
f"The filename contains '{axis_str}' but could not read a number following it. Use the format '...{axis_str}<#>...'")
Expand Down
6 changes: 3 additions & 3 deletions pylinac/core/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ def __init__(self, path: str, detector_row: int = 106, bias_row: int = 107, cali
with open(path, encoding='cp437') as f:
raw_data = f.read().splitlines()
self.detectors = raw_data[detector_row].split('\t')[data_columns]
self.bias = np.array(raw_data[bias_row].split('\t')[data_columns]).astype(np.float)
self.calibration = np.array(raw_data[calibration_row].split('\t')[data_columns]).astype(np.float)
self.data = np.array(raw_data[data_row].split('\t')[data_columns]).astype(np.float)
self.bias = np.array(raw_data[bias_row].split('\t')[data_columns]).astype(float)
self.calibration = np.array(raw_data[calibration_row].split('\t')[data_columns]).astype(float)
self.data = np.array(raw_data[data_row].split('\t')[data_columns]).astype(float)
self.timetic = float(raw_data[bias_row].split('\t')[2])
self.integrated_dose = self.calibration * (self.data - self.bias * self.timetic)

Expand Down
2 changes: 1 addition & 1 deletion pylinac/core/roi.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def std(self) -> float:
masked_img = self.circle_mask()
return float(np.nanstd(masked_img))

@lru_cache(maxsize=1)
@lru_cache()
def circle_mask(self) -> np.ndarray:
"""Return a mask of the image, only showing the circular ROI."""
# http://scikit-image.org/docs/dev/auto_examples/plot_camera_numpy.html
Expand Down
2 changes: 1 addition & 1 deletion pylinac/core/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np


NumberLike = Union[int, np.float, float]
NumberLike = Union[int, float]

ArrayLike = Union[list, tuple, np.ndarray]

Expand Down
2 changes: 1 addition & 1 deletion pylinac/core/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os.path as osp
import struct
import subprocess
from collections import Iterable
from collections.abc import Iterable
from dataclasses import dataclass, field
from datetime import datetime
from enum import Enum
Expand Down
2 changes: 1 addition & 1 deletion pylinac/ct.py
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ def _publish_pdf(self, filename: str, metadata: Optional[dict], notes: str, anal

def _zip_images(self) -> None:
"""Compress the raw images into a ZIP archive and remove the uncompressed images."""
zip_name = f'{osp.dirname(self.dicom_stack[0].path)}\CBCT - {self.dicom_stack[0].date_created(format="%A, %I-%M-%S, %B %d, %Y")}.zip'
zip_name = fr'{osp.dirname(self.dicom_stack[0].path)}\CBCT - {self.dicom_stack[0].date_created(format="%A, %I-%M-%S, %B %d, %Y")}.zip'
with zipfile.ZipFile(zip_name, 'w', compression=zipfile.ZIP_DEFLATED) as zfile:
for image in self.dicom_stack:
zfile.write(image.path, arcname=osp.basename(image.path))
Expand Down
2 changes: 1 addition & 1 deletion pylinac/picketfence.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import io
import os.path as osp
import warnings
from collections import Sequence
from collections.abc import Sequence
from dataclasses import dataclass
from itertools import cycle
from tempfile import TemporaryDirectory
Expand Down
4 changes: 2 additions & 2 deletions pylinac/planar_imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ def _phantom_radius_calc(self) -> float:
"""
return self.phantom_ski_region.major_axis_length / 14

@lru_cache(maxsize=1)
@lru_cache()
def _phantom_angle_calc(self) -> float:
"""The angle of the phantom. This assumes the user is using the stand that comes with the phantom,
which angles the phantom at 45 degrees.
Expand Down Expand Up @@ -930,7 +930,7 @@ def run_demo() -> None:
leeds.analyze()
leeds.plot_analyzed_image()

@lru_cache(maxsize=1)
@lru_cache()
def _phantom_angle_calc(self) -> float:
"""Determine the angle of the phantom.
Expand Down
2 changes: 1 addition & 1 deletion pylinac/starshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def distance(p, lines):
"""Calculate the maximum distance to any line from the given point."""
return max(line.distance_to(Point(p[0], p[1])) for line in lines)

res = optimize.minimize(distance, sp.as_array(), args=(self.lines,), method='Nelder-Mead', options={'ftol': 0.001})
res = optimize.minimize(distance, sp.as_array(), args=(self.lines,), method='Nelder-Mead', options={'fatol': 0.001})
# res = optimize.least_squares(distance, sp.as_array(), args=(self.lines,), ftol=0.001)

self.wobble.radius = res.fun
Expand Down
2 changes: 1 addition & 1 deletion pylinac/winston_lutz.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def analyze(self, bb_size_mm: float = 5):
img.analyze(bb_size_mm)
self._is_analyzed = True

@lru_cache(maxsize=1)
@lru_cache()
def _minimize_axis(self, axes: Union[Axis, Tuple[Axis, ...]] = (Axis.GANTRY,)):
"""Return the minimization result of the given axis."""
if isinstance(axes, Axis):
Expand Down
2 changes: 1 addition & 1 deletion tests_basic/test_starshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def test_demo_runs(self):

def test_fails_with_tight_tol(self):
star = Starshot.from_demo_image()
star.analyze()
star.analyze(tolerance=0.1)
self.assertFalse(star.passed)

def test_bad_inputs_still_recovers(self):
Expand Down
2 changes: 1 addition & 1 deletion tests_basic/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class LocationMixin:
@classmethod
def get_filename(cls):
"""Return the canonical path to the file."""
if cls.dir_location is '':
if cls.dir_location == '':
return get_file_from_cloud_test_repo([cls.cloud_dir, *cls.file_path])
else:
return osp.join(cls.dir_location, *cls.file_path)
Expand Down

0 comments on commit 8de1b54

Please sign in to comment.