Metadata-Version: 2.4
Name: omero-annotate-ai
Version: 0.4.0
Summary: OMERO integration for AI-powered image annotation and segmentation workflows
Author-email: Maarten Paul <m.w.paul@lumc.nl>
Maintainer-email: Maarten Paul <m.w.paul@lumc.nl>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/Leiden-Cell-Observatory/omero_annotate_ai
Project-URL: Repository, https://github.com/Leiden-Cell-Observatory/omero_annotate_ai.git
Project-URL: Issues, https://github.com/Leiden-Cell-Observatory/omero_annotate_ai/issues
Project-URL: Documentation, https://github.com/Leiden-Cell-Observatory/omero_annotate_ai#readme
Project-URL: Changelog, https://github.com/Leiden-Cell-Observatory/omero_annotate_ai/releases
Keywords: omero,microscopy,segmentation,ai,annotation,sam,micro-sam
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering :: Image Processing
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
Classifier: Environment :: Console
Classifier: Environment :: Other Environment
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.21.0
Requires-Dist: pandas>=1.3.0
Requires-Dist: imageio>=2.9.0
Requires-Dist: dask>=2021.6.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: typing-extensions>=4.0.0
Requires-Dist: ezomero>=3.1.0
Requires-Dist: opencv-python
Requires-Dist: tifffile
Provides-Extra: notebooks
Requires-Dist: ipywidgets>=7.6.0; extra == "notebooks"
Requires-Dist: ipykernel; extra == "notebooks"
Requires-Dist: pixi-kernel<0.7,>=0.6.6; extra == "notebooks"
Requires-Dist: marimo<0.20,>=0.19.2; extra == "notebooks"
Requires-Dist: keyring>=23.0.0; extra == "notebooks"
Provides-Extra: microsam
Requires-Dist: napari>=0.4.15; extra == "microsam"
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov>=2.0; extra == "dev"
Requires-Dist: black>=22.0; extra == "dev"
Requires-Dist: isort>=5.0; extra == "dev"
Requires-Dist: flake8>=4.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: mkdocs>=1.5.3; extra == "docs"
Requires-Dist: mkdocs-material>=9.5.9; extra == "docs"
Requires-Dist: mkdocstrings>=0.24.0; extra == "docs"
Requires-Dist: mkdocstrings-python>=1.7.0; extra == "docs"
Requires-Dist: mkdocs-gen-files>=0.5.0; extra == "docs"
Requires-Dist: mkdocs-literate-nav>=0.6.1; extra == "docs"
Requires-Dist: mkdocs-section-index>=0.3.8; extra == "docs"
Requires-Dist: mkdocs-autorefs>=0.5.0; extra == "docs"
Requires-Dist: griffe-pydantic>=1.1.7; extra == "docs"
Provides-Extra: all
Requires-Dist: omero-annotate-ai[microsam,notebooks]; extra == "all"
Dynamic: license-file

# OMERO Annotate.AI

