-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functionality for specifying channel names when saving to spatial…
…data Zarr (#151) * Add ability to specify image channel names. If provided, the channel names are saved as metadata in the Zarr. When reading the resulting Zarr file with spatialdata, the channel names will be read too and accessible in the corresponding spatialdata object via the "c" field of "coords". Channel names are also passed correctly to different image processing functions. --------- Co-authored-by: ArneDefauw <[email protected]>
- Loading branch information
1 parent
bbda4d0
commit b33e9b0
Showing
17 changed files
with
258 additions
and
78 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
src/napari_sparrow/_tests/test_data/multi_channel_zarr/sdata.zarr/images/combine/.zattrs
This file contains 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,95 @@ | ||
{ | ||
"channels_metadata": { | ||
"channels": [ | ||
{ | ||
"label": 0 | ||
}, | ||
{ | ||
"label": 1 | ||
} | ||
] | ||
}, | ||
"multiscales": [ | ||
{ | ||
"axes": [ | ||
{ | ||
"name": "c", | ||
"type": "channel" | ||
}, | ||
{ | ||
"name": "y", | ||
"type": "space" | ||
}, | ||
{ | ||
"name": "x", | ||
"type": "space" | ||
} | ||
], | ||
"coordinateTransformations": [ | ||
{ | ||
"input": { | ||
"axes": [ | ||
{ | ||
"name": "c", | ||
"type": "channel" | ||
}, | ||
{ | ||
"name": "y", | ||
"type": "space", | ||
"unit": "unit" | ||
}, | ||
{ | ||
"name": "x", | ||
"type": "space", | ||
"unit": "unit" | ||
} | ||
], | ||
"name": "cyx" | ||
}, | ||
"output": { | ||
"axes": [ | ||
{ | ||
"name": "c", | ||
"type": "channel" | ||
}, | ||
{ | ||
"name": "y", | ||
"type": "space", | ||
"unit": "unit" | ||
}, | ||
{ | ||
"name": "x", | ||
"type": "space", | ||
"unit": "unit" | ||
} | ||
], | ||
"name": "global" | ||
}, | ||
"translation": [ | ||
0.0, | ||
0.0, | ||
0.0 | ||
], | ||
"type": "translation" | ||
} | ||
], | ||
"datasets": [ | ||
{ | ||
"coordinateTransformations": [ | ||
{ | ||
"scale": [ | ||
1.0, | ||
1.0, | ||
1.0 | ||
], | ||
"type": "scale" | ||
} | ||
], | ||
"path": "0" | ||
} | ||
], | ||
"name": "/images/combine", | ||
"version": "0.4" | ||
} | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
src/napari_sparrow/_tests/test_data/multi_channel_zarr/sdata.zarr/images/combine/.zgroup
This file contains 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,3 @@ | ||
{ | ||
"zarr_format": 2 | ||
} |
25 changes: 25 additions & 0 deletions
25
src/napari_sparrow/_tests/test_data/multi_channel_zarr/sdata.zarr/images/combine/0/.zarray
This file contains 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,25 @@ | ||
{ | ||
"chunks": [ | ||
1, | ||
512, | ||
512 | ||
], | ||
"compressor": { | ||
"blocksize": 0, | ||
"clevel": 5, | ||
"cname": "lz4", | ||
"id": "blosc", | ||
"shuffle": 1 | ||
}, | ||
"dimension_separator": "/", | ||
"dtype": "<f4", | ||
"fill_value": 0.0, | ||
"filters": null, | ||
"order": "C", | ||
"shape": [ | ||
2, | ||
512, | ||
512 | ||
], | ||
"zarr_format": 2 | ||
} |
Binary file added
BIN
+877 KB
src/napari_sparrow/_tests/test_data/multi_channel_zarr/sdata.zarr/images/combine/0/0/0/0
Binary file not shown.
Binary file added
BIN
+882 KB
src/napari_sparrow/_tests/test_data/multi_channel_zarr/sdata.zarr/images/combine/0/1/0/0
Binary file not shown.
This file contains 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,16 @@ | ||
from spatialdata import SpatialData | ||
|
||
from napari_sparrow.image._combine import combine | ||
|
||
def test_combine( sdata_multi_c ): | ||
|
||
sdata_multi_c=combine( sdata_multi_c, | ||
img_layer="raw_image", | ||
output_layer="combine", | ||
nuc_channels=[ 15, 14 ], | ||
mem_channels=[ 0,6,11 ], | ||
overwrite=True | ||
) | ||
|
||
assert "combine" in sdata_multi_c.images | ||
assert isinstance(sdata_multi_c, SpatialData) |
This file contains 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 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 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 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
Oops, something went wrong.