diff --git a/brainglobe_utils/IO/image/load.py b/brainglobe_utils/IO/image/load.py index afee5f5..c9fb6e1 100644 --- a/brainglobe_utils/IO/image/load.py +++ b/brainglobe_utils/IO/image/load.py @@ -783,17 +783,12 @@ def read_with_dask(path): filenames = [line.rstrip() for line in f.readlines()] else: - filenames_tif = glob.glob(os.path.join(path, "*.tif")) - filenames_tiff = glob.glob(os.path.join(path, "*.tiff")) - if filenames_tif: - filenames = filenames_tif - elif filenames_tiff: - filenames = filenames_tiff - else: - raise ( - ValueError( - f"Folder {path} does not contain any .tif or .tiff files" - ) + filenames = glob.glob(os.path.join(path, "*.tif")) or glob.glob( + os.path.join(path, "*.tiff") + ) + if not filenames: + raise ValueError( + f"Folder {path} does not contain any .tif or .tiff files" ) shape, dtype = get_tiff_meta(filenames[0])