Metadata-Version: 2.4
Name: nima_io
Version: 0.4.1
Summary: A project to read microscopy files.
Project-URL: Bug Tracker, https://github.com/darosio/nima_io/issues
Project-URL: Changelog, https://github.com/darosio/nima_io/blob/main/CHANGELOG.md
Project-URL: Documentation, https://nima-io.readthedocs.io
Project-URL: Github releases, https://github.com/darosio/nima_io/releases
Project-URL: Homepage, https://github.com/darosio/nima_io
Author-email: Daniele Arosio <darosio@duck.com>
License-Expression: BSD-3-Clause
License-File: LICENSE.txt
Keywords: Bioimage,Image Analysis,Metadata,Open Microscopy,Tiled Images
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Unix Shell
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.11
Requires-Dist: bioio-bioformats>=1.3.2
Requires-Dist: bioio-lif>=1.4.2
Requires-Dist: bioio-ome-tiff>=1.4.0
Requires-Dist: bioio-tifffile>=1.3.0
Requires-Dist: bioio>=3.2.0
Requires-Dist: click>=8.3.1
Requires-Dist: numpy>=2.4.2
Requires-Dist: ome-types>=0.6.3
Requires-Dist: xarray>=2026.2.0
Provides-Extra: docs
Requires-Dist: autodocsumm>=0.2.14; extra == 'docs'
Requires-Dist: bioio; extra == 'docs'
Requires-Dist: ipykernel>=7.1.0; extra == 'docs'
Requires-Dist: jupyter>=1.1.1; extra == 'docs'
Requires-Dist: matplotlib>=3.10.8; extra == 'docs'
Requires-Dist: myst-nb>=1.3.0; extra == 'docs'
Requires-Dist: pydata-sphinx-theme>=0.16.1; extra == 'docs'
Requires-Dist: pygments>=2.19.2; extra == 'docs'
Requires-Dist: scikit-image>=0.26.0; extra == 'docs'
Requires-Dist: sphinx-autodoc-typehints>=3.5.2; extra == 'docs'
Requires-Dist: sphinx-click>=6.2.0; extra == 'docs'
Requires-Dist: sphinx>=8.2.3; extra == 'docs'
Requires-Dist: sphinxcontrib-plantuml>=0.31; extra == 'docs'
Provides-Extra: zarr
Requires-Dist: bioio-ome-zarr>=3.2.2; extra == 'zarr'
Description-Content-Type: text/markdown

# NImA-io

