From 09a8c71059dd6beca88d644489a5ba83a854346f Mon Sep 17 00:00:00 2001 From: "glegoc@NeuroPSI" Date: Wed, 15 Jan 2025 10:15:39 +0100 Subject: [PATCH] Update segment_images.py - added explicit error when no files in directory --- scripts/segmentation/segment_images.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/segmentation/segment_images.py b/scripts/segmentation/segment_images.py index d1bb785..1bfdfdc 100644 --- a/scripts/segmentation/segment_images.py +++ b/scripts/segmentation/segment_images.py @@ -19,7 +19,7 @@ with the same names as probabilities images (without their suffix). author : Guillaume Le Goc (g.legoc@posteo.org) @ NeuroPSI -version : 2024.12.10 +version : 2025.1.15 """ @@ -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 @@ -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,