Skip to content

Commit

Permalink
Unit support (#1136)
Browse files Browse the repository at this point in the history
* Support new properties.json format with unit.

* Implement requested changes.

* Added newlines in datasource-properties.json.

* Update changelog.

* Add conversion hook for Unit.

* Rename unit to length_unit.

* Fix naming issues, and add unit to CLI

* Set default in CLI to string instead of LengthUnit

There seems to be an typer issue, that a LengthUnit is not recognized.

* Create constants for default unit and default unit str.
  • Loading branch information
markbader committed Jul 18, 2024
1 parent 92a14bb commit c4b53b0
Show file tree
Hide file tree
Showing 51 changed files with 2,846 additions and 2,475 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ The `webknossos` folder contains examples, which are not part of the package, bu
The tests also contain functionality for the WEBKNOSSOS client. There a two modes to run the tests:

1. `./test.sh --refresh-snapshots`, sending network requests to a WEBKNOSSOS instance:
This expects a local WEBKNOSSOS setup with specific test data, which is shipped with WEBKNOSSOS. If you're starting and running WEBKNOSSOS manually, please use port 9000 (the default) and run the `tools/postgres/prepareTestDb.sh` script in the WEBKNOSSOS repository (⚠️ this overwrites your local WEBKNOSSOS database). Alternatively, a docker-compose setup is started automatically for the tests, see `./test.sh` and `tests/docker-compose.yml` for details. The network requests & response are recorded as "cassettes" by [vcr.py](https://vcrpy.readthedocs.io), see next point:
This expects a local WEBKNOSSOS setup with specific test data, which is shipped with WEBKNOSSOS. If you're starting and running WEBKNOSSOS manually, please use port 9000 (the default) and run the `tools/postgres/dbtool.js prepare-test-db` script in the WEBKNOSSOS repository (⚠️ this overwrites your local WEBKNOSSOS database). Alternatively, a docker-compose setup is started automatically for the tests, see `./test.sh` and `tests/docker-compose.yml` for details. The network requests & response are recorded as "cassettes" by [vcr.py](https://vcrpy.readthedocs.io), see next point:
2. `./test.sh` replays responses from previous network snapshots using [vcr.py](https://vcrpy.readthedocs.io) via [pytest-recording](https://github.com/kiwicom/pytest-recording). No additional network requests are allowed in this mode.

`./test.sh --store-durations` updates the durations for
Expand Down
1 change: 1 addition & 0 deletions webknossos/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
### Breaking Changes

### Added
- Added support for new voxel size that stores unit and updated to WEBKNOSSOS API version 7. [#1136](https://github.com/scalableminds/webknossos-libs/pull/1136)

### Changed

Expand Down
2 changes: 1 addition & 1 deletion webknossos/local_wk_setup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function export_vars {
export WK_TOKEN=1b88db86331a38c21a0b235794b9e459856490d70408bcffb767f64ade0f83d2bdb4c4e181b9a9a30cdece7cb7c65208cc43b6c1bb5987f5ece00d348b1a905502a266f8fc64f0371cd6559393d72e031d0c2d0cabad58cccf957bb258bc86f05b5dc3d4fff3d5e3d9c0389a6027d861a21e78e3222fb6c5b7944520ef21761e
export WK_URL=http://localhost:9000
export DOCKER_TAG=master__27071
export DOCKER_TAG=master__28678
}

function ensure_local_test_wk {
Expand Down
93 changes: 78 additions & 15 deletions webknossos/testdata/complex_property_ds/datasource-properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,62 @@
"name": "color",
"category": "color",
"boundingBox": {
"topLeft": [0, 0, 0],
"topLeft": [
0,
0,
0
],
"width": 1024,
"height": 1024,
"depth": 1024
},
"wkwResolutions": [
{
"resolution": [1, 1, 1],
"resolution": [
1,
1,
1
],
"cubeLength": 1024
},
{
"resolution": [16, 16, 16],
"resolution": [
16,
16,
16
],
"cubeLength": 64
},
{
"resolution": [2, 2, 2],
"resolution": [
2,
2,
2
],
"cubeLength": 512
},
{
"resolution": [32, 32, 32],
"resolution": [
32,
32,
32
],
"cubeLength": 32
},
{
"resolution": [4, 4, 4],
"resolution": [
4,
4,
4
],
"cubeLength": 256
},
{
"resolution": [8, 8, 8],
"resolution": [
8,
8,
8
],
"cubeLength": 128
}
],
Expand All @@ -45,34 +73,62 @@
{
"name": "segmentation",
"boundingBox": {
"topLeft": [0, 0, 0],
"topLeft": [
0,
0,
0
],
"width": 1024,
"height": 1024,
"depth": 1024
},
"wkwResolutions": [
{
"resolution": [1, 1, 1],
"resolution": [
1,
1,
1
],
"cubeLength": 1024
},
{
"resolution": [16, 16, 16],
"resolution": [
16,
16,
16
],
"cubeLength": 64
},
{
"resolution": [2, 2, 2],
"resolution": [
2,
2,
2
],
"cubeLength": 512
},
{
"resolution": [32, 32, 32],
"resolution": [
32,
32,
32
],
"cubeLength": 32
},
{
"resolution": [4, 4, 4],
"resolution": [
4,
4,
4
],
"cubeLength": 256
},
{
"resolution": [8, 8, 8],
"resolution": [
8,
8,
8
],
"cubeLength": 128
}
],
Expand All @@ -90,5 +146,12 @@
"dataFormat": "wkw"
}
],
"scale": [11.239999771118164, 11.239999771118164, 28]
"scale": {
"unit": "nanometer",
"factor": [
11.239999771118164,
11.239999771118164,
28
]
}
}
21 changes: 18 additions & 3 deletions webknossos/testdata/tiff/datasource-properties.wkw-fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,33 @@
"elementClass": "uint8",
"wkwResolutions": [
{
"resolution": [1, 1, 1],
"resolution": [
1,
1,
1
],
"cubeLength": 1024
}
],
"numChannels": 1,
"boundingBox": {
"topLeft": [0, 0, 0],
"topLeft": [
0,
0,
0
],
"width": 265,
"height": 265,
"depth": 257
}
}
],
"scale": [11.24, 11.24, 25.0]
"scale": {
"unit": "nanometer",
"factor": [
11.24,
11.24,
25.0
]
}
}
15 changes: 9 additions & 6 deletions webknossos/testdata/tiff/datasource-properties.zarr-fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
"name": "test_dataset",
"team": "<unknown>"
},
"scale": [
11.24,
11.24,
25.0
],
"scale": {
"unit": "nanometer",
"factor": [
11.24,
11.24,
25.0
]
},
"dataLayers": [
{
"name": "tiff",
Expand Down Expand Up @@ -43,4 +46,4 @@
"largestSegmentId": 255
}
]
}
}
Loading

0 comments on commit c4b53b0

Please sign in to comment.