Skip to content

Commit

Permalink
use natural sort for ordering input data (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippotto authored Aug 8, 2019
1 parent 5c1cd95 commit 4859954
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ wkw==0.0.6
requests
black
cluster_tools==1.36
natsort
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]",
Expand Down
4 changes: 2 additions & 2 deletions wkcuber/cubing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 3 additions & 5 deletions wkcuber/tile_cubing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit 4859954

Please sign in to comment.