-
Notifications
You must be signed in to change notification settings - Fork 1
Read remote Zarr v2 stores via .zmetadata (0.1.1) #29
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b4c2918
Add tiny consolidated Zarr v3 demo store for remote read example
d33bs e237576
Read remote Zarr v2 stores via consolidated .zmetadata
d33bs 4e84767
Bump version to 0.1.1
d33bs 5035788
Add real-data HTTP tests and point docs at real examples
d33bs d52b459
Test OME-Zarr over HTTP; consolidate the OME fixture
d33bs e16b803
Read OME-Zarr by array_path without consolidated metadata
d33bs 988fa96
Make dims= a LIST(VARCHAR) instead of a string
d33bs fa48b60
Expose array_path selection as a `value` column
d33bs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| [package] | ||
| name = "zarr" | ||
| version = "0.1.0" | ||
| version = "0.1.1" | ||
| edition = "2021" | ||
|
|
||
| [lib] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,58 @@ | ||
| # Querying OME-Zarr | ||
|
|
||
| OME-Zarr images commonly contain several resolution levels and nested label | ||
| arrays. Start by listing the available arrays: | ||
| arrays. The examples below run against this repo's small synthetic fixture | ||
| (`make generate_fixtures` first). Start by listing the available arrays: | ||
|
|
||
| ```sql | ||
| SELECT name, dims, shape, dtype | ||
| FROM read_zarr_metadata('image.ome.zarr'); | ||
| FROM read_zarr_metadata('test/fixtures/bioimage/ome_zarr/synthetic_multichannel.ome.zarr'); | ||
| ``` | ||
|
|
||
| The `array_path` argument is optional. Use it when a store has multiple | ||
| resolution levels, nested labels, or otherwise ambiguous array groups. The path | ||
| is the same store-relative path reported by `read_zarr_metadata`. | ||
|
|
||
| Then select a resolution level and aggregate a region by channel: | ||
| Then select a resolution level and aggregate by channel: | ||
|
|
||
| ```sql | ||
| SELECT c, AVG("0") AS mean_intensity | ||
| FROM read_zarr('image.ome.zarr', array_path='0') | ||
| WHERE y BETWEEN 100 AND 199 | ||
| AND x BETWEEN 200 AND 299 | ||
| SELECT c, AVG(value) AS mean_intensity | ||
| FROM read_zarr('test/fixtures/bioimage/ome_zarr/synthetic_multichannel.ome.zarr', array_path='0') | ||
| GROUP BY c; | ||
| ``` | ||
|
|
||
| Here, `0` is the conventional path for the highest-resolution level. Xarray | ||
| dimension names such as `c`, `y`, and `x` become SQL columns. Numeric and nested | ||
| array names must be double-quoted when referenced as columns. | ||
| Here, `0` is the conventional path for the highest-resolution level. When you | ||
| select a single array with `array_path`, its data is exposed as a `value` column | ||
| and its xarray dimension names (`c`, `y`, `x`) become the other columns — add a | ||
| `WHERE y BETWEEN ... AND x BETWEEN ...` clause to aggregate a sub-region. | ||
|
|
||
| Nested label arrays use the same selector: | ||
|
|
||
| ```sql | ||
| SELECT "labels/nuclei/0" AS label, COUNT(*) AS pixels | ||
| FROM read_zarr('image.ome.zarr', array_path='labels/nuclei/0') | ||
| WHERE "labels/nuclei/0" > 0 | ||
| SELECT value AS label, COUNT(*) AS pixels | ||
| FROM read_zarr('test/fixtures/bioimage/ome_zarr/synthetic_multichannel.ome.zarr', array_path='labels/nuclei/0') | ||
| WHERE value > 0 | ||
| GROUP BY label; | ||
| ``` | ||
|
|
||
| ## Remote OME-Zarr | ||
|
|
||
| Public OME-Zarr images can be read straight from a URL. Bioimage stores usually | ||
| lack consolidated metadata, so whole-store operations (`read_zarr_metadata`, or | ||
| `read_zarr` without `array_path`) aren't available remotely — but a specific | ||
| resolution level reads by `array_path`, with `c`/`z`/`y`/`x` recovered from the | ||
| OME `multiscales.axes`: | ||
|
|
||
| ```sql | ||
| -- A public image from the Image Data Resource (IDR) | ||
| SELECT c, z, y, x, value AS intensity | ||
| FROM read_zarr( | ||
| 'https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr', | ||
| array_path='0' | ||
| ) | ||
| LIMIT 10; | ||
| ``` | ||
|
|
||
| Filters and aggregates over a full pyramid level scan every chunk (there is no | ||
| sub-chunk filter pushdown yet), so keep remote exploratory queries bounded with | ||
| `LIMIT` or use a coarse resolution level. |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| { | ||
| "shape": [ | ||
| 4 | ||
| ], | ||
| "data_type": "float64", | ||
| "chunk_grid": { | ||
| "name": "regular", | ||
| "configuration": { | ||
| "chunk_shape": [ | ||
| 4 | ||
| ] | ||
| } | ||
| }, | ||
| "chunk_key_encoding": { | ||
| "name": "default", | ||
| "configuration": { | ||
| "separator": "/" | ||
| } | ||
| }, | ||
| "fill_value": "NaN", | ||
| "codecs": [ | ||
| { | ||
| "name": "bytes", | ||
| "configuration": { | ||
| "endian": "little" | ||
| } | ||
| }, | ||
| { | ||
| "name": "zstd", | ||
| "configuration": { | ||
| "level": 0, | ||
| "checksum": false | ||
| } | ||
| } | ||
| ], | ||
| "attributes": { | ||
| "_FillValue": "AAAAAAAA+H8=" | ||
| }, | ||
| "dimension_names": [ | ||
| "lat" | ||
| ], | ||
| "zarr_format": 3, | ||
| "node_type": "array", | ||
| "storage_transformers": [] | ||
| } |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| { | ||
| "shape": [ | ||
| 5 | ||
| ], | ||
| "data_type": "float64", | ||
| "chunk_grid": { | ||
| "name": "regular", | ||
| "configuration": { | ||
| "chunk_shape": [ | ||
| 5 | ||
| ] | ||
| } | ||
| }, | ||
| "chunk_key_encoding": { | ||
| "name": "default", | ||
| "configuration": { | ||
| "separator": "/" | ||
| } | ||
| }, | ||
| "fill_value": "NaN", | ||
| "codecs": [ | ||
| { | ||
| "name": "bytes", | ||
| "configuration": { | ||
| "endian": "little" | ||
| } | ||
| }, | ||
| { | ||
| "name": "zstd", | ||
| "configuration": { | ||
| "level": 0, | ||
| "checksum": false | ||
| } | ||
| } | ||
| ], | ||
| "attributes": { | ||
| "_FillValue": "AAAAAAAA+H8=" | ||
| }, | ||
| "dimension_names": [ | ||
| "lon" | ||
| ], | ||
| "zarr_format": 3, | ||
| "node_type": "array", | ||
| "storage_transformers": [] | ||
| } |
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.