Skip to content

Commit 9328ac2

Browse files
authored
Natsort images when Path passed to add_layer_from_images (#854)
* Natsort images when Path passed to add_layer_from_images * format * changelog
1 parent 173ffc4 commit 9328ac2

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

webknossos/Changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ For upgrade instructions, please check the respective *Breaking Changes* section
1919
### Changed
2020

2121
### Fixed
22-
22+
- Fixed a bug, where the image order could be randomized when passing a directory path to `Dataset.add_layer_from_images`. [#854](https://github.com/scalableminds/webknossos-libs/pull/854)
2323

2424
## [0.11.1](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.11.1) - 2023-01-05
2525
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.11.0...v0.11.1)

webknossos/webknossos/dataset/_utils/pims_images.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from urllib.error import HTTPError
2222

2323
import numpy as np
24+
from natsort import natsorted
2425

2526
# pylint: disable=unused-import
2627
try:
@@ -294,11 +295,11 @@ def _normalize_original_images(self) -> Union[str, List[str]]:
294295
original_images_path = Path(original_images)
295296
if original_images_path.is_dir():
296297
valid_suffixes = get_valid_pims_suffixes()
297-
original_images = [
298+
original_images = natsorted(
298299
str(i)
299300
for i in original_images_path.glob("**/*")
300301
if i.is_file() and i.suffix.lstrip(".") in valid_suffixes
301-
]
302+
)
302303
if len(original_images) == 1:
303304
original_images = original_images[0]
304305
if isinstance(original_images, str):

0 commit comments

Comments
 (0)