ClearEx is an open source Python package for scalable analytics of cleared and expanded tissue imaging data.
- GUI-first entrypoint with headless fallback.
- Headless CLI for scripted runs.
- Input support for TIFF/OME-TIFF, generic Zarr, HDF5 (
.h5/.hdf5/.hdf), NumPy (.npy/.npz), and Navigate BDV N5 acquisitions throughexperiment.yml. - Navigate experiment ingestion from
experiment.yml/experiment.yaml. - Canonical persisted store format is OME-Zarr v3 (
*.ome.zarr). - Legacy
.n5remains a source-only input format. Navigate BDV N5 materialization requires companion*.xmlmetadata and now readssetup*/timepoint*/s0datasets through TensorStore so Dask ingestion stays parallelized onzarr>=3. - Public microscopy-facing image data is published as OME-Zarr HCS collections, while ClearEx execution caches and non-image artifacts live under namespaced
clearex/...groups. - Internal analysis image layout remains
(t, p, c, z, y, x)for runtime-cache arrays and analysis kernels. - Store-level spatial calibration for Navigate multiposition data is persisted in
clearex/metadataand applied to physical placement metadata without rewriting image data. - Analysis operations available from the main entrypoint:
- flatfield (
results/flatfield/latest) - deconvolution (
results/deconvolution/latest) - shear transform (
results/shear_transform/latest) - registration (
results/registration/latest) - uSegment3D segmentation (
results/usegment3d/latest) - particle detection (
clearex/results/particle_detection/latest) - display-pyramid metadata (
clearex/results/display_pyramid/latest) - visualization metadata (
clearex/results/visualization/latest) with napari launch - MIP export metadata (
clearex/results/mip_export/latest)
- flatfield (
- FAIR-style provenance records are persisted in
clearex/provenance/runswith append-only run history and hash chaining.
data_store.ome.zarris the canonical materialized store besideexperiment.yml.- The public source image collection is a synthetic single-well HCS layout at the store root:
A/1/<field>/<level>. - Public image-producing analysis outputs are sibling HCS collections under
results/<analysis>/latest. - ClearEx internal execution data lives under:
clearex/runtime_cache/source/...clearex/runtime_cache/results/<analysis>/latest/...
- ClearEx-owned metadata, provenance, GUI state, and non-image artifacts live under:
clearex/metadataclearex/provenanceclearex/gui_stateclearex/results/<analysis>/latest
- Legacy root
data, rootdata_pyramid, andresults/<analysis>/latest/datalayouts are migration-only and are no longer the canonical public contract.
- Python
>=3.12,<3.13(use Python3.12) - macOS/Linux/Windows supported by Python stack
- For GUI usage: display server +
PyQt6(installed in base dependencies)
Flatfield correction depends on BaSiCPy, which currently pins scipy<1.13.
SciPy 1.12.x does not publish Python 3.13 wheels, so Python 3.13
installations may fall back to unsupported source builds on Linux clusters.
Install uv:
# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
uv --version# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
uv --version# Ensure a supported Python version is installed and used
uv python install 3.12
uv venv --python 3.12
source .venv/bin/activate
# Install ClearEx (editable install)
uv pip install -e .
# Optional extras
uv pip install -e ".[decon]" # deconvolution stack (PyPetaKit5D + PSFmodels)
uv pip install -e ".[usegment3d]" # uSegment3D segmentation stack
uv pip install -e ".[dev]" # tests/lint/dev tools
uv pip install -e ".[docs]" # docs build stack
uv pip install -e ".[dev,docs,decon,usegment3d]"# Ensure a supported Python version is installed and used
uv python install 3.12
uv venv --python 3.12
.venv\Scripts\Activate.ps1
# Install ClearEx (editable install)
uv pip install -e .
# Optional extras
uv pip install -e ".[decon]"
uv pip install -e ".[usegment3d]"
uv pip install -e ".[dev]"
uv pip install -e ".[docs]"
uv pip install -e ".[dev,docs,decon,usegment3d]"Alternative repo-aware install with lockfile:
uv sync --python 3.12If you previously created .venv with Python 3.13 or 3.14, remove it and recreate:
# macOS / Linux
rm -rf .venv
uv venv --python 3.12# Windows (PowerShell)
Remove-Item -Recurse -Force .venv
uv venv --python 3.12python3.12 -m venv .venv
source .venv/bin/activate
pip install -e .py -3.12 -m venv .venv
.venv\Scripts\Activate.ps1
pip install -e .For HPC-specific setup guidance, see INSTALLATION_NOTES.md.
ClearEx installs the clearex command:
clearex --helpCurrent CLI usage:
usage: clearex [-h] [--flatfield] [--deconvolution] [--particle-detection]
[--usegment3d] [--channel-indices CHANNEL_INDICES]
[--input-resolution-level INPUT_RESOLUTION_LEVEL]
[--shear-transform] [-r] [--display-pyramid] [-v]
[--mip-export] [-f FILE] [--migrate-store MIGRATE_STORE]
[--migrate-output MIGRATE_OUTPUT] [--migrate-overwrite]
[--dask | --no-dask] [--chunks CHUNKS]
[--stage-axis-map STAGE_AXIS_MAP] [--gui | --no-gui]
[--headless]
--flatfield: Run flatfield-correction workflow.-f, --file: Path to input image/store or Navigateexperiment.yml.--deconvolution: Run deconvolution workflow.--particle-detection: Run particle detection workflow.--usegment3d: Run uSegment3D segmentation workflow.--channel-indices: uSegment3D channels to process (0,1,2orall).--input-resolution-level: uSegment3D input pyramid level (0,1, ...).--shear-transform: Run shear-transform workflow.-r, --registration: Run registration workflow hook.--display-pyramid: Prepare reusable display pyramids for visualization.-v, --visualization: Run visualization workflow.--mip-export: Export XY/XZ/YZ maximum-intensity projections.--migrate-store: Convert one legacy ClearEx.zarr/.n5store into canonical OME-Zarr v3.--migrate-output: Optional destination path for--migrate-store.--migrate-overwrite: Overwrite the migration destination.--dask / --no-dask: Enable/disable Dask-backed reading.--chunks: Chunk spec for Dask reads, for example256or1,256,256.--stage-axis-map: Store-level worldz/y/xmapping for Navigate multiposition stage coordinates, for examplez=+x,y=none,x=+y.--gui / --no-gui: Enable/disable GUI launch (default is--gui).--headless: Force non-interactive mode (overrides--gui).
Launch GUI (default behavior):
clearexRun headless on a Navigate experiment:
clearex --headless \
--file /path/to/experiment.yml \
--deconvolution --usegment3d --particle-detectionRun headless with an explicit stage-to-world axis mapping for Navigate multiposition placement:
clearex --headless \
--file /path/to/experiment.yml \
--visualization \
--stage-axis-map z=+x,y=none,x=+yRun headless uSegment3D on all channels:
clearex --headless \
--file /path/to/experiment.yml \
--usegment3d \
--channel-indices all \
--input-resolution-level 1Run headless particle detection on an existing canonical OME-Zarr store:
clearex --headless \
--file /path/to/data_store.ome.zarr \
--particle-detectionDisable Dask lazy loading:
clearex --headless --no-dask --file /path/to/data_store.ome.zarr --particle-detectionMigrate one legacy ClearEx store into canonical OME-Zarr v3:
clearex --migrate-store /path/to/legacy_store.zarr- If
--filepoints to Navigateexperiment.yml, ClearEx resolves acquisition data and materializes a canonical store first. - Existing canonical OME-Zarr stores are reused in place.
- Non-canonical acquisition inputs, including TIFF/OME-TIFF, HDF5, NumPy, generic Zarr, Navigate BDV N5 sources, and other Navigate source layouts, materialize to
data_store.ome.zarrbesideexperiment.yml. - Bare direct source
.n5runtime input is not a supported phase-1 workflow. For N5 acquisitions, point--fileat Navigateexperiment.ymlso ClearEx can resolve BDV XML metadata and materialize canonical.ome.zarr. - Legacy ClearEx
.zarr/.n5stores are not treated as canonical runtime inputs. Migrate them first withclearex --migrate-store. - Canonical stores persist
spatial_calibration = {schema, stage_axis_map_zyx, theta_mode}insideclearex/metadata. Missing metadata resolves to the identity mappingz=+z,y=+y,x=+x. - In the setup window,
Spatial Calibrationis configured per listed experiment. Draft mappings are tracked per experiment while the dialog is open, existing stores prefill the control, andNextwrites the resolved mapping to every reused or newly prepared store before analysis selection opens. - In headless mode,
--stage-axis-mapwrites the supplied mapping to materialized experiment stores and existing canonical OME-Zarr stores before analysis starts. If the flag is omitted, existing store calibration is preserved. - Deconvolution, particle detection, uSegment3D, and visualization operations run against canonical OME-Zarr stores.
- Visualization supports multi-volume overlays using logical sources and/or public OME image collections (for example source data plus
results/usegment3d/latest) with per-layer image/labels display controls. - Multiposition visualization placement now resolves world
z/y/xtranslations from the store-level spatial calibration. Bindings supportX,Y,Z, and Navigate focus axisFwith sign inversion ornone;THETAremains a rotation of thez/yplane about worldx. - Visualization now probes napari OpenGL renderer info (
vendor/renderer/version) and can fail fast when software rendering is detected or GPU rendering cannot be confirmed (require_gpu_rendering=True). - MIP export writes TIFF outputs as OME-TIFF (
.tif) with projection-aware physical pixel calibration (PhysicalSizeX/Y) derived from sourcevoxel_size_um_zyx. - uSegment3D runs per
(t, p, selected channel)volume task and publishes the latest result asresults/usegment3d/latest.- GUI channel checkboxes now support selecting multiple channels in one run (
channel_indices). - With GPU-aware
LocalCluster, separate channel tasks can execute concurrently across GPUs. input_resolution_levellets segmentation run on a selected prepared pyramid level.output_reference_space=level0upsamples labels back to original resolution.save_native_labels=True(when upsampling) also stores native-resolution labels as ClearEx-owned auxiliary artifacts.
- GUI channel checkboxes now support selecting multiple channels in one run (
- GPU awareness:
gpu=Truerequests GPU use for Cellpose/uSegment3D internals.require_gpu=Truefails fast if CUDA is unavailable.- For
LocalClusteranalysis runs with GPU-enabled uSegment3D, ClearEx now launches a GPU-pinned worker pool (one process per visible GPU by default) and advertises aGPU=1worker resource so segmentation tasks stay on GPU workers. - Local GPU mode can be controlled through
create_dask_client(..., gpu_enabled=True, gpu_device_ids=[...]). - GPU execution still depends on the installed PyTorch/CUDA build supporting
the device architecture (for example, modern PyTorch wheels may not support
older Pascal GPUs like Tesla P100
sm_60). - CuPy must match your CUDA major version (
cupy-cuda12xfor CUDA 12 environments,cupy-cuda11xfor CUDA 11 environments). Worker startup should expose NVRTC/CUDA runtime libraries onLD_LIBRARY_PATH.
- Scalability notes:
- Distributed execution is parallelized over
(t, p)volumes through Dask. - Intra-volume scalability uses uSegment3D gradient-descent tiling (
aggregation_tile_*parameters). - Visualization multiscale gate is configurable per volume layer:
inherit: follow global multiscale toggle and use existing pyramids when available.require: fail if no pyramid exists for that layer.auto_build: generate a visualization pyramid cache for that layer when missing.off: force single-scale rendering for that layer.
- Auto-generated visualization pyramids are written under
results/visualization_cache/pyramids/...and reused on subsequent runs. - Chunk-wise
map_overlapstitching across labels is not yet enabled by default because label continuity/relabeling across chunk seams requires additional global reconciliation.
- Distributed execution is parallelized over
- GUI setup accepts Navigate
experiment.yml/experiment.yamlfiles and managed experiment lists (.clearex-experiment-list.json). - In the setup window you can:
- load a single experiment,
- recursively scan a folder for
experiment.ymlfiles, - drag and drop experiments, folders, or saved list files into the experiment pane,
- save the current ordered experiment list for later reuse.
- Selecting an experiment in the setup list loads metadata automatically; double-clicking reloads that entry explicitly.
- Pressing
Nextbatch-prepares canonicaldata_store.ome.zarroutputs for every listed experiment that does not already have a complete store, then opens analysis selection for the currently selected experiment. - The setup dialog persists the last-used Zarr save config across sessions.
Rebuild Canonical Storeforces listed experiments to be rebuilt with the current chunking and pyramid settings; otherwise existing complete stores are reused as-is.- The analysis window includes an
Analysis Scopepanel where you can:- pick which loaded
experiment.ymldrives the current analysis context, or - enable batch mode to run the same selected analysis sequence across every experiment in the loaded list.
- pick which loaded
- Analysis parameters now persist per dataset:
- when you reopen a store, ClearEx restores the last saved GUI state for that dataset when available,
- otherwise it can fall back to the latest completed provenance-backed run parameters,
Restore Latest Run Parametersresets the current dataset view back to the most recent completed run.
- This persistence path is part of the GUI contract: future analysis widgets and workflows should be wired into the same restore, save, and provenance-backed replay mechanism rather than introducing one-off state handling.
- The
Running Analysisprogress dialog includes aStop Analysisbutton that requests a cooperative halt at the next progress checkpoint and records the run ascancelledin provenance. - If GUI cannot launch (for example no display), ClearEx logs a warning and falls back to headless execution.
- Keyframe capture is enabled by default during visualization (
capture_keyframes=True). - In napari:
- Press
Kto capture a keyframe. - Press
Shift-Kto remove the most recent keyframe.
- Press
- Default keyframe manifest path is
<analysis_store>.visualization_keyframes.json(override withkeyframe_manifest_path). - Each keyframe stores reproducible viewer state for movie reconstruction, including:
- camera (angles, zoom, center, perspective),
- dims (
current_step, axis labels, order, and 2D/3D display mode), - layer order and selected/active layers,
- per-layer display state (visibility, LUT/colormap, rendering mode, blending, opacity, contrast, and transforms when available).
- The GUI exposes a popup table (
Layer/View Table...) to define optional per-layer overrides andAnnotationlabels that are embedded in the keyframe manifest. - The GUI also exposes a popup table (
Volume Layers...) to configure overlay rows with:- component path,
- layer type (
imageorlabels), - channels, visibility, opacity, blending, colormap, rendering, and multiscale policy.
- Visualization parameters include
require_gpu_rendering(enabled by default). Disable only when running intentionally without a GPU-backed OpenGL context.
- Public OME source image collection:
- root
A/1/<field>/<level>(TCZYX)
- root
- Public OME image analysis collections:
results/flatfield/latest/A/1/<field>/<level>results/deconvolution/latest/A/1/<field>/<level>results/shear_transform/latest/A/1/<field>/<level>results/registration/latest/A/1/<field>/<level>results/usegment3d/latest/A/1/<field>/<level>
- ClearEx metadata and runtime namespaces:
clearex/metadataclearex/provenance/runs/<run_id>clearex/provenance/latest_outputs/<analysis>clearex/gui_stateclearex/runtime_cache/source/dataclearex/runtime_cache/source/data_pyramid/level_*clearex/runtime_cache/results/<analysis>/latest/dataclearex/runtime_cache/results/<analysis>/latest/data_pyramid/level_*clearex/results/<analysis>/latest
- Migration-only legacy layouts:
- root
data - root
data_pyramid results/<analysis>/latest/data
- root