[![PyPI](https://img.shields.io/pypi/v/nima_io.svg)](https://pypi.org/project/nima_io/)
[![CI](https://github.com/darosio/nima_io/actions/workflows/ci.yml/badge.svg)](https://github.com/darosio/nima_io/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/darosio/nima_io/branch/main/graph/badge.svg?token=OU6F9VFUQ6)](https://codecov.io/gh/darosio/nima_io)
[![](https://img.shields.io/badge/Pages-blue?logo=github)](https://darosio.github.io/nima_io/)

This is a helper library designed for reading microscopy data supported by
[Bioformats](https://www.openmicroscopy.org/bio-formats/) using Python. The
package also includes a command-line interface for assessing differences between
images.

## Features / Description

Despite the comprehensive python-bioformats package, Bioformats reading in
Python is not flawless. To assess correct reading and performance, I gathered a
set of test input files from real working data and established various
approaches for reading them:

1. Utilizing the external "showinf" and parsing the generated XML metadata.
1. Employing out-of-the-box python-bioformats.
1. Leveraging bioformats through the Java API.
1. Combining python-bioformats with Java for metadata (Download link: bio-formats 5.9.2).

At present, Solution No. 4 appears to be the most effective.

It's important to note that FEI files are not 100% OME compliant, and
understanding OME metadata can be challenging. For instance, metadata.getXXX is
sometimes equivalent to
metadata.getRoot().getImage(i).getPixels().getPlane(index).

The use of parametrized tests enhances clarity and consistency. The approach of
returning a wrapper to a Bioformats reader enables memory-mapped (a la memmap)
operations.

Notebooks are included in the documentation tutorials to aid development and
illustrate usage. Although there was an initial exploration of the TileStitch
Java class, the decision was made to implement TileStitcher in Python.

Future improvements can be implemented in the code, particularly for the
multichannel OME standard example, which currently lacks obj or resolutionX
metadata. Additionally, support for various instrument, experiment, or plate
metadata can be considered in future updates.

## Installation

System requirements:

- maven

### From PyPI

Using pip:

```
pip install nima_io
```

### Recommended: Using pipx

For isolated installation (recommended):

```
pipx install nima_io
```

### Shell Completion

#### Bash

```bash
_IMGDIFF_COMPLETE=bash_source imgdiff > ~/.local/bin/imgdiff-complete.bash
source ~/.local/bin/imgdiff-complete.bash
# Add to your ~/.bashrc to make it permanent:
echo 'source ~/.local/bin/ingdiff-complete.bash' >> ~/.bashrc
```

#### Fish:

```bash
_IMGDIFF_COMPLETE=fish_source imgdiff | source
# Add to fish config to make it permanent:
_IMGDIFF_COMPLETE=fish_source imgdiff > ~/.config/fish/completions/imgdiff.fish

```

## Usage

Docs: https://{{ cookiecutter.project_slug }}.readthedocs.io/

### CLI

```bash
imgdiff --help
```

### Python

```python
from nima_io import read
```

## Development

Requires Python `uv`.

With uv:

```bash
# one-time
pre-commit install
# dev tools and deps
uv sync --group dev
# lint/test
uv run ruff check .  (or: make lint)
uv run pytest -q  (or: make test)
```

### Update and initialize submodules

```
git submodule update --init --recursive
```

Navigate to the tests/data/ directory:

```
cd tests/data/
git co master
```

Configure Git Annex for SSH caching:

```
git config annex.sshcaching true
```

Pull the necessary files using Git Annex:

```
git annex pull
```

These commands set up the development environment and fetch the required data for testing.

Modify tests/data.filenames.txt and tests/data.filenames.md5 as needed and run:

```
cd tests
./data.filenames.sh
```

We use Renovate to keep dependencies current.

## Dependency updates (Renovate)

Enable Renovate:

1. Install the GitHub App: https://github.com/apps/renovate (Settings → Integrations → GitHub Apps → Configure → select this repo/org).
1. This repo includes a `renovate.json` policy. Renovate will open a “Dependency Dashboard” issue and PRs accordingly.

Notes:

- Commit style: `build(deps): bump <dep> from <old> to <new>`
- Pre-commit hooks are grouped and labeled; Python version bumps in `pyproject.toml` are disabled by policy.

Migrating from Dependabot:

- You may keep “Dependabot alerts” ON for vulnerability visibility, but disable Dependabot security PRs.

## Template updates (Cruft)

This project is linked to its Cookiecutter template with Cruft.

- Check for updates: `cruft check`
- Apply updates: `cruft update -y` (resolve conflicts, then commit)

CI runs a weekly job to open a PR when template updates are available.

First-time setup if you didn’t generate with Cruft:

```bash
pipx install cruft  # or: pip install --user cruft
cruft link --checkout main https://github.com/darosio/cookiecutter-python.git
```

Notes:

- The CI workflow skips if `.cruft.json` is absent.
- If you maintain a stable template branch (e.g., `v1`), link with `--checkout v1`. You can also update within that line using `cruft update -y --checkout v1`.

## License

We use a shared copyright model that enables all contributors to maintain the
copyright on their contributions.

All code is licensed under the terms of the [revised BSD license](LICENSE.txt).

## Contributing

If you are interested in contributing to the project, please read our
[contributing](https://darosio.github.io/nima_io/references/contributing.html)
and
[development environment](https://darosio.github.io/nima_io/references/development.html)
guides, which outline the guidelines and conventions that we follow for
contributing code, documentation, and other resources.