[![PyPI version](https://img.shields.io/pypi/v/omero-annotate-ai)](https://pypi.org/project/omero-annotate-ai/)
[![install with bioconda](https://img.shields.io/badge/install%20with-bioconda-brightgreen.svg?style=flat)](http://bioconda.github.io/recipes/omero-annotate-ai/README.html)
[![Python versions](https://img.shields.io/pypi/pyversions/omero-annotate-ai)](https://pypi.org/project/omero-annotate-ai/)
[![CI/CD](https://github.com/Leiden-Cell-Observatory/omero_annotate_ai/actions/workflows/ci.yml/badge.svg)](https://github.com/Leiden-Cell-Observatory/omero_annotate_ai/actions)
[![Documentation](https://github.com/Leiden-Cell-Observatory/omero_annotate_ai/actions/workflows/docs.yml/badge.svg)](https://leiden-cell-observatory.github.io/omero_annotate_ai/)
[![Pixi Badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/prefix-dev/pixi/main/assets/badge/v0.json)](https://pixi.sh)
[![License](https://img.shields.io/github/license/Leiden-Cell-Observatory/omero_annotate_ai)](https://github.com/Leiden-Cell-Observatory/omero_annotate_ai/blob/main/LICENSE)

**Reproducible AI-assisted annotation of OMERO data, from image selection to training-ready datasets.**

Pick images from an OMERO project, dataset, plate or screen. Annotate them in napari with
[micro-SAM](https://github.com/computational-cell-analytics/micro-sam) or prepare them for
[Cellpose](https://www.cellpose.org). The masks, ROIs and a tracking table go back to OMERO.
Every run is described by one YAML file, so you can resume it, repeat it or share it.

![micro-SAM segmentation of a Cell Painting field in napari](docs/images/napari_microsam.jpg)
<sub>micro-SAM (`vit_b_lm`) instance segmentation of nuclei in a Cell Painting field from the BioImage Archive (S-BIAD855), shown in napari.</sub>

## How it works

```mermaid
flowchart LR
    A[OMERO<br/>project · dataset · plate · screen] --> B[Select images<br/>train / val / test split]
    B --> C[Annotate in napari<br/>micro-SAM or Cellpose]
    C --> D[Back to OMERO<br/>masks · ROIs · tracking table]
    D --> E[Training data<br/>micro-SAM · BiaPy · DL4MicEverywhere]
    D --> F[BioImage Archive<br/>MIFA export]
```

- **Jupyter widgets** for connecting to OMERO and configuring a run step by step, no code needed.
- **Resumable:** the tracking table records which images and patches are done, so an interrupted run continues where it stopped.
- **Flexible sampling:** timepoints, z-slices, 3D volumes, random patches, and filtering plate wells on their key-value pairs.
- **Training-ready output:** one folder layout for micro-SAM, BiaPy and DL4MicEverywhere, with images and labels paired by name.
- **FAIR by default:** the config carries study and method metadata and exports to the BioImage Archive (MIFA).
- **Read-only mode** for public servers such as the [IDR](https://idr.openmicroscopy.org).

## Jupyter widgets

<table>
  <tr>
    <td width="45%"><img src="docs/images/widget_connect.png" alt="OMERO connection widget"></td>
    <td width="55%"><img src="docs/images/widget_container.png" alt="Choosing an OMERO container in the workflow widget"></td>
  </tr>
  <tr>
    <td><sub>Connect to any OMERO server, here the public IDR.</sub></td>
    <td><sub>Choose a project, dataset, plate or screen.</sub></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><img src="docs/images/widget_config.png" alt="Reviewing the generated YAML configuration" width="65%"><br>
    <sub>Set the parameters and review the YAML config the run will use.</sub></td>
  </tr>
</table>

## Installation

```bash
# Recommended: pixi
pixi init myproject && cd myproject
pixi add micro_sam
pixi add --pypi omero-annotate-ai

# Or: conda + pip
conda install -c conda-forge micro_sam
pip install omero-annotate-ai
```

See the [installation guide](https://leiden-cell-observatory.github.io/omero_annotate_ai/installation/) for details and troubleshooting.

## Quick start

**With widgets** (in Jupyter):

```python
from omero_annotate_ai import create_omero_connection_widget, create_workflow_widget, create_pipeline

conn_widget = create_omero_connection_widget()
conn_widget.display()
conn = conn_widget.get_connection()

workflow_widget = create_workflow_widget(connection=conn)
workflow_widget.display()

config = workflow_widget.get_config()
pipeline = create_pipeline(config, conn)
table_id, config = pipeline.run_full_micro_sam_workflow()
```

**From a YAML config** (scripts, batch runs, or repeating a run):

```python
from omero_annotate_ai import load_config, create_pipeline

config = load_config("annotation_config.yaml")
pipeline = create_pipeline(config, conn)
table_id, config = pipeline.run_full_micro_sam_workflow()
```

The [configuration guide](https://leiden-cell-observatory.github.io/omero_annotate_ai/configuration/) lists every option.

## Example notebooks

| | Jupyter | marimo |
|---|---|---|
| Annotate with micro-SAM | [widget workflow](notebooks/jupyter/annotation/omero-annotate-ai-annotation-widget.ipynb) | [annotation](notebooks/marimo/omero-annotate-ai-annotation.py) |
| Prepare for Cellpose | [cellpose](notebooks/jupyter/annotation/omero-annotate-ai-cellpose.ipynb) | [cellpose](notebooks/marimo/omero-annotate-ai-cellpose.py) |
| Run from YAML | [from YAML](notebooks/jupyter/annotation/omero-annotate-ai-from-yaml.ipynb) | [from YAML](notebooks/marimo/omero-annotate-ai-from-yaml.py) |
| Train | [micro-SAM](notebooks/jupyter/training/omero-training-microsam.ipynb) · [BiaPy](notebooks/jupyter/training/omero-training_biapy.ipynb) · [DL4MicEverywhere](notebooks/jupyter/training/omero-training_DL4mic.ipynb) | [micro-SAM](notebooks/marimo/omero-training-microsam.py) |
| Export to the BioImage Archive | [BIA export](notebooks/jupyter/export_annotations/omero-table-to-bioimage-archive.ipynb) | |
| Try it on public IDR data | | [IDR demo](notebooks/marimo/omero-idr-demo.py) |

## Documentation

Full documentation: **https://leiden-cell-observatory.github.io/omero_annotate_ai/**
([micro-SAM tutorial](https://leiden-cell-observatory.github.io/omero_annotate_ai/tutorials/microsam-annotation-pipeline/),
[API reference](https://leiden-cell-observatory.github.io/omero_annotate_ai/api/)).

## Contributing

```bash
git clone https://github.com/Leiden-Cell-Observatory/omero_annotate_ai.git
cd omero_annotate_ai
pixi install
pixi run -e dev pytest tests/
```

Issues and pull requests are welcome on [GitHub](https://github.com/Leiden-Cell-Observatory/omero_annotate_ai/issues).

## Contact and acknowledgements

**Maarten Paul**, m.w.paul@lacdr.leidenuniv.nl

Developed at the [Leiden Cell Observatory](https://github.com/Leiden-Cell-Observatory) within the
[NL-BioImaging](https://github.com/NL-BioImaging) infrastructure, funded by NWO.
