Skip to content

Commit c4b53b0

Browse files
authored
Unit support (#1136)
* 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.
1 parent 92a14bb commit c4b53b0

File tree

51 files changed

+2846
-2475
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2846
-2475
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ The `webknossos` folder contains examples, which are not part of the package, bu
140140
The tests also contain functionality for the WEBKNOSSOS client. There a two modes to run the tests:
141141

142142
1. `./test.sh --refresh-snapshots`, sending network requests to a WEBKNOSSOS instance:
143-
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:
143+
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:
144144
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.
145145

146146
`./test.sh --store-durations` updates the durations for

webknossos/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
1515
### Breaking Changes
1616

1717
### Added
18+
- 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)
1819

1920
### Changed
2021

webknossos/local_wk_setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function export_vars {
22
export WK_TOKEN=1b88db86331a38c21a0b235794b9e459856490d70408bcffb767f64ade0f83d2bdb4c4e181b9a9a30cdece7cb7c65208cc43b6c1bb5987f5ece00d348b1a905502a266f8fc64f0371cd6559393d72e031d0c2d0cabad58cccf957bb258bc86f05b5dc3d4fff3d5e3d9c0389a6027d861a21e78e3222fb6c5b7944520ef21761e
33
export WK_URL=http://localhost:9000
4-
export DOCKER_TAG=master__27071
4+
export DOCKER_TAG=master__28678
55
}
66

77
function ensure_local_test_wk {

webknossos/testdata/complex_property_ds/datasource-properties.json

Lines changed: 78 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,62 @@
88
"name": "color",
99
"category": "color",
1010
"boundingBox": {
11-
"topLeft": [0, 0, 0],
11+
"topLeft": [
12+
0,
13+
0,
14+
0
15+
],
1216
"width": 1024,
1317
"height": 1024,
1418
"depth": 1024
1519
},
1620
"wkwResolutions": [
1721
{
18-
"resolution": [1, 1, 1],
22+
"resolution": [
23+
1,
24+
1,
25+
1
26+
],
1927
"cubeLength": 1024
2028
},
2129
{
22-
"resolution": [16, 16, 16],
30+
"resolution": [
31+
16,
32+
16,
33+
16
34+
],
2335
"cubeLength": 64
2436
},
2537
{
26-
"resolution": [2, 2, 2],
38+
"resolution": [
39+
2,
40+
2,
41+
2
42+
],
2743
"cubeLength": 512
2844
},
2945
{
30-
"resolution": [32, 32, 32],
46+
"resolution": [
47+
32,
48+
32,
49+
32
50+
],
3151
"cubeLength": 32
3252
},
3353
{
34-
"resolution": [4, 4, 4],
54+
"resolution": [
55+
4,
56+
4,
57+
4
58+
],
3559
"cubeLength": 256
3660
},
3761
{
38-
"resolution": [8, 8, 8],
62+
"resolution": [
63+
8,
64+
8,
65+
8
66+
],
3967
"cubeLength": 128
4068
}
4169
],
@@ -45,34 +73,62 @@
4573
{
4674
"name": "segmentation",
4775
"boundingBox": {
48-
"topLeft": [0, 0, 0],
76+
"topLeft": [
77+
0,
78+
0,
79+
0
80+
],
4981
"width": 1024,
5082
"height": 1024,
5183
"depth": 1024
5284
},
5385
"wkwResolutions": [
5486
{
55-
"resolution": [1, 1, 1],
87+
"resolution": [
88+
1,
89+
1,
90+
1
91+
],
5692
"cubeLength": 1024
5793
},
5894
{
59-
"resolution": [16, 16, 16],
95+
"resolution": [
96+
16,
97+
16,
98+
16
99+
],
60100
"cubeLength": 64
61101
},
62102
{
63-
"resolution": [2, 2, 2],
103+
"resolution": [
104+
2,
105+
2,
106+
2
107+
],
64108
"cubeLength": 512
65109
},
66110
{
67-
"resolution": [32, 32, 32],
111+
"resolution": [
112+
32,
113+
32,
114+
32
115+
],
68116
"cubeLength": 32
69117
},
70118
{
71-
"resolution": [4, 4, 4],
119+
"resolution": [
120+
4,
121+
4,
122+
4
123+
],
72124
"cubeLength": 256
73125
},
74126
{
75-
"resolution": [8, 8, 8],
127+
"resolution": [
128+
8,
129+
8,
130+
8
131+
],
76132
"cubeLength": 128
77133
}
78134
],
@@ -90,5 +146,12 @@
90146
"dataFormat": "wkw"
91147
}
92148
],
93-
"scale": [11.239999771118164, 11.239999771118164, 28]
149+
"scale": {
150+
"unit": "nanometer",
151+
"factor": [
152+
11.239999771118164,
153+
11.239999771118164,
154+
28
155+
]
156+
}
94157
}

webknossos/testdata/tiff/datasource-properties.wkw-fixture.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,33 @@
1111
"elementClass": "uint8",
1212
"wkwResolutions": [
1313
{
14-
"resolution": [1, 1, 1],
14+
"resolution": [
15+
1,
16+
1,
17+
1
18+
],
1519
"cubeLength": 1024
1620
}
1721
],
1822
"numChannels": 1,
1923
"boundingBox": {
20-
"topLeft": [0, 0, 0],
24+
"topLeft": [
25+
0,
26+
0,
27+
0
28+
],
2129
"width": 265,
2230
"height": 265,
2331
"depth": 257
2432
}
2533
}
2634
],
27-
"scale": [11.24, 11.24, 25.0]
35+
"scale": {
36+
"unit": "nanometer",
37+
"factor": [
38+
11.24,
39+
11.24,
40+
25.0
41+
]
42+
}
2843
}

webknossos/testdata/tiff/datasource-properties.zarr-fixture.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
"name": "test_dataset",
44
"team": "<unknown>"
55
},
6-
"scale": [
7-
11.24,
8-
11.24,
9-
25.0
10-
],
6+
"scale": {
7+
"unit": "nanometer",
8+
"factor": [
9+
11.24,
10+
11.24,
11+
25.0
12+
]
13+
},
1114
"dataLayers": [
1215
{
1316
"name": "tiff",
@@ -43,4 +46,4 @@
4346
"largestSegmentId": 255
4447
}
4548
]
46-
}
49+
}

0 commit comments

Comments
 (0)