Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bioformats2raw.layout #112

Merged
merged 32 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d7c0556
First draft of bioformats2raw.layout
joshmoore Apr 7, 2022
8ee02d1
Add layout example
joshmoore Apr 8, 2022
ee15455
Improve wording of "SHOULD parse multiple images", thanks to Ilan
joshmoore Apr 20, 2022
c8e98e4
Clarify contents of METADATA.ome.xml, thanks to Melissa
joshmoore Apr 20, 2022
6403d88
Add schema & test for bf2raw metadata
joshmoore Apr 21, 2022
890e8a2
Add missing schema file
joshmoore Apr 21, 2022
b099281
Merge 'origin/main' into bf2raw
joshmoore May 3, 2022
2b67a36
Add applicable versions statement
joshmoore May 11, 2022
31d34c3
Update text with suggestions
joshmoore May 30, 2022
3173303
Merge 'origin/main' into bf2raw
joshmoore May 30, 2022
d44a066
Add bf2raw examples config
joshmoore May 30, 2022
7574d22
Add test to find missing configs
joshmoore May 30, 2022
ff5d7ec
Split subitems to pass linting
joshmoore May 30, 2022
e2119e5
Add graphical layout representation
joshmoore May 30, 2022
4fcc045
Fix missing whitespace
joshmoore May 30, 2022
57acc23
Add "series" attribute in "OME" group under bioformats2raw.layout
melissalinkert Jul 5, 2022
5eca169
Update the MUST/SHOULD semantics
joshmoore Jul 18, 2022
cf4e04c
Fix doubly indented bullets
joshmoore Sep 14, 2022
89c322d
Make minimum spec a link
joshmoore Sep 14, 2022
3691437
Add no-toc sections
joshmoore Sep 14, 2022
499caee
Re-arrange and add more text
joshmoore Sep 14, 2022
c7582e5
Make changes based on feedback from Will
joshmoore Sep 15, 2022
399b70b
Add bf2raw plate example
joshmoore Sep 15, 2022
740a11b
Add schema for ome series
joshmoore Sep 15, 2022
1f91482
Apply suggestions from code review
joshmoore Sep 19, 2022
861227b
Apply to v0.4 only
joshmoore Sep 22, 2022
8e612ef
Re-iterate plate precedence without OME/METADATA.ome.xml
joshmoore Sep 22, 2022
a0919be
Backport latest/bf2raw to 0.4
joshmoore Sep 22, 2022
5971927
Re-word the 'series' section
joshmoore Sep 22, 2022
88fd042
Make plate/series link a "SHOULD"
joshmoore Sep 22, 2022
7b7c43f
Add 'transitional' to 'omero' spec
joshmoore Sep 26, 2022
106c301
Add 0.4.1 changelog
joshmoore Sep 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions latest/examples/bf2raw/bioformats2raw_layout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"bioformats2raw.layout" : 3
}
36 changes: 35 additions & 1 deletion latest/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ 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).

