Skip to content

Commit 1acbdfc

Browse files
MichaelBuessemeyerMichael Büßemeyer
andauthored
Parse dataset id from downloaded nml (#1256)
* parse dataset id from downloaded nml * add changelog entry * add test testing access to renamed dataset from an annotation - improve existing test to check whether the dataset id is parsed from a zipped annotation * format tests * fix dumping dataset id to nml in wklibs * remove regression test and do it in a follow up pr * remove debug logs --------- Co-authored-by: Michael Büßemeyer <[email protected]>
1 parent fbec20b commit 1acbdfc

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

webknossos/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
1919
### Changed
2020

2121
### Fixed
22+
- Fixed opening a renamed dataset via an annotation link. [#1256](https://github.com/scalableminds/webknossos-libs/pull/1256)
2223

2324

2425
## [0.16.8](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.16.8) - 2025-02-04
Binary file not shown.

webknossos/tests/test_annotation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def test_annotation_from_wkw_zip_file() -> None:
2121

2222
assert annotation.dataset_name == "l4dense_motta_et_al_demo_v2"
2323
assert annotation.organization_id == "scalable_minds"
24+
assert annotation.dataset_id == "67b7c81b0100004d00f5ab31"
2425
assert annotation.owner_name == "Philipp Otto"
2526
assert annotation.annotation_id == "61c20205010000cc004a6356"
2627
assert "timestamp" in annotation.metadata
@@ -32,6 +33,7 @@ def test_annotation_from_wkw_zip_file() -> None:
3233

3334
assert copied_annotation.dataset_name == "l4dense_motta_et_al_demo_v2"
3435
assert copied_annotation.organization_id == "scalable_minds"
36+
assert copied_annotation.dataset_id == "67b7c81b0100004d00f5ab31"
3537
assert copied_annotation.owner_name == "Philipp Otto"
3638
assert copied_annotation.annotation_id == "61c20205010000cc004a6356"
3739
assert "timestamp" in copied_annotation.metadata

webknossos/webknossos/_nml/parameters.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Parameters(NamedTuple):
1515
scale: Vector3 # dataset voxel_size
1616
description: Optional[str] = None
1717
organization: Optional[str] = None
18+
dataset_id: Optional[str] = None
1819
offset: Optional[Vector3] = None # deprecated. Kept for backward compatibility.
1920
time: Optional[int] = (
2021
None # UNIX timestamp marking the creation time & date of an annotation.
@@ -87,6 +88,7 @@ def _dump(self, xf: XmlWriter) -> None:
8788
"name": self.name,
8889
"organization": self.organization,
8990
"description": self.description,
91+
"datasetId": self.dataset_id,
9092
}
9193
),
9294
)
@@ -240,6 +242,7 @@ def _parse(cls, nml_parameters: Element) -> "Parameters":
240242
name=experiment_element.get("name", "Unnamed Experiment"),
241243
description=experiment_element.get("description"),
242244
organization=experiment_element.get("organization"),
245+
dataset_id=experiment_element.get("datasetId"),
243246
scale=(
244247
float(scale_element.get("x", 0)),
245248
float(scale_element.get("y", 0)),

webknossos/webknossos/annotation/_nml_conversion.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def nml_to_skeleton(nml: wknml.Nml) -> "Skeleton":
1919
from ..skeleton import Skeleton
2020

2121
skeleton = Skeleton(
22+
dataset_id=nml.parameters.dataset_id,
2223
dataset_name=nml.parameters.name,
2324
voxel_size=nml.parameters.scale,
2425
organization_id=nml.parameters.organization,
@@ -120,7 +121,8 @@ def _random_color_rgba() -> Tuple[float, float, float, float]:
120121
def annotation_to_nml(
121122
annotation: "Annotation",
122123
) -> wknml.Nml:
123-
nmlParameters = wknml.Parameters(
124+
nml_parameters = wknml.Parameters(
125+
dataset_id=annotation.dataset_id,
124126
name=annotation.dataset_name,
125127
scale=annotation.voxel_size,
126128
description=annotation.description,
@@ -199,7 +201,7 @@ def annotation_to_nml(
199201

200202
nml = wknml.Nml(
201203
meta=meta,
202-
parameters=nmlParameters,
204+
parameters=nml_parameters,
203205
trees=trees,
204206
branchpoints=branchpoints,
205207
comments=comments,

0 commit comments

Comments
 (0)