smartmicroscopy

Control ZEN through ZEN-API

Examples for microscope control, experiment configuration, image streaming, and guided acquisition.

These scripts can move hardware, acquire images, and change or overwrite experiment/output files. Review their settings before running on a microscope.

Setup and launch

From Windows CMD, launch a selected script using the workshop environment:

cd /d "F:\Pixi_Projects\zen_czi\smartmicroscopy"
pixi run --locked -e default python "examples\control_zen_via_zenapi\zenapi_streaming.py"

Replace the script name with the example you need. Most examples are configured inside their source rather than through command-line flags.

Hardware and experiment examples

Streaming

Guided acquisition

zenapi_guidedacq.py segments a saved overview and runs live detail scans for the detected regions. Optional settings collect run files and show a final comparison plot.

See the guided-acquisition README for setup, options, output locations, and the linked visual walkthrough, flowchart, and sequence diagram.

Supporting files

Keep gateway credentials private. Output locations vary by example; check the script and ZEN’s configured image output directory before acquisition.

CMD streaming example

Start a compatible ZEN installation with ZEN-API enabled and make the named experiment available. Configure config.ini for your gateway (or create the local my_config.ini if selected by your script). The gateway INI is required; streaming dimensions come from ZEN’s exported experiment metadata, not a separate streaming INI.

From the workshop root in CMD, start acquisition and write OME-Zarr:

pixi run --locked -e default python "examples\control_zen_via_zenapi\zenapi_stream2omezarr_experiment.py" ^
  --experiment "00_ZEN_API_OMEZARR_Stream" ^
  --zenapi-config "examples\control_zen_via_zenapi\config.ini" ^
  --output-dir "results\zen-streaming" ^
  --dtype uint16 ^
  --czi-name "zenapi_stream" ^
  --start-experiment ^
  --no-overwrite-czi ^
  --no-overwrite-zarr