Skip to content

Commit

Permalink
Update segment_images.py
Browse files Browse the repository at this point in the history
- added explicit error when no files in directory
  • Loading branch information
GuillaumeLeGoc committed Jan 15, 2025
1 parent f7e2f23 commit 09a8c71
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/segmentation/segment_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
with the same names as probabilities images (without their suffix).
author : Guillaume Le Goc ([email protected]) @ NeuroPSI
version : 2024.12.10
version : 2025.1.15
"""

Expand Down Expand Up @@ -345,6 +345,11 @@ def process_directory(
if filename.endswith(img_suffix)
]

if len(images_list) == 0:
raise FileNotFoundError(
f"No file found in {images_dir}. Check 'IMAGES_DIR' and 'IMG_SUFFIX'."
)

# write parameters
parameters = parameters_as_dict(
images_dir, masks_dir, segtype, channel_suffix, proba_threshold, edge_dist
Expand Down Expand Up @@ -462,7 +467,7 @@ def make_suffix(s):

pbar = tqdm(channels_params)
for param in pbar:
pbar.set_description(f"Segmenting {param["name"]}")
pbar.set_description(f"Segmenting {param['name']}")
process_directory(
IMAGES_DIR,
img_suffix=IMG_SUFFIX,
Expand Down

0 comments on commit 09a8c71

Please sign in to comment.