Skip to content

Commit

Permalink
simplify error handling
Browse files Browse the repository at this point in the history
Co-authored-by: Niko Sirmpilatze <[email protected]>
  • Loading branch information
alessandrofelder and niksirbi committed Aug 15, 2024
1 parent 2ca604c commit f2a5f21
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions brainglobe_utils/IO/image/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit f2a5f21

Please sign in to comment.