Skip to content

Commit 5181fb5

Browse files
authored
default to -1 for largestSegmentId (#362)
* default to -1 for largestSegmentId * Update Changelog.md * minor fix * formatting
1 parent 9362e06 commit 5181fb5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ For upgrade instructions, please check the respective *Breaking Changes* section
1414
### Added
1515

1616
### Changed
17+
- Datasets with a missing `largestSegmentId` can now be loaded with a default of `-1`. [#362](https://github.com/scalableminds/webknossos-cuber/pull/362)
1718

1819
### Fixed
1920

wkcuber/api/properties/layer_properties.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from os.path import join, dirname, isfile
23
from pathlib import Path
34
from typing import Tuple, Type, Union, Any, Dict, List, Optional, cast
@@ -255,6 +256,11 @@ def _from_json(
255256
resolution_type: Type[Resolution],
256257
dataset_path: Path,
257258
) -> "SegmentationLayerProperties":
259+
if "largestSegmentId" not in json_data:
260+
warnings.warn(
261+
f"Segmentation layer {json_data['name']} is missing the 'largestSegmentId', defaulting to -1.",
262+
RuntimeWarning,
263+
)
258264
# create LayerProperties without resolutions
259265
layer_properties = cls(
260266
json_data["name"],
@@ -273,7 +279,7 @@ def _from_json(
273279
),
274280
json_data["boundingBox"],
275281
None,
276-
json_data["largestSegmentId"],
282+
json_data.get("largestSegmentId", -1),
277283
json_data.get("mappings"),
278284
json_data.get("defaultViewConfiguration"),
279285
)

0 commit comments

Comments
 (0)