diff --git a/requirements.txt b/requirements.txt index d0a269ba9..98b7cd386 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ wkw==0.0.6 requests black cluster_tools==1.36 +natsort \ No newline at end of file diff --git a/setup.py b/setup.py index 230ae5dfb..00cb02f59 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ packages=find_packages(exclude=("tests",)), use_scm_version=True, setup_requires=['setuptools_scm'], - install_requires=["scipy", "numpy", "pillow", "pyyaml", "wkw", "cluster_tools==1.36"], + install_requires=["scipy", "numpy", "pillow", "pyyaml", "wkw", "cluster_tools==1.36", "natsort"], description="A cubing tool for webKnossos", author="Norman Rzepka", author_email="norman.rzepka@scalableminds.com", diff --git a/wkcuber/cubing.py b/wkcuber/cubing.py index b05e0a9b8..d19f561dc 100644 --- a/wkcuber/cubing.py +++ b/wkcuber/cubing.py @@ -3,6 +3,7 @@ import numpy as np from argparse import ArgumentParser from os import path +from natsort import natsorted from .utils import ( get_chunks, @@ -74,8 +75,7 @@ def find_source_filenames(source_path): + str(image_reader.readers.keys()) + "." ) - source_files.sort() - return source_files + return natsorted(source_files) def read_image_file(file_name, dtype): diff --git a/wkcuber/tile_cubing.py b/wkcuber/tile_cubing.py index 83f399fea..20eae458a 100644 --- a/wkcuber/tile_cubing.py +++ b/wkcuber/tile_cubing.py @@ -6,6 +6,7 @@ from argparse import ArgumentParser from os import path, listdir from PIL import Image +from natsort import natsorted from .utils import ( get_chunks, @@ -31,8 +32,7 @@ def find_source_sections(source_path): f for f in listdir(source_path) if path.isdir(path.join(source_path, f)) ] section_folders = [path.join(source_path, s) for s in section_folders] - section_folders.sort() - return section_folders + return natsorted(section_folders) def parse_tile_file_name(filename): @@ -49,9 +49,7 @@ def find_source_files(source_section_path): path.join(source_section_path, "**", "*"), image_reader.readers.keys() ) ] - - all_source_files.sort() - return all_source_files + return natsorted(all_source_files) def tile_cubing_job(target_wkw_info, z_batches, source_path, batch_size, tile_size):