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()
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.5/x64/lib/python3.13/site-packages/anndata/_core/aligned_df.py:68: ImplicitModificationWarning: Transforming to str index. warnings.warn("Transforming to str index.", ImplicitModificationWarning)
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
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']