From e5c20b219bf524d4923e2d5fa0cac7007374b6b1 Mon Sep 17 00:00:00 2001 From: Sebastien Besson Date: Tue, 8 Feb 2022 14:55:24 +0000 Subject: [PATCH 1/9] Extract the multiscales snippet into a JSON file validated by the schema --- .../valid_strict/multiscales_example.json | 37 ++++++++++++++++ 0.4/index.bs | 44 +++---------------- 2 files changed, 42 insertions(+), 39 deletions(-) create mode 100644 0.4/examples/valid_strict/multiscales_example.json diff --git a/0.4/examples/valid_strict/multiscales_example.json b/0.4/examples/valid_strict/multiscales_example.json new file mode 100644 index 00000000..2ef60bdd --- /dev/null +++ b/0.4/examples/valid_strict/multiscales_example.json @@ -0,0 +1,37 @@ +{ + "multiscales": [ + { + "version": "0.4", + "name": "example", + "axes": [ + {"name": "t", "type": "time", "unit": "millisecond"}, + {"name": "c", "type": "channel"}, + {"name": "z", "type": "space", "unit": "micrometer"}, + {"name": "y", "type": "space", "unit": "micrometer"}, + {"name": "x", "type": "space", "unit": "micrometer"} + ], + "datasets": [ + { + "path": "0", + "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 0.5, 0.5, 0.5]}] # the voxel size for the first scale level (0.5 micrometer) + } + { + "path": "1", + "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 1.0, 1.0, 1.0]}] # the voxel size for the second scale level (downscaled by a factor of 2 -> 1 micrometer) + }, + { + "path": "2", + "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 2.0, 2.0, 2.0]}] # the voxel size for the second scale level (downscaled by a factor of 4 -> 2 micrometer) + } + ], + "coordinateTransformations": [{"type": "scale", "scale": [0.1, 1.0, 1.0, 1.0, 1.0]], # the time unit (0.1 milliseconds), which is the same for each scale level + "type": "gaussian", + "metadata": { # the fields in metadata depend on the downscaling implementation + "method": "skimage.transform.pyramid_gaussian", # here, the paramters passed to the skimage function are given + "version": "0.16.1", + "args": "[true]", + "kwargs": {"multichannel": true} + } + } + ] +} \ No newline at end of file diff --git a/0.4/index.bs b/0.4/index.bs index 48677191..3f25f9df 100644 --- a/0.4/index.bs +++ b/0.4/index.bs @@ -285,45 +285,11 @@ Each "multiscales" dictionary SHOULD contain the field "name". It SHOULD contain Each "multiscales" dictionary SHOULD contain the field "type", which gives the type of downscaling method used to generate the multiscale image pyramid. It SHOULD contain the field "metadata", which contains a dictionary with additional information about the downscaling method. -``` -{ - "multiscales": [ - { - "version": "0.4", - "name": "example", - "axes": [ - {"name": "t", "type": "time", "unit": "millisecond"}, - {"name": "c", "type": "channel"}, - {"name": "z", "type": "space", "unit": "micrometer"}, - {"name": "y", "type": "space", "unit": "micrometer"}, - {"name": "x", "type": "space", "unit": "micrometer"} - ], - "datasets": [ - { - "path": "0", - "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 0.5, 0.5, 0.5]}] # the voxel size for the first scale level (0.5 micrometer) - } - { - "path": "1", - "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 1.0, 1.0, 1.0]}] # the voxel size for the second scale level (downscaled by a factor of 2 -> 1 micrometer) - }, - { - "path": "2", - "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 2.0, 2.0, 2.0]}] # the voxel size for the second scale level (downscaled by a factor of 4 -> 2 micrometer) - } - ], - "coordinateTransformations": [{"type": "scale", "scale": [0.1, 1.0, 1.0, 1.0, 1.0]], # the time unit (0.1 milliseconds), which is the same for each scale level - "type": "gaussian", - "metadata": { # the fields in metadata depend on the downscaling implementation - "method": "skimage.transform.pyramid_gaussian", # here, the paramters passed to the skimage function are given - "version": "0.16.1", - "args": "[true]", - "kwargs": {"multichannel": true} - } - } - ] -} -``` +
+path: examples/valid_strict/multiscales_example.json
+highlight: json
+
+ If only one multiscale is provided, use it. Otherwise, the user can choose by name, using the first multiscale as a fallback: From c460f1222dcbb5b9d6ecfa193526dcaa754456c2 Mon Sep 17 00:00:00 2001 From: Sebastien Besson Date: Tue, 8 Feb 2022 15:07:22 +0000 Subject: [PATCH 2/9] Fix invalid JSON elements (comments, missing parenthesis) --- 0.4/examples/valid_strict/multiscales_example.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/0.4/examples/valid_strict/multiscales_example.json b/0.4/examples/valid_strict/multiscales_example.json index 2ef60bdd..5d2f3b36 100644 --- a/0.4/examples/valid_strict/multiscales_example.json +++ b/0.4/examples/valid_strict/multiscales_example.json @@ -13,21 +13,21 @@ "datasets": [ { "path": "0", - "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 0.5, 0.5, 0.5]}] # the voxel size for the first scale level (0.5 micrometer) - } + "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 0.5, 0.5, 0.5]}] + }, { "path": "1", - "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 1.0, 1.0, 1.0]}] # the voxel size for the second scale level (downscaled by a factor of 2 -> 1 micrometer) + "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 1.0, 1.0, 1.0]}] }, { "path": "2", - "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 2.0, 2.0, 2.0]}] # the voxel size for the second scale level (downscaled by a factor of 4 -> 2 micrometer) + "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 2.0, 2.0, 2.0]}] } ], - "coordinateTransformations": [{"type": "scale", "scale": [0.1, 1.0, 1.0, 1.0, 1.0]], # the time unit (0.1 milliseconds), which is the same for each scale level + "coordinateTransformations": [{"type": "scale", "scale": [0.1, 1.0, 1.0, 1.0, 1.0]}], "type": "gaussian", - "metadata": { # the fields in metadata depend on the downscaling implementation - "method": "skimage.transform.pyramid_gaussian", # here, the paramters passed to the skimage function are given + "metadata": { + "method": "skimage.transform.pyramid_gaussian", "version": "0.16.1", "args": "[true]", "kwargs": {"multichannel": true} From 6e3a0a38a4809675e980d32e213a23e693b30134 Mon Sep 17 00:00:00 2001 From: Sebastien Besson Date: Thu, 10 Mar 2022 16:27:40 +0000 Subject: [PATCH 3/9] Split the coordinateTransformations for readability --- .../valid_strict/multiscales_example.json | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/0.4/examples/valid_strict/multiscales_example.json b/0.4/examples/valid_strict/multiscales_example.json index 5d2f3b36..b32a5af2 100644 --- a/0.4/examples/valid_strict/multiscales_example.json +++ b/0.4/examples/valid_strict/multiscales_example.json @@ -13,18 +13,30 @@ "datasets": [ { "path": "0", - "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 0.5, 0.5, 0.5]}] + "coordinateTransformations": [{ + "type": "scale", + "scale": [1.0, 1.0, 0.5, 0.5, 0.5] + }] }, { "path": "1", - "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 1.0, 1.0, 1.0]}] + "coordinateTransformations": [{ + "type": "scale", + "scale": [1.0, 1.0, 1.0, 1.0, 1.0] + }] }, { "path": "2", - "coordinateTransformations": [{"type": "scale", "scale": [1.0, 1.0, 2.0, 2.0, 2.0]}] + "coordinateTransformations": [{ + "type": "scale", + "scale": [1.0, 1.0, 2.0, 2.0, 2.0] + }] } ], - "coordinateTransformations": [{"type": "scale", "scale": [0.1, 1.0, 1.0, 1.0, 1.0]}], + "coordinateTransformations": [{ + "type": "scale", + "scale": [0.1, 1.0, 1.0, 1.0, 1.0] + }], "type": "gaussian", "metadata": { "method": "skimage.transform.pyramid_gaussian", From 0e5d65211a64f8f5ce5756f179ab5aaea6026ceb Mon Sep 17 00:00:00 2001 From: Sebastien Besson Date: Thu, 10 Mar 2022 16:29:49 +0000 Subject: [PATCH 4/9] Tentatively capture comments as custom description key/values --- 0.4/examples/valid_strict/multiscales_example.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/0.4/examples/valid_strict/multiscales_example.json b/0.4/examples/valid_strict/multiscales_example.json index b32a5af2..f661fbb3 100644 --- a/0.4/examples/valid_strict/multiscales_example.json +++ b/0.4/examples/valid_strict/multiscales_example.json @@ -14,6 +14,7 @@ { "path": "0", "coordinateTransformations": [{ + "description": "the voxel size for the first scale level (0.5 micrometer)", "type": "scale", "scale": [1.0, 1.0, 0.5, 0.5, 0.5] }] @@ -21,6 +22,7 @@ { "path": "1", "coordinateTransformations": [{ + "description": "the voxel size for the second scale level (downscaled by a factor of 2 -> 1 micrometer)", "type": "scale", "scale": [1.0, 1.0, 1.0, 1.0, 1.0] }] @@ -28,17 +30,20 @@ { "path": "2", "coordinateTransformations": [{ + "description": "the voxel size for the third scale level (downscaled by a factor of 4 -> 2 micrometer)", "type": "scale", "scale": [1.0, 1.0, 2.0, 2.0, 2.0] }] } ], "coordinateTransformations": [{ + "description": "the time unit (0.1 milliseconds), which is the same for each scale level", "type": "scale", "scale": [0.1, 1.0, 1.0, 1.0, 1.0] }], "type": "gaussian", "metadata": { + "description": "the fields in metadata depend on the downscaling implementation. Here, the parameters passed to the skimage function are given", "method": "skimage.transform.pyramid_gaussian", "version": "0.16.1", "args": "[true]", From fbf4aee3b2ee6deb9ba411eacab7a2cc0bc28304 Mon Sep 17 00:00:00 2001 From: Sebastien Besson Date: Wed, 16 Mar 2022 17:32:06 +0000 Subject: [PATCH 5/9] Convert back into comments --- 0.4/examples/valid_strict/multiscales_example.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/0.4/examples/valid_strict/multiscales_example.json b/0.4/examples/valid_strict/multiscales_example.json index f661fbb3..c03044d1 100644 --- a/0.4/examples/valid_strict/multiscales_example.json +++ b/0.4/examples/valid_strict/multiscales_example.json @@ -14,7 +14,7 @@ { "path": "0", "coordinateTransformations": [{ - "description": "the voxel size for the first scale level (0.5 micrometer)", + // the voxel size for the first scale level (0.5 micrometer) "type": "scale", "scale": [1.0, 1.0, 0.5, 0.5, 0.5] }] @@ -22,7 +22,7 @@ { "path": "1", "coordinateTransformations": [{ - "description": "the voxel size for the second scale level (downscaled by a factor of 2 -> 1 micrometer)", + // the voxel size for the second scale level (downscaled by a factor of 2 -> 1 micrometer) "type": "scale", "scale": [1.0, 1.0, 1.0, 1.0, 1.0] }] @@ -30,14 +30,14 @@ { "path": "2", "coordinateTransformations": [{ - "description": "the voxel size for the third scale level (downscaled by a factor of 4 -> 2 micrometer)", + // the voxel size for the third scale level (downscaled by a factor of 4 -> 2 micrometer) "type": "scale", "scale": [1.0, 1.0, 2.0, 2.0, 2.0] }] } ], "coordinateTransformations": [{ - "description": "the time unit (0.1 milliseconds), which is the same for each scale level", + // the time unit (0.1 milliseconds), which is the same for each scale level "type": "scale", "scale": [0.1, 1.0, 1.0, 1.0, 1.0] }], From ae8839c35bd2fc4e35d6be4ea77b80b12ec8db78 Mon Sep 17 00:00:00 2001 From: Sebastien Besson Date: Wed, 16 Mar 2022 21:23:15 +0000 Subject: [PATCH 6/9] Update tests to strip out comments --- 0.4/tests/test_validation.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/0.4/tests/test_validation.py b/0.4/tests/test_validation.py index 83683ac4..3a6a5761 100644 --- a/0.4/tests/test_validation.py +++ b/0.4/tests/test_validation.py @@ -35,9 +35,10 @@ def ids(files): "testfile", valid_strict_files, ids=ids(valid_strict_files)) def test_valid_strict(testfile): with open(testfile) as f: - json_file = json.load(f) - validator.validate(json_file) - strict_validator.validate(json_file) + data = ''.join(line for line in f if not line.lstrip().startswith('//')) + jsondata = json.loads(data) + validator.validate(jsondata) + strict_validator.validate(jsondata) @pytest.mark.parametrize("testfile", valid_files, ids=ids(valid_files)) From a7038b6fc518b2f23c6c1ad08c47a27268caa999 Mon Sep 17 00:00:00 2001 From: Sebastien Besson Date: Wed, 16 Mar 2022 22:16:09 +0000 Subject: [PATCH 7/9] Add document conventions --- 0.4/index.bs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/0.4/index.bs b/0.4/index.bs index 3f25f9df..bae45706 100644 --- a/0.4/index.bs +++ b/0.4/index.bs @@ -92,6 +92,16 @@ of bioimaging data, whether during acquisition or sharing in the cloud. Note: The following text makes use of OME-Zarr [[ome-zarr-py]], the current prototype implementation, for all examples. +Document conventions +-------------------- + +The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, +“RECOMMENDED”, “MAY”, and “OPTIONAL” are to be interpreted as described in +[RFC 2119](https://tools.ietf.org/html/rfc2119). + +Some of the JSON examples in this document include commments. However, this only for +clarity purposes and comments SHOULD NOT be included in JSON objects. + On-disk (or in-cloud) layout {#on-disk} ======================================= From 551aab770bee91681ba8c90f7afc4da5b0920504 Mon Sep 17 00:00:00 2001 From: Sebastien Besson Date: Thu, 17 Mar 2022 15:41:19 +0000 Subject: [PATCH 8/9] Do not allow comments in JSON objects --- 0.4/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/0.4/index.bs b/0.4/index.bs index bae45706..260f5a04 100644 --- a/0.4/index.bs +++ b/0.4/index.bs @@ -100,7 +100,7 @@ The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL [RFC 2119](https://tools.ietf.org/html/rfc2119). Some of the JSON examples in this document include commments. However, this only for -clarity purposes and comments SHOULD NOT be included in JSON objects. +clarity purposes and comments MUST NOT be included in JSON objects. On-disk (or in-cloud) layout {#on-disk} ======================================= From 51ccdd9471e8059fc6e1949734f98f42ce513dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Besson?= Date: Thu, 17 Mar 2022 16:08:41 +0000 Subject: [PATCH 9/9] Update 0.4/index.bs Co-authored-by: Josh Moore --- 0.4/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/0.4/index.bs b/0.4/index.bs index 260f5a04..e531ff07 100644 --- a/0.4/index.bs +++ b/0.4/index.bs @@ -99,7 +99,7 @@ The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL “RECOMMENDED”, “MAY”, and “OPTIONAL” are to be interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119). -Some of the JSON examples in this document include commments. However, this only for +Some of the JSON examples in this document include commments. However, these are only for clarity purposes and comments MUST NOT be included in JSON objects. On-disk (or in-cloud) layout {#on-disk}