From 79a0107fd72923266877a40534b865a7c4c18c25 Mon Sep 17 00:00:00 2001 From: Nicolas Peschke Date: Wed, 15 Sep 2021 14:08:29 +0200 Subject: [PATCH] fixing loading from txt file hotfix for https://github.com/brainglobe/cellfinder/issues/184 --- cellfinder_core/tools/IO.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cellfinder_core/tools/IO.py b/cellfinder_core/tools/IO.py index b5baea0c..8b1c5c48 100644 --- a/cellfinder_core/tools/IO.py +++ b/cellfinder_core/tools/IO.py @@ -33,7 +33,12 @@ def read_with_dask(path): :return: """ - filenames = glob.glob(os.path.join(path, "*.tif")) + if path.endswith(".txt"): + with open(path, "r") as f: + filenames = [line.rstrip() for line in f.readlines()] + + else: + filenames = glob.glob(os.path.join(path, "*.tif")) shape, dtype = get_tiff_meta(filenames[0]) lazy_arrays = [lazy_imread(fn) for fn in get_sorted_file_paths(filenames)]