Metadata-Version: 2.4
Name: altea
Version: 0.1.0
Summary: Autonomous Learning for Tomographic Ensembles and Attributes: a reproducible pipeline for quality control, segmentation and 3D morphometry of tomographic image stacks.
Author: Jorge Bravo-Abad
License: MIT License
        
        Copyright (c) 2026 Jorge Bravo-Abad
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/jorgebravoabad/altea
Project-URL: Repository, https://github.com/jorgebravoabad/altea
Keywords: tomography,FIB-SEM,image-segmentation,morphometry,porous-media,reproducibility,materials-characterization
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Image Processing
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.23
Requires-Dist: scipy>=1.9
Requires-Dist: scikit-image>=0.20
Requires-Dist: scikit-learn>=1.1
Requires-Dist: tifffile>=2022.8.12
Requires-Dist: pyyaml>=6.0
Requires-Dist: matplotlib>=3.6
Provides-Extra: deep
Requires-Dist: torch>=2.0; extra == "deep"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Dynamic: license-file

# ALTEA

**Autonomous Learning for Tomographic Ensembles and Attributes**

A reproducible, provenance-tracked Python pipeline for automated quality
control, segmentation and 3-D morphometry of tomographic image stacks such as
FIB-SEM. Built with porous and heterogeneous materials in mind (MOFs, battery
electrodes, catalysts, membranes, rock), but general to any two-phase or
multi-phase volumetric acquisition.

[![CI](https://github.com/jorgebravoabad/altea/actions/workflows/ci.yml/badge.svg)](https://github.com/jorgebravoabad/altea/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

---

## Why

Analysing FIB-SEM tomography today typically involves two costly, poorly
reproducible steps: an operator manually discards a large fraction of acquired
slices (e.g. 500–600 acquired, 300–400 kept) by visual inspection, and the
image treatment is tuned by eye per sample "like Photoshop", with no single
procedure that applies across samples. ALTEA turns both into deterministic,
config-driven, versioned operations, and records exactly what was done to every
volume.

ALTEA is a reproducible **orchestration layer**, not a single model. Every stage
is explicit, every parameter lives in a config file, and every run emits a
provenance record (software and dependency versions, input data hash, per-stage
parameters and metrics). The same input always yields the same result — and you
can prove it.

## Pipeline

```
load → quality control → drift correction → preprocessing → segmentation → morphometry
```

| Stage | What it does |
|-------|--------------|
| **io** | Load FIB-SEM stacks (multi-page TIFF or slice directories) with voxel spacing |
| **qc** | Per-slice sharpness / brightness / drift / curtaining scores; reproducible, threshold-driven slice selection (replaces manual curation) |
| **align** | Rigid drift correction by phase cross-correlation |
| **preprocess** | Deterministic denoising and contrast normalization — every parameter recorded |
| **segment** | Pluggable backends: classical (Otsu, watershed) and learned (random-forest pixel classifier; optional deep U-Net) |
| **morphometry** | Porosity, specific surface area, pore-size distribution, connectivity/percolation, geometric tortuosity — all voxel-size-aware |
| **acquire** | Convergence analysis: how few slices suffice for a target accuracy (basis for cost-aware acquisition) |

## Install

```bash
pip install altea            # core
pip install "altea[deep]"    # + optional deep-learning segmentation backends
pip install "altea[dev]"     # + test / lint tooling
```

## Quickstart

No data required — run the synthetic demo:

```bash
altea demo --output runs/demo
```

Or on your own stack:

```bash
altea run --input stack.tif --config configs/fibsem_default.yaml --output runs/sample1
```

In Python:

```python
from altea import Pipeline
from altea.datasets import make_porous_volume, add_acquisition_artifacts

clean, ground_truth = make_porous_volume(porosity=0.35)
raw = add_acquisition_artifacts(clean, blur_slices=(8,), charge_slices=(15,))

results = Pipeline.from_yaml("configs/fibsem_default.yaml").run(raw, output_dir="runs/demo")

m = results["morphometry"]
print(m.porosity, m.specific_surface_area, m.tortuosity)
print(results["qc_report"].summary())      # which slices were dropped, and why
```

## Segmentation backends

Backends share one interface and self-register, so switching is a one-line
config change:

```yaml
segment:
  backend: pixel_rf      # otsu | watershed | pixel_rf | unet
  params: {sigmas: [1, 2, 4], n_estimators: 200}
```

Add your own by subclassing `SegmentationBackend` and decorating with
`@register_backend`. Nothing else in the pipeline changes.

## Reproducibility

Every run writes `provenance.json`:

```json
{
  "altea_version": "0.1.0",
  "dependency_versions": {"numpy": "...", "scikit-image": "..."},
  "input_hash": "sha256:...",
  "config": {...},
  "stages": [{"name": "qc", "params": {...}, "metrics": {...}}, ...]
}
```

## Roadmap

- **Cost-aware autonomous acquisition.** The `acquire` module already quantifies
  the accuracy-vs-slice-count trade-off. The next step is an active policy that
  decides on the fly how many sections to acquire to reach a target uncertainty,
  reducing destructive beam time.
- Deep segmentation backends (2-D U-Net / nnU-Net wrapper) under `altea[deep]`.
- Sparse-view reconstruction of discarded slices.

## Status

Alpha. Interfaces may change before 1.0.

## Citation

If you use ALTEA, please cite it via [`CITATION.cff`](CITATION.cff).

## License

MIT — see [LICENSE](LICENSE).
