Skip to content

Commit 4346ff5

Browse files
authored
Merge pull request #157 from DeepLabCut/cy/fix-h5-sorting
Fix & improve frame matching behavior
2 parents 2509cde + 37b333f commit 4346ff5

5 files changed

Lines changed: 577 additions & 110 deletions

File tree

src/napari_deeplabcut/_reader.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def read_images(path: str | Path | list[str | Path]):
253253

254254
# Multiple images → lazy-imread stack
255255
if len(filepaths) > 1:
256-
relative_paths = [str(Path(*fp.parts[-3:])) for fp in filepaths]
256+
relative_paths = [misc.canonicalize_path(fp, 3) for fp in filepaths]
257257
params = {
258258
"name": "images",
259259
"metadata": {
@@ -269,7 +269,7 @@ def read_images(path: str | Path | list[str | Path]):
269269
params = {
270270
"name": "images",
271271
"metadata": {
272-
"paths": [str(Path(*image_path.parts[-3:]))],
272+
"paths": [misc.canonicalize_path(image_path, 3)],
273273
"root": str(image_path.parent),
274274
},
275275
}
@@ -404,8 +404,11 @@ def read_hdf(filename: str) -> list[LayerData]:
404404
else:
405405
image_inds, paths2inds = misc.encode_categories(
406406
image_paths,
407-
return_map=True,
407+
is_path=True,
408+
return_unique=True,
409+
do_sort=True,
408410
)
411+
409412
data[:, 0] = image_inds
410413
data[:, 1:] = df[["y", "x"]].to_numpy()
411414
metadata = _populate_metadata(

src/napari_deeplabcut/_tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# src/napari_deeplabcut/_tests/conftest.py
12
import json
23
import os
34
from pathlib import Path

0 commit comments

Comments
 (0)