Skip to content

Commit

Permalink
Fixed linting and testing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tkakar committed Feb 4, 2025
1 parent 0e51d52 commit 7e344f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/portal_visualization/builders/imaging_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _add_segmentation_image(self, dataset):
raise RuntimeError(f"Error while searching for segmentation images: {e}")

filtered_images = [
img for img in found_images
img for img in found_images
if not any(subdir in img for subdir in base_image_dirs)
]

Expand Down Expand Up @@ -247,15 +247,15 @@ def __init__(self, entity, groups_token, assets_endpoint, **kwargs):
self.seg_image_pyramid_regex = IMAGE_PYRAMID_DIR
self.view_type = KAGGLE_IMAGE_VIEW_TYPE

# Needed to adjust to various directory structures. For older datasets, the image pyramids will be present in either 'processed_microscopy' , 'processedMicroscopy'
# while newer datasets have lab_processed as directory.
# Needed to adjust to various directory structures. For older datasets, the image pyramids will be present in
# either 'processed_microscopy' , 'processedMicroscopy' while newer datasets have lab_processed as directory.

image_dir = SEGMENTATION_SUPPORT_IMAGE_SUBDIR
file_paths_found = self._get_file_paths()
paths = get_found_images_all(file_paths_found)
matched_dirs = {dir for dir in base_image_dirs if any(dir in img for img in paths)}

image_dir = list(matched_dirs)[0] if len(matched_dirs) >= 0 else image_dir
image_dir = next(iter(matched_dirs), image_dir)

self.image_pyramid_regex = f"{IMAGE_PYRAMID_DIR}/{image_dir}"

Expand Down
2 changes: 1 addition & 1 deletion src/portal_visualization/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
}

# To filter base image pyramids when finding segmentation mask images (kaggle-1, kaggle-2)
base_image_dirs = ['lab_processed', 'processed_microscopy' , 'processedMicroscopy']
base_image_dirs = ['lab_processed', 'processed_microscopy', 'processedMicroscopy']
2 changes: 2 additions & 0 deletions src/portal_visualization/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def get_found_images(image_pyramid_regex, file_paths_found):
]
return found_images


def get_found_images_all(file_paths_found):
found_images = [
path for path in get_matches(
Expand All @@ -93,6 +94,7 @@ def get_found_images_all(file_paths_found):
]
return found_images


def get_image_metadata(self, img_url):
"""
Retrieve metadata from an image URL.
Expand Down

0 comments on commit 7e344f8

Please sign in to comment.