Repository: scalableminds/webknossos-libs

Issue:
Volume Layer dimensions are incorrectly inferred.
## Context
- Affected library: `webknossos`
- I created some volume annotations as tasks in wK and now want to re-unite / connect them as ground-truth segmentation layers with the original datasets. 
- When exporting a volume annotation as a new segmentation layer to any existing dataset (`annotation.export_volume_layer_to_dataset(...)`), wk-libs tries to infer the size/dimensions/BB of the volume layer. The heuristic used for that assumes that the volume annotations were created in Mag(1).
- In my case the volume annotation spanned the whole dataset. In other words, the annotation's BB should match the dataset's outer bounds/color layer's BB.

```
import webknossos as wk

annotation = wk.Annotation.download(<url/to/my/task>)
ds = wk.Dataset.open(<path>)
annotation.export_volume_layer_to_dataset(dataset, layer_name="segmentation")

color_layer = ds.get_layer("color")
seg_layer = ds.get_layer("segmentation")

color_layer.bounding_box
> Out[25]: BoundingBox(topleft=(0, 0, 0), size=(9688, 7168, 1))

seg_layer.bounding_box
> Out[26]: BoundingBox(topleft=(0, 0, 0), size=(4704, 3584, 32))
```

## Expected Behavior
<!--- What should should happen instead of the bug / error message. -->
The inferred BB of the exported volume annotation should be correct and take the Mag of the annotation into account.

## Current Behavior
- In my particular case, the volume annotation has finest magnification of 2-2-1 and the resulting BB was about a 1/4 of the color layers (Mag 1-1-1) in XY. (Top-left quadrant)
  - In X-direction the inferred dimension is roughly 1/2 of what it should be. Not sure why there is a slight deviation... 
  - In Y-direction the inferred dimension is exactly 1/2 of what it should be.
- Additionally, this particular dataset consist of only 2D data, i.e. Z-depth of 1. The inferred BB has a z-depth of 32 (likely the minimum cube_length or something), which is also wrong

## Steps to Reproduce the bug
<!-- If the bug is hard to reproduce check the following: -->
- [ ] Cannot reproduce the bug anymore / needs deeper investigation.
<!--- If you can reproduce the bug, provide a list of actions to reproduce the bug. -->

1. Create a volume annotation with a restriction to a minimum mag of 2-2-1
2. Use the above code snippet above to export the annotation as a new segmentation layer and see the wrong BB.


## Your Environment for bug
<!--- In what environment did the bug occur? -->
- Operating System and version: MacOS Monterey 12.3.1
- Version of webKnossos-libs (Release or Commit): `0.10.5`




Discussion:

Resolving patch:
diff --git a/webknossos/webknossos/dataset/_array.py b/webknossos/webknossos/dataset/_array.py
--- a/webknossos/webknossos/dataset/_array.py
+++ b/webknossos/webknossos/dataset/_array.py
@@ -116,7 +116,7 @@ def ensure_size(
 
     @abstractmethod
     def list_bounding_boxes(self) -> Iterator[BoundingBox]:
-        pass
+        "The bounding boxes are measured in voxels of the current mag."
 
     @abstractmethod
     def close(self) -> None:
diff --git a/webknossos/webknossos/dataset/_utils/infer_bounding_box_existing_files.py b/webknossos/webknossos/dataset/_utils/infer_bounding_box_existing_files.py
--- a/webknossos/webknossos/dataset/_utils/infer_bounding_box_existing_files.py
+++ b/webknossos/webknossos/dataset/_utils/infer_bounding_box_existing_files.py
@@ -6,8 +6,9 @@
 
 def infer_bounding_box_existing_files(mag_view: MagView) -> BoundingBox:
     """Since volume annotation layers are only a single layer, they do not contain a datasource-properties.json.
-    Therefore, the bounding box needs to be inferred when working with those."""
+    Therefore, the bounding box needs to be inferred when working with those.
+    The returned bounding box is measured in Mag(1) voxels."""
 
     return reduce(
-        lambda acc, bbox: acc.extended_by(bbox), mag_view._array.list_bounding_boxes()
+        lambda acc, bbox: acc.extended_by(bbox), mag_view.get_bounding_boxes_on_disk()
     )


Test patch: