Skip to content

Commit

Permalink
fix: ruff errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjermiah committed May 16, 2024
1 parent 9cc441b commit 73052c8
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.12", "3.11", "3.10"]
python-version: 3.11
# python-version: ["3.12", "3.11", "3.10"]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion examples/radcure_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def process_one_subject(self, subject_id):

image = self.image_input(subject_id).image

structure_set = self.structure_set_input(subject_id)
structure_set = self.structure_set_input(subject_id) # noqa: F841
dose_set = self.rtdose_input(subject_id)
pet_set = self.petscan_input(subject_id)

Expand Down
2 changes: 1 addition & 1 deletion src/imgtools/autopipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def process_one_subject(self, subject_id):
if conn_to == "CT" or conn_to == "MR":
img = image
elif conn_to == "PT":
img = pet
img = pet # noqa: F821

mask = self.make_binary_mask(structure_set, img,
self.existing_roi_indices,
Expand Down
3 changes: 0 additions & 3 deletions src/imgtools/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ def geometry(self):
direction=self.direction,
spacing=self.spacing)

@property
def size(self):
return self._image.GetSize()[::-1]

@property
def ndim(self):
Expand Down
2 changes: 1 addition & 1 deletion src/imgtools/io/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def process_one_subject(
if conn_to == "CT":
mask = make_binary_mask(structure_set, image)
elif conn_to == "PT":
mask = make_binary_mask(structure_set, pet)
mask = make_binary_mask(structure_set, pet) # noqa: F821
else:
raise ValueError("You need to pass a reference CT or PT/PET image to map contours to.")
temp[f"mod_{colname}"] = tio.LabelMap.from_sitk(mask)
Expand Down
2 changes: 1 addition & 1 deletion src/imgtools/io/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def put(self, subject_id, mask, **kwargs):

origin = mask.GetOrigin()
spacing = mask.GetSpacing()
direction = mask.GetDirection()
direction = mask.GetDirection() # noqa: F841

space = "left-posterior-superior" # everything is ITK read/write

Expand Down
2 changes: 1 addition & 1 deletion src/imgtools/modules/datagraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def parser(self, query_string: str) -> pd.DataFrame:
'''
# Basic processing of just one modality
supp_mods = ["RTDOSE", "RTSTRUCT", "CT", "PT", 'MR', 'SEG']
edge_def = {"RTSTRUCT,RTDOSE" : 0, "CT,RTDOSE" : 1, "CT,RTSTRUCT" : 2, "PET,RTSTRUCT" : 3, "CT,PT" : 4, 'MR,RTSTRUCT': 2, "RTPLAN,RTSTRUCT": 6, "RTPLAN,RTDOSE": 5, "CT,SEG": 7, "MR,SEG": 7, "MR,RTSTRUCT": 2}
edge_def = {"RTSTRUCT,RTDOSE" : 0, "CT,RTDOSE" : 1, "CT,RTSTRUCT" : 2, "PET,RTSTRUCT" : 3, "CT,PT" : 4, 'MR,RTSTRUCT': 2, "RTPLAN,RTSTRUCT": 6, "RTPLAN,RTDOSE": 5, "CT,SEG": 7, "MR,SEG": 7}
self.mods = query_string.split(",")
self.mods_n = len(self.mods)

Expand Down
4 changes: 2 additions & 2 deletions src/imgtools/ops/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def __init__(self,

import json
with open(tree_crawl_path, 'r') as f:
tree_db = json.load(f) # currently unused, TO BE implemented in the future
tree_db = json.load(f) # currently unused, TO BE implemented in the future # noqa: F841

# GRAPH
# -----
Expand Down Expand Up @@ -1636,7 +1636,7 @@ def get_mask(self, reference_image, seg, mask, label, idx, continuous):
mask[:,:,:,idx] += seg[:,:,:,idx_seg]
else: # if 2D segmentations on 3D images
frame = seg.frame_groups[idx_seg]
ref_uid = frame.DerivationImageSequence[0].SourceImageSequence[0].ReferencedSOPInstanceUID # unused but references InstanceUID of slice
ref_uid = frame.DerivationImageSequence[0].SourceImageSequence[0].ReferencedSOPInstanceUID # unused but references InstanceUID of slice # noqa: F841
frame_coords = np.array(frame.PlanePositionSequence[0].ImagePositionPatient)
img_coords = physical_points_to_idxs(reference_image, np.expand_dims(frame_coords, (0, 1)))[0][0]
z = img_coords[0]
Expand Down
2 changes: 1 addition & 1 deletion src/imgtools/utils/nnunet.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def subfiles(folder: str, join: bool = True, prefix: str = None, suffix: str = N
if join:
path_fn = os.path.join
else:
path_fn = lambda x, y: y
path_fn = lambda x, y: y # noqa: E731
res = [path_fn(folder, i) for i in os.listdir(folder) if os.path.isfile(os.path.join(folder, i))
and (prefix is None or i.startswith(prefix))
and (suffix is None or i.endswith(suffix))]
Expand Down
2 changes: 1 addition & 1 deletion tests/dataset_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def dataset_path():

#Defining paths for autopipeline and dataset component
crawl_path = pathlib.Path(imgtools_path, f"imgtools_{dataset_name}.csv").as_posix()
json_path = pathlib.Path(imgtools_path, f"imgtools_{dataset_name}.json").as_posix()
json_path = pathlib.Path(imgtools_path, f"imgtools_{dataset_name}.json").as_posix() # noqa: F841
edge_path = pathlib.Path(imgtools_path, f"imgtools_{dataset_name}_edges.csv").as_posix()
yield quebec_path, output_path, crawl_path, edge_path

Expand Down
2 changes: 1 addition & 1 deletion tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def dataset_path():

#Defining paths for autopipeline and dataset component
crawl_path = pathlib.Path(imgtools_path, f"imgtools_{dataset_name}.csv").as_posix()
json_path = pathlib.Path(imgtools_path, f"imgtools_{dataset_name}.json").as_posix()
json_path = pathlib.Path(imgtools_path, f"imgtools_{dataset_name}.json").as_posix() # noqa: F841
edge_path = pathlib.Path(imgtools_path, f"imgtools_{dataset_name}_edges.csv").as_posix()
yield quebec_path, output_path, crawl_path, edge_path

Expand Down

0 comments on commit 73052c8

Please sign in to comment.