In [1]:
Copied!
from pathlib import Path
from ngio import open_ome_zarr_plate
from ngio.utils import download_ome_zarr_dataset
# Download the dataset
download_dir = Path(".").absolute().parent.parent / "data"
hcs_path = download_ome_zarr_dataset("CardiomyocyteTinyMip", download_dir=download_dir)
hcs_zarr = open_ome_zarr_plate(hcs_path)
print(hcs_zarr)
print(f"Rows: {hcs_zarr.rows}, Columns: {hcs_zarr.columns}")
# Get all the images in the plate
hcs_zarr.get_images()
from pathlib import Path
from ngio import open_ome_zarr_plate
from ngio.utils import download_ome_zarr_dataset
# Download the dataset
download_dir = Path(".").absolute().parent.parent / "data"
hcs_path = download_ome_zarr_dataset("CardiomyocyteTinyMip", download_dir=download_dir)
hcs_zarr = open_ome_zarr_plate(hcs_path)
print(hcs_zarr)
print(f"Rows: {hcs_zarr.rows}, Columns: {hcs_zarr.columns}")
# Get all the images in the plate
hcs_zarr.get_images()
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html from .autonotebook import tqdm as notebook_tqdm
Unzipping contents of '/home/runner/work/ngio/ngio/data/20200812-CardiomyocyteDifferentiation14-Cycle1-tiny-mip.zarr.zip' to '/home/runner/work/ngio/ngio/data/tmp'
Plate([rows x columns] (1 x 1)) Rows: ['B'], Columns: ['03']
Out[1]:
{'B/03/0': OmeZarrContainer(levels=5, labels=['nuclei'], #tables=4)}
Aggregate tables across all images¶
In [2]:
Copied!
# Aggregate all table across all images
table = hcs_zarr.concatenate_image_tables(name="nuclei")
table.dataframe
# Aggregate all table across all images
table = hcs_zarr.concatenate_image_tables(name="nuclei")
table.dataframe
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/functools.py:934: ImplicitModificationWarning: Transforming to str index. return dispatch(args[0].__class__)(*args, **kw)
Out[2]:
| area | bbox_area | equivalent_diameter | max_intensity | mean_intensity | min_intensity | standard_deviation_intensity | row | column | path_in_well | |
|---|---|---|---|---|---|---|---|---|---|---|
| label | ||||||||||
| 1 | 1360.0 | 1664.0 | 13.746119 | 268.0 | 184.579407 | 125.0 | 24.502481 | B | 03 | 0 |
| 2 | 2464.0 | 2992.0 | 16.757685 | 461.0 | 273.246765 | 132.0 | 51.794971 | B | 03 | 0 |
| 3 | 1968.0 | 2688.0 | 15.548035 | 429.0 | 277.291656 | 143.0 | 41.822422 | B | 03 | 0 |
| 4 | 5120.0 | 6400.0 | 21.384073 | 413.0 | 279.035156 | 118.0 | 44.379074 | B | 03 | 0 |
| 5 | 288.0 | 352.0 | 8.193409 | 341.0 | 243.315979 | 147.0 | 41.861721 | B | 03 | 0 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 1493 | 1248.0 | 1440.0 | 13.357914 | 385.0 | 269.291656 | 108.0 | 45.967396 | B | 03 | 0 |
| 1494 | 528.0 | 704.0 | 10.027941 | 475.0 | 315.710236 | 128.0 | 70.174896 | B | 03 | 0 |
| 1495 | 608.0 | 768.0 | 10.510781 | 377.0 | 281.544403 | 122.0 | 34.698723 | B | 03 | 0 |
| 1496 | 288.0 | 480.0 | 8.193409 | 356.0 | 261.003479 | 122.0 | 44.835232 | B | 03 | 0 |
| 1497 | 432.0 | 528.0 | 9.379111 | 454.0 | 336.101837 | 172.0 | 53.799728 | B | 03 | 0 |
1497 rows × 10 columns
Save the table in the HCS plate¶
In [3]:
Copied!
# Save the tabvle in the HCS plate
hcs_zarr.add_table(name="nuclei", table=table)
# Read the table back for sanity check
hcs_zarr.get_table("nuclei").dataframe
# Save the tabvle in the HCS plate
hcs_zarr.add_table(name="nuclei", table=table)
# Read the table back for sanity check
hcs_zarr.get_table("nuclei").dataframe
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/site-packages/anndata/_io/zarr.py:44: UserWarning: Writing zarr v2 data will no longer be the default in the next minor release. v3 data will be written by default. If you are explicitly setting this configuration, consider migrating to the zarr v3 file format. f = open_write_group(store)
Out[3]:
| area | bbox_area | equivalent_diameter | max_intensity | mean_intensity | min_intensity | standard_deviation_intensity | row | column | path_in_well | |
|---|---|---|---|---|---|---|---|---|---|---|
| label | ||||||||||
| 1 | 1360.0 | 1664.0 | 13.746119 | 268.0 | 184.579407 | 125.0 | 24.502481 | B | 03 | 0 |
| 2 | 2464.0 | 2992.0 | 16.757685 | 461.0 | 273.246765 | 132.0 | 51.794971 | B | 03 | 0 |
| 3 | 1968.0 | 2688.0 | 15.548035 | 429.0 | 277.291656 | 143.0 | 41.822422 | B | 03 | 0 |
| 4 | 5120.0 | 6400.0 | 21.384073 | 413.0 | 279.035156 | 118.0 | 44.379074 | B | 03 | 0 |
| 5 | 288.0 | 352.0 | 8.193409 | 341.0 | 243.315979 | 147.0 | 41.861721 | B | 03 | 0 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 1493 | 1248.0 | 1440.0 | 13.357914 | 385.0 | 269.291656 | 108.0 | 45.967396 | B | 03 | 0 |
| 1494 | 528.0 | 704.0 | 10.027941 | 475.0 | 315.710236 | 128.0 | 70.174896 | B | 03 | 0 |
| 1495 | 608.0 | 768.0 | 10.510781 | 377.0 | 281.544403 | 122.0 | 34.698723 | B | 03 | 0 |
| 1496 | 288.0 | 480.0 | 8.193409 | 356.0 | 261.003479 | 122.0 | 44.835232 | B | 03 | 0 |
| 1497 | 432.0 | 528.0 | 9.379111 | 454.0 | 336.101837 | 172.0 | 53.799728 | B | 03 | 0 |
1497 rows × 10 columns
Create a new empty Plate¶
In [4]:
Copied!
from ngio import ImageInWellPath, create_empty_plate
test_plate = create_empty_plate(
store="./data/empty_plate.zarr",
name="Test Plate",
images=[
ImageInWellPath(row="A", column="01", path="0"),
ImageInWellPath(row="A", column="02", path="0"),
ImageInWellPath(row="A", column="02", path="1", acquisition_id=1),
],
overwrite=True,
)
print(test_plate)
print(f"Rows: {test_plate.rows}, Columns: {test_plate.columns}")
from ngio import ImageInWellPath, create_empty_plate
test_plate = create_empty_plate(
store="./data/empty_plate.zarr",
name="Test Plate",
images=[
ImageInWellPath(row="A", column="01", path="0"),
ImageInWellPath(row="A", column="02", path="0"),
ImageInWellPath(row="A", column="02", path="1", acquisition_id=1),
],
overwrite=True,
)
print(test_plate)
print(f"Rows: {test_plate.rows}, Columns: {test_plate.columns}")
Plate([rows x columns] (1 x 2)) Rows: ['A'], Columns: ['01', '02']
In [ ]:
Copied!