HCS API reference¶
Open a plate¶
ngio.open_ome_zarr_plate
¶
open_ome_zarr_plate(
store: StoreOrGroup,
cache: bool = False,
mode: AccessModeLiteral = "r+",
) -> OmeZarrPlate
Open an OME-Zarr plate.
Parameters:
-
store(StoreOrGroup) –The Zarr store or group that stores the plate.
-
cache(bool, default:False) –Whether to use a cache for the zarr group metadata.
-
mode(AccessModeLiteral, default:'r+') –The access mode for the image. Defaults to "r+".
Source code in src/ngio/hcs/_plate.py
OmeZarrPlate¶
ngio.OmeZarrPlate
¶
OmeZarrPlate(
group_handler: ZarrGroupHandler,
table_container: TablesContainer | None = None,
)
A class to handle the Plate Sequence in an OME-Zarr file.
Initialize the LabelGroupHandler.
Parameters:
-
group_handler(ZarrGroupHandler) –The Zarr group handler that contains the Plate.
-
table_container(TablesContainer | None, default:None) –The tables container that contains plate level tables.
Source code in src/ngio/hcs/_plate.py
acquisitions_names
property
¶
Return the acquisitions in the plate.
wells_paths
¶
images_paths_async
async
¶
Return the images paths in the plate asynchronously.
Deprecated: use images_paths(). Well metadata is read from the plate's
own attributes, so there was never any IO here to parallelise.
Parameters:
-
acquisition(int | None, default:None) –The acquisition id to filter the images.
Source code in src/ngio/hcs/_plate.py
images_paths
¶
Return the images paths in the plate.
If acquisition is None, return all images paths in the plate. Else, return the images paths in the plate for the given acquisition.
Parameters:
-
acquisition(int | None, default:None) –The acquisition id to filter the images.
Source code in src/ngio/hcs/_plate.py
well_images_paths
¶
Return the images paths in a well.
If acquisition is None, return all images paths in the well. Else, return the images paths in the well for the given acquisition.
Parameters:
-
row(str) –The row of the well.
-
column(int | str) –The column of the well.
-
acquisition(int | None, default:None) –The acquisition id to filter the images.
Source code in src/ngio/hcs/_plate.py
get_image_acquisition_id
¶
Get the acquisition id of an image in a well.
Parameters:
-
row(str) –The row of the well.
-
column(int | str) –The column of the well.
-
image_path(str) –The path of the image.
Returns:
-
int | None–int | None: The acquisition id of the image.
Source code in src/ngio/hcs/_plate.py
get_well
¶
get_well(row: str, column: int | str) -> OmeZarrWell
Get a well from the plate.
Parameters:
-
row(str) –The row of the well.
-
column(int | str) –The column of the well.
Returns:
-
OmeZarrWell(OmeZarrWell) –The well.
Source code in src/ngio/hcs/_plate.py
get_wells_async
async
¶
get_wells_async(
max_workers: int | None = None,
) -> dict[str, OmeZarrWell]
Get all wells in the plate asynchronously.
Deprecated: use get_wells(max_workers=...).
Parameters:
-
max_workers(int | None, default:None) –How many wells to open at a time.
Noneleaves the fan-out to asyncio's default thread executor.
Returns:
-
dict[str, OmeZarrWell]–A dictionary of wells, keyed by well path.
Source code in src/ngio/hcs/_plate.py
get_wells
¶
get_wells(
max_workers: int | None = None,
) -> dict[str, OmeZarrWell]
Get all wells in the plate.
Parameters:
-
max_workers(int | None, default:None) –How many wells to open concurrently.
None(the default) opens them one at a time in the calling thread.
Returns:
-
dict[str, OmeZarrWell]–A dictionary of wells, keyed by well path.
Source code in src/ngio/hcs/_plate.py
get_images_async
async
¶
get_images_async(
acquisition: int | None = None,
max_workers: int | None = None,
) -> dict[str, OmeZarrContainer]
Get all images in the plate asynchronously.
Deprecated: use get_images(max_workers=...).
Parameters:
-
acquisition(int | None, default:None) –The acquisition id to filter the images.
-
max_workers(int | None, default:None) –How many images to open at a time.
Noneleaves the fan-out to asyncio's default thread executor.
Returns:
-
dict[str, OmeZarrContainer]–A dictionary of images, keyed by image path.
Source code in src/ngio/hcs/_plate.py
get_images
¶
get_images(
acquisition: int | None = None,
max_workers: int | None = None,
) -> dict[str, OmeZarrContainer]
Get all images in the plate.
Parameters:
-
acquisition(int | None, default:None) –The acquisition id to filter the images.
-
max_workers(int | None, default:None) –How many images to open concurrently.
None(the default) opens them one at a time in the calling thread.
Returns:
-
dict[str, OmeZarrContainer]–A dictionary of images, keyed by image path.
Source code in src/ngio/hcs/_plate.py
get_image
¶
get_image(
row: str, column: int | str, image_path: str
) -> OmeZarrContainer
Get an image from the plate.
Parameters:
-
row(str) –The row of the well.
-
column(int | str) –The column of the well.
-
image_path(str) –The path of the image.
Returns:
-
OmeZarrContainer(OmeZarrContainer) –The image.
Source code in src/ngio/hcs/_plate.py
get_image_store
¶
get_image_store(
row: str, column: int | str, image_path: str
) -> StoreOrGroup
Get the image store from the plate.
Parameters:
-
row(str) –The row of the well.
-
column(int | str) –The column of the well.
-
image_path(str) –The path of the image.
Source code in src/ngio/hcs/_plate.py
get_well_images
¶
get_well_images(
row: str,
column: str | int,
acquisition: int | None = None,
) -> dict[str, OmeZarrContainer]
Get all images in a well.
Parameters:
-
row(str) –The row of the well.
-
column(str | int) –The column of the well.
-
acquisition(int | None, default:None) –The acquisition id to filter the images.
Source code in src/ngio/hcs/_plate.py
atomic_add_image
¶
atomic_add_image(
row: str,
column: int | str,
image_path: str,
acquisition_id: int | None = None,
acquisition_name: str | None = None,
) -> str
Parallel safe version of add_image.
Every worker adding to a plate contends on the same two metadata files,
the plate's for the well list and the well's for the image list. This
serialises both read-modify-writes behind a file lock, so concurrent
workers cannot lose each other's updates. The lock is an OS file lock:
it holds across threads and processes on one machine, and on a shared
network filesystem only if the mount honours flock.
Note
On Windows the lock is best-effort and warns: filelock can hand
the same lock to two workers at once, so a single writer is safe but
concurrent ones can still lose an update. Run those on Linux/macOS.
Raises:
-
NgioValueError–If the store is not local, or if the plate was opened with caching enabled — neither supports the lock.
Source code in src/ngio/hcs/_plate.py
add_image
¶
add_image(
row: str,
column: int | str,
image_path: str,
acquisition_id: int | None = None,
acquisition_name: str | None = None,
) -> str
Add an image to an ome-zarr plate.
Source code in src/ngio/hcs/_plate.py
add_well
¶
add_well(row: str, column: int | str) -> OmeZarrWell
Add a well to an ome-zarr plate.
Source code in src/ngio/hcs/_plate.py
add_column
¶
add_column(column: int | str) -> OmeZarrPlate
Add a column to an ome-zarr plate.
Source code in src/ngio/hcs/_plate.py
add_acquisition
¶
add_acquisition(
acquisition_id: int, acquisition_name: str
) -> OmeZarrPlate
Add an acquisition to an ome-zarr plate.
Be aware that this is not a parallel safe operation.
Parameters:
-
acquisition_id(int) –The acquisition id.
-
acquisition_name(str) –The acquisition name.
Source code in src/ngio/hcs/_plate.py
atomic_remove_image
¶
Parallel safe version of remove_image.
Serialises the read-modify-write of the plate and well metadata behind a
file lock, so concurrent workers cannot lose each other's updates. The
lock is an OS file lock: it holds across threads and processes on one
machine, and on a shared network filesystem only if the mount honours
flock.
Note
On Windows the lock is best-effort and warns: filelock can hand
the same lock to two workers at once, so a single writer is safe but
concurrent ones can still lose an update. Run those on Linux/macOS.
Raises:
-
NgioValueError–If the store is not local, or if the plate was opened with caching enabled — neither supports the lock.
Source code in src/ngio/hcs/_plate.py
remove_image
¶
Remove an image from an ome-zarr plate.
derive_plate
¶
derive_plate(
store: StoreOrGroup,
plate_name: str | None = None,
ngff_version: NgffVersions | None = None,
keep_acquisitions: bool = False,
cache: bool = False,
overwrite: bool = False,
) -> OmeZarrPlate
Derive a new OME-Zarr plate from an existing one.
Parameters:
-
store(StoreOrGroup) –The Zarr store or group that stores the plate.
-
plate_name(str | None, default:None) –The name of the new plate.
-
ngff_version(NgffVersion, default:None) –The NGFF version to use for the new plate.
-
keep_acquisitions(bool, default:False) –Whether to keep the acquisitions in the new plate.
-
cache(bool, default:False) –Whether to use a cache for the zarr group metadata.
-
overwrite(bool, default:False) –Whether to overwrite the existing plate.
Source code in src/ngio/hcs/_plate.py
list_tables
¶
list_tables(
filter_types: TypedTable | str | None = None,
) -> list[str]
List all tables in the plate.
Source code in src/ngio/hcs/_plate.py
list_roi_tables
¶
List all ROI tables in the plate.
Returns [] when the plate has no tables, matching list_tables.
Source code in src/ngio/hcs/_plate.py
get_roi_table
¶
get_roi_table(name: str) -> RoiTable
Get a ROI table from the image.
Parameters:
-
name(str) –The name of the table.
Source code in src/ngio/hcs/_plate.py
get_masking_roi_table
¶
get_masking_roi_table(name: str) -> MaskingRoiTable
Get a masking ROI table from the image.
Parameters:
-
name(str) –The name of the table.
Source code in src/ngio/hcs/_plate.py
get_feature_table
¶
get_feature_table(name: str) -> FeatureTable
Get a feature table from the image.
Parameters:
-
name(str) –The name of the table.
Source code in src/ngio/hcs/_plate.py
get_generic_roi_table
¶
get_generic_roi_table(name: str) -> GenericRoiTable
Get a generic ROI table from the image.
Parameters:
-
name(str) –The name of the table.
Source code in src/ngio/hcs/_plate.py
get_condition_table
¶
get_condition_table(name: str) -> ConditionTable
Get a condition table from the image.
Parameters:
-
name(str) –The name of the table.
Source code in src/ngio/hcs/_plate.py
get_table
¶
get_table(name: str) -> Table
Get a table from the image.
Parameters:
-
name(str) –The name of the table.
get_table_as
¶
get_table_as(
name: str,
table_cls: type[TableType],
backend: TableBackend | None = None,
) -> TableType
Get a table from the image as a specific type.
Parameters:
-
name(str) –The name of the table.
-
table_cls(type[TableType]) –The type of the table.
-
backend(TableBackend | None, default:None) –The backend to use. If None, the default backend is used.
Source code in src/ngio/hcs/_plate.py
add_table
¶
add_table(
name: str,
table: Table,
backend: TableBackend | None = None,
overwrite: bool = False,
) -> None
Add a table to the plate.
If backend is None (default), the table's own backend is preserved.
Source code in src/ngio/hcs/_plate.py
delete_table
¶
Delete a table from the group.
Parameters:
-
name(str) –The name of the table to delete.
-
missing_ok(bool, default:False) –If True, do not raise an error if the table does not exist.
Source code in src/ngio/hcs/_plate.py
list_image_tables
¶
list_image_tables(
acquisition: int | None = None,
filter_types: str | None = None,
mode: Literal["common", "all"] = "common",
max_workers: int | None = None,
) -> list[str]
List all image tables in the plate.
Parameters:
-
acquisition(int | None, default:None) –The acquisition id to filter the images.
-
filter_types(str | None, default:None) –The type of tables to filter. If None, return all tables.
-
mode(Literal['common', 'all'], default:'common') –Whether to return only tables common to every image (
"common") or the union across them ("all"). -
max_workers(int | None, default:None) –How many images to read concurrently.
None(the default) reads them one at a time in the calling thread.
Source code in src/ngio/hcs/_plate.py
list_image_tables_async
async
¶
list_image_tables_async(
acquisition: int | None = None,
filter_types: str | None = None,
mode: Literal["common", "all"] = "common",
max_workers: int | None = None,
) -> list[str]
List all image tables in the plate asynchronously.
Deprecated: use list_image_tables(max_workers=...).
Parameters:
-
acquisition(int | None, default:None) –The acquisition id to filter the images.
-
filter_types(str | None, default:None) –The type of tables to filter. If None, return all tables.
-
mode(Literal['common', 'all'], default:'common') –Whether to return only tables common to every image (
"common") or the union across them ("all"). -
max_workers(int | None, default:None) –How many images to read at a time.
Noneleaves the fan-out to asyncio's default thread executor.
Source code in src/ngio/hcs/_plate.py
concatenate_image_tables
¶
concatenate_image_tables(
name: str,
acquisition: int | None = None,
strict: bool = True,
index_key: str | None = None,
mode: Literal["eager", "lazy"] = "eager",
max_workers: int | None = None,
) -> Table
Concatenate tables from all images in the plate.
Parameters:
-
name(str) –The name of the table to concatenate.
-
index_key(str | None, default:None) –The key to use for the index of the concatenated table.
-
acquisition(int | None, default:None) –The acquisition id to filter the images.
-
strict(bool, default:True) –If True, raise an error if the table is not found in the image.
-
index_key(str | None, default:None) –If a string is provided, a new index column will be created new_index_pattern = {row}{column}}_{label
-
mode(Literal['eager', 'lazy'], default:'eager') –The mode to use for concatenation. Can be 'eager' or 'lazy'. if 'eager', the table will be loaded into memory. if 'lazy', the table will be loaded as a lazy frame.
-
max_workers(int | None, default:None) –How many images to read concurrently.
None(the default) reads them one at a time in the calling thread.
Source code in src/ngio/hcs/_plate.py
concatenate_image_tables_as
¶
concatenate_image_tables_as(
name: str,
table_cls: type[TableType],
acquisition: int | None = None,
index_key: str | None = None,
strict: bool = True,
mode: Literal["eager", "lazy"] = "eager",
max_workers: int | None = None,
) -> TableType
Concatenate tables from all images in the plate as a specific type.
Parameters:
-
name(str) –The name of the table to concatenate.
-
table_cls(type[TableType]) –The type of the table to concatenate.
-
index_key(str | None, default:None) –The key to use for the index of the concatenated table.
-
acquisition(int | None, default:None) –The acquisition id to filter the images.
-
index_key(str | None, default:None) –If a string is provided, a new index column will be created new_index_pattern = {row}{column}}_{label
-
strict(bool, default:True) –If True, raise an error if the table is not found in the image.
-
mode(Literal['eager', 'lazy'], default:'eager') –The mode to use for concatenation. Can be 'eager' or 'lazy'. if 'eager', the table will be loaded into memory. if 'lazy', the table will be loaded as a lazy frame.
-
max_workers(int | None, default:None) –How many images to read concurrently.
None(the default) reads them one at a time in the calling thread.
Source code in src/ngio/hcs/_plate.py
concatenate_image_tables_async
async
¶
concatenate_image_tables_async(
name: str,
acquisition: int | None = None,
index_key: str | None = None,
strict: bool = True,
mode: Literal["eager", "lazy"] = "eager",
max_workers: int | None = None,
) -> Table
Concatenate tables from all images in the plate asynchronously.
Deprecated: use concatenate_image_tables(max_workers=...).
Parameters:
-
name(str) –The name of the table to concatenate.
-
index_key(str | None, default:None) –The key to use for the index of the concatenated table.
-
acquisition(int | None, default:None) –The acquisition id to filter the images.
-
index_key(str | None, default:None) –If a string is provided, a new index column will be created new_index_pattern = {row}{column}}_{label
-
strict(bool, default:True) –If True, raise an error if the table is not found in the image.
-
mode(Literal['eager', 'lazy'], default:'eager') –The mode to use for concatenation. Can be 'eager' or 'lazy'. if 'eager', the table will be loaded into memory. if 'lazy', the table will be loaded as a lazy frame.
-
max_workers(int | None, default:None) –How many images to read concurrently.
None(the default) reads them one at a time in the calling thread.
Source code in src/ngio/hcs/_plate.py
concatenate_image_tables_as_async
async
¶
concatenate_image_tables_as_async(
name: str,
table_cls: type[TableType],
acquisition: int | None = None,
index_key: str | None = None,
strict: bool = True,
mode: Literal["eager", "lazy"] = "eager",
max_workers: int | None = None,
) -> TableType
Concatenate tables from all images in the plate as a specific type.
Deprecated: use concatenate_image_tables_as(max_workers=...).
Parameters:
-
name(str) –The name of the table to concatenate.
-
table_cls(type[TableType]) –The type of the table to concatenate.
-
index_key(str | None, default:None) –The key to use for the index of the concatenated table.
-
acquisition(int | None, default:None) –The acquisition id to filter the images.
-
index_key(str | None, default:None) –If a string is provided, a new index column will be created new_index_pattern = {row}{column}}_{label
-
strict(bool, default:True) –If True, raise an error if the table is not found in the image.
-
mode(Literal['eager', 'lazy'], default:'eager') –The mode to use for concatenation. Can be 'eager' or 'lazy'. if 'eager', the table will be loaded into memory. if 'lazy', the table will be loaded as a lazy frame.
-
max_workers(int | None, default:None) –How many images to read concurrently.
None(the default) reads them one at a time in the calling thread.
Source code in src/ngio/hcs/_plate.py
Open a well¶
ngio.open_ome_zarr_well
¶
open_ome_zarr_well(
store: StoreOrGroup,
cache: bool = False,
mode: AccessModeLiteral = "r+",
) -> OmeZarrWell
Open an OME-Zarr well.
Parameters:
-
store(StoreOrGroup) –The Zarr store or group that stores the plate.
-
cache(bool, default:False) –Whether to use a cache for the zarr group metadata.
-
mode(AccessModeLiteral, default:'r+') –The access mode for the image. Defaults to "r+".
Source code in src/ngio/hcs/_plate.py
OmeZarrWell¶
ngio.OmeZarrWell
¶
OmeZarrWell(group_handler: ZarrGroupHandler)
A class to handle the Well Sequence in an OME-Zarr file.
Initialize the LabelGroupHandler.
Parameters:
-
group_handler(ZarrGroupHandler) –The Zarr group handler that contains the Well.
Source code in src/ngio/hcs/_plate.py
paths
¶
Return the images paths in the well.
If acquisition is None, return all images paths in the well. Else, return the images paths in the well for the given acquisition.
Parameters:
-
acquisition(int | None, default:None) –The acquisition id to filter the images.
Source code in src/ngio/hcs/_plate.py
get_image_store
¶
get_image_store(image_path: str) -> StoreOrGroup
Get the image store from the well.
Parameters:
-
image_path(str) –The path of the image.
get_image_acquisition_id
¶
Get the acquisition id of an image in the well.
Parameters:
-
image_path(str) –The path of the image.
Returns:
-
int | None–int | None: The acquisition id of the image.
Source code in src/ngio/hcs/_plate.py
get_image
¶
get_image(image_path: str) -> OmeZarrContainer
Get an image from the well.
Parameters:
-
image_path(str) –The path of the image.
Returns:
-
OmeZarrContainer(OmeZarrContainer) –The image.
Source code in src/ngio/hcs/_plate.py
atomic_add_image
¶
atomic_add_image(
image_path: str,
acquisition_id: int | None = None,
strict: bool = True,
) -> StoreOrGroup
Parallel safe version of add_image.
Serialises the read-modify-write of the well metadata behind a file
lock, so concurrent workers cannot lose each other's updates. The lock
is an OS file lock: it holds across threads and processes on one
machine, and on a shared network filesystem only if the mount honours
flock.
Note
On Windows the lock is best-effort and warns: filelock can hand
the same lock to two workers at once, so a single writer is safe but
concurrent ones can still lose an update. Run those on Linux/macOS.
Raises:
-
NgioValueError–If the store is not local, or if the well was opened with caching enabled — neither supports the lock.
Source code in src/ngio/hcs/_plate.py
add_image
¶
add_image(
image_path: str,
acquisition_id: int | None = None,
strict: bool = True,
) -> StoreOrGroup
Add an image to an ome-zarr well.
Parameters:
-
image_path(str) –The path of the image.
-
acquisition_id(int | None, default:None) –The acquisition id to filter the images.
-
strict(bool, default:True) –Whether to check if the acquisition id is already exists in the well. Defaults to True. If False this might lead to acquisition in a well that does not exist at the plate level.
Source code in src/ngio/hcs/_plate.py
Create a plate or a well¶
ngio.create_empty_plate
¶
create_empty_plate(
store: StoreOrGroup,
name: str,
images: list[ImageInWellPath] | None = None,
ngff_version: NgffVersions = DefaultNgffVersion,
cache: bool = False,
overwrite: bool = False,
) -> OmeZarrPlate
Initialize and create an empty OME-Zarr plate.
Parameters:
-
store(StoreOrGroup) –The Zarr store or group that stores the plate.
-
name(str) –The name of the plate.
-
images(list[ImageInWellPath] | None, default:None) –A list of images to add to the plate. If None, no images are added. Defaults to None.
-
ngff_version(NgffVersion, default:DefaultNgffVersion) –The NGFF version to use for the new plate.
-
cache(bool, default:False) –Whether to use a cache for the zarr group metadata.
-
overwrite(bool, default:False) –Whether to overwrite the existing plate.
Source code in src/ngio/hcs/_plate.py
ngio.create_empty_well
¶
create_empty_well(
store: StoreOrGroup,
ngff_version: NgffVersions = DefaultNgffVersion,
cache: bool = False,
overwrite: bool = False,
) -> OmeZarrWell
Create an empty OME-Zarr well.
Parameters:
-
store(StoreOrGroup) –The Zarr store or group that stores the well.
-
ngff_version(NgffVersion, default:DefaultNgffVersion) –The version of the new well.
-
cache(bool, default:False) –Whether to use a cache for the zarr group metadata.
-
overwrite(bool, default:False) –Whether to overwrite the existing well.