<p>
<dfn>Transitional</dfn> metadata is added to the specification with the
joshmoore marked this conversation as resolved.
Show resolved Hide resolved
intention of removing it in the future. Implementations may be expected (MUST) or
encouraged (SHOULD) support the reading of the data, but writing will usually
joshmoore marked this conversation as resolved.
Show resolved Hide resolved
be optional (MAY). Examples of transitional metadata include custom additions by
implementations that are later submitted as a formal specification. (See [[#bf2raw]])
</p>

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.

Expand Down Expand Up @@ -242,9 +250,35 @@ keys as specified below for discovering certain types of data, especially images

If part of [[#multiscale-md]], the length of "axes" MUST be equal to the number of dimensions of the arrays that contain the image data.

"bioformats2raw.layout" (transitional) {#bf2raw}
------------------------------------------------

[=Transitional=] "bioformats2raw.layout" metadata identifies a group which implicitly describes a series of images.
The need for the collection stems from the common "multi-image file" scenario in microscopy. Parsers like Bio-Formats
define a strict, stable ordering of the images in a single container that can be used to refer to them by other tools.
In order to capture that information within an OME-NGFF dataset, `bioformats2raw` internally introduced a wrapping
layer. An upcoming NGFF specification will replace this layout with explicit metadata.

Conforming groups MUST have the value "3" for the "bioformats2raw.layout" key in their `.zattrs` metadata at the top of the hierarchy:

<pre class=include-code>
path: examples/bf2raw/bioformats2raw_layout.json
highlight: json
</pre>

Additionally:
joshmoore marked this conversation as resolved.
Show resolved Hide resolved
- MUST store separate "multiscales" images in consecutively numbered groups starting from 0 (i.e. "0/", "1/", "2/", "3/", ...);
sbesson marked this conversation as resolved.
Show resolved Hide resolved
- MAY have OME metadata representing the entire collection of images in a file named "OME/METADATA.ome.xml";
joshmoore marked this conversation as resolved.
Show resolved Hide resolved
- if so, MUST represent every "multiscales" group as exactly one OME-XML "Image" in the same order as the group numbers.

Conforming readers:
- SHOULD detect the presence of more than one image and make users aware of the fact;
- MAY choose to show all images within the collection or offer the user a choice of images, as with <dfn export="true"><abbr title="High-content screening">HCS</abbr></dfn> plates;
- MAY ignore other groups or arrays under the root of the hierarchy.


"coordinateTransformations" metadata {#trafo-md}
-------------------------------------
------------------------------------------------

"coordinateTransformations" describe a series of transformations that map between two coordinate spaces (defined by "axes").
For example, to map a discrete data space of an array to the corresponding physical space.
Expand Down
14 changes: 14 additions & 0 deletions latest/schemas/bf2raw.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://ngff.openmicroscopy.org/latest/schemas/bf2raw.schema",
"title": "NGFF container produced by bioformats2raw",
"description": "JSON from OME-NGFF .zattrs",
"type": "object",
"properties": {
"bioformats2raw.layout": {
"description": "The top-level identifier metadata added by bioformats2raw",
"type": "number",
"enum": [3]
}
}
}
15 changes: 15 additions & 0 deletions latest/tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@
from jsonschema.exceptions import ValidationError


with open('schemas/bf2raw.schema') as f:
bf2raw_schema = json.load(f)
with open('schemas/image.schema') as f:
image_schema = json.load(f)
with open('schemas/strict_image.schema') as f:
strict_image_schema = json.load(f)

schema_store = {
bf2raw_schema['$id']: bf2raw_schema,
image_schema['$id']: image_schema,
strict_image_schema['$id']: strict_image_schema,
}

resolver = RefResolver.from_schema(image_schema, store=schema_store)
validator = Draft202012Validator(image_schema, resolver=resolver)
strict_validator = Draft202012Validator(strict_image_schema, resolver=resolver)
bf2raw_validator = Draft202012Validator(bf2raw_schema, resolver=resolver)

bf2raw_files = list(glob.glob("examples/bf2raw/*.json"))
joshmoore marked this conversation as resolved.
Show resolved Hide resolved
valid_strict_files = list(glob.glob("examples/valid_strict/*.json"))
valid_files = list(glob.glob("examples/valid/*.json"))
invalid_files = list(glob.glob("examples/invalid/*.json"))
Expand All @@ -31,6 +37,15 @@ def ids(files):
return [str(x).split("/")[-1][0:-5] for x in files]


@pytest.mark.parametrize(
"testfile", bf2raw_files, ids=ids(bf2raw_files))
def test_bf2raw(testfile):
with open(testfile) as f:
data = ''.join(line for line in f if not line.lstrip().startswith('//'))
jsondata = json.loads(data)
bf2raw_validator.validate(jsondata)


@pytest.mark.parametrize(
"testfile", valid_strict_files, ids=ids(valid_strict_files))
def test_valid_strict(testfile):
Expand Down