extract_czexp_plan#
zen_api_utils.extract_czexp_plan
#
Extract a provisional CZI/CZMBI acquisition plan from a ZEN Experiment XML file.
Disclaimer: This script is intended for experimental use and may not cover all edge cases of ZEN Experiment XML files.
Run from the repository root:
python experimental\extract_czexp_plan.py experimental\ZEN_API_Test_CD7_split.czexp
Write a reduced JSON plan and a CZMBI file in one call:
python experimental\extract_czexp_plan.py `
experimental\ZEN_API_Test_CD7_split.czexp `
--reduced `
--output experimental\plan.json `
--czmbi-output experimental\hcs.czmbi
The JSON plan is always written first. When --czmbi-output is present, the
script reloads that JSON and projects its first acquisition block to CZMBI 1.0.
CZMBI generation requires split-scene acquisition with one planned CZI per scene.
When ZEN does not expose exact output names, the generated CZMBI uses deterministic
suggested_filename values that must be validated against actual ZEN output.
Classes:
-
UnsupportedCzmbiProjectionError–Raised when a planned CZI output cannot be represented in CZMBI 1.0.
Functions:
-
well_id–Return an Excel-style well identifier for one-based indices.
-
coordinate_pair–Parse a comma-separated XML coordinate pair.
-
tile_region_well–Read an explicit well coordinate from one ZEN tile region.
-
assign_template_wells–Assign direct positions to wells in a centered, axis-aligned carrier grid.
-
find_active_dimension_setup–Find an active dimension setup through active parent dimensions.
-
extract_tile_regions–Extract active rectangular tile grids from the sample holder.
-
active_tile_count–Return the largest per-scene M count from active tile grids.
-
extract_plan_xml–Extract an acquisition plan from XML returned by the ZEN API.
-
extract_plan–Extract an acquisition plan from a persisted
.czexpXML file. -
build_czmbi–Build CZMBI 1.0 for one split-scene block.
-
write_czmbi–Write a CZMBI 1.0 XML file and return its destination path.
-
write_czmbi_from_json–Load an extracted plan JSON file and write its CZMBI 1.0 XML projection.
-
reduce_plan–Remove non-CZMBI ZEN identifiers from
planin place and return it.
UnsupportedCzmbiProjectionError
#
Bases: ValueError
Raised when a planned CZI output cannot be represented in CZMBI 1.0.
well_id
#
well_id(row: int, column: int) -> str
Return an Excel-style well identifier for one-based indices.
coordinate_pair
#
coordinate_pair(element: Element, path: str) -> tuple[float, float] | None
Parse a comma-separated XML coordinate pair.
tile_region_well
#
tile_region_well(region: Element) -> tuple[int | None, int | None]
Read an explicit well coordinate from one ZEN tile region.
assign_template_wells
#
assign_template_wells(positions: list[dict[str, Any]], sample_holder: Element) -> None
Assign direct positions to wells in a centered, axis-aligned carrier grid.
find_active_dimension_setup
#
find_active_dimension_setup(block: Element, setup_name: str) -> ET.Element | None
Find an active dimension setup through active parent dimensions.
extract_tile_regions
#
extract_tile_regions(block: Element) -> list[dict[str, Any]]
Extract active rectangular tile grids from the sample holder.
active_tile_count
#
active_tile_count(block: Element) -> int
Return the largest per-scene M count from active tile grids.
extract_plan_xml
#
extract_plan_xml(xml: str, source_name: str = '<experiment-export>') -> dict[str, Any]
Extract an acquisition plan from XML returned by the ZEN API.
extract_plan
#
extract_plan(source: Path) -> dict[str, Any]
Extract an acquisition plan from a persisted .czexp XML file.
build_czmbi
#
build_czmbi(plan: dict[str, Any], block_index: int = 0) -> ET.Element
Build CZMBI 1.0 for one split-scene block.
Exact zen_filename values take precedence. Deterministic
suggested_filename values are used only when exact names are unavailable.
write_czmbi
#
write_czmbi(plan: dict[str, Any], destination: Path, block_index: int = 0) -> Path
Write a CZMBI 1.0 XML file and return its destination path.
write_czmbi_from_json
#
write_czmbi_from_json(plan_source: Path, destination: Path, block_index: int = 0) -> Path
Load an extracted plan JSON file and write its CZMBI 1.0 XML projection.
reduce_plan
#
reduce_plan(plan: dict[str, Any]) -> dict[str, Any]
Remove non-CZMBI ZEN identifiers from plan in place and return it.