Metadata-Version: 2.2
Name: splineops
Version: 2.2.0
Summary: Projection-based antialiased resizing for N-D scientific arrays.
Keywords: spline,resampling,antialiasing,microscopy,n-dimensional
Author: Pablo Garcia-Amorena, Philippe Thévenaz, Arrate Muñoz Barrutia, Daniel Sage, Dimitris Perdios, Thomas Debarre, Michael Unser
License: BSD 3-Clause License
         
         Copyright (c) 2024, splineops
         Copyright (c) 2023-2024, EPFL (Dimitris Perdios, Pablo Garcia-Amorena)
         Copyright (c) 2021-2022, EPFL (Dimitris Perdios)
         
         Redistribution and use in source and binary forms, with or without
         modification, are permitted provided that the following conditions are met:
         
         1. Redistributions of source code must retain the above copyright notice, this
            list of conditions and the following disclaimer.
         
         2. Redistributions in binary form must reproduce the above copyright notice,
            this list of conditions and the following disclaimer in the documentation
            and/or other materials provided with the distribution.
         
         3. Neither the name of the copyright holder nor the names of its
            contributors may be used to endorse or promote products derived from
            this software without specific prior written permission.
         
         THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
         AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
         IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
         DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
         FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
         DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
         SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
         CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
         OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
         OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
         
Classifier: Topic :: Scientific/Engineering :: Image Processing
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Project-URL: Homepage, https://splineops.github.io/
Project-URL: Documentation, https://splineops.github.io/
Project-URL: Source, https://github.com/splineops/splineops
Project-URL: Issues, https://github.com/splineops/splineops/issues
Project-URL: Download, https://github.com/splineops/splineops.git
Project-URL: Evidence, https://splineops.github.io/claims.html
Requires-Python: >=3.11
Requires-Dist: numpy>=1.26
Requires-Dist: scipy>=1.15
Requires-Dist: matplotlib>=3.8
Provides-Extra: visualization
Requires-Dist: pooch>=1.8; extra == "visualization"
Requires-Dist: IPython>=8.26; extra == "visualization"
Provides-Extra: study
Requires-Dist: scikit-image>=0.25; extra == "study"
Requires-Dist: tifffile>=2024.8; extra == "study"
Provides-Extra: wavefield-study
Requires-Dist: scikit-image>=0.25; extra == "wavefield-study"
Requires-Dist: torch>=2.0; extra == "wavefield-study"
Provides-Extra: selma3d-study
Requires-Dist: splineops[wavefield-study]; extra == "selma3d-study"
Requires-Dist: nibabel>=5.2; extra == "selma3d-study"
Provides-Extra: selma3d-demo
Requires-Dist: splineops[study]; extra == "selma3d-demo"
Requires-Dist: nibabel>=5.2; extra == "selma3d-demo"
Requires-Dist: napari[pyqt6]>=0.6; extra == "selma3d-demo"
Provides-Extra: selma3d-demo-all
Requires-Dist: splineops[selma3d-demo]; extra == "selma3d-demo-all"
Requires-Dist: torch>=2.0; extra == "selma3d-demo-all"
Provides-Extra: minivess-study
Requires-Dist: splineops[selma3d-study]; extra == "minivess-study"
Requires-Dist: opencv-python-headless>=4.8; extra == "minivess-study"
Provides-Extra: tests
Requires-Dist: tox>=4.13; extra == "tests"
Requires-Dist: pytest>=6.0; extra == "tests"
Requires-Dist: pytest-cov>=5.0; extra == "tests"
Requires-Dist: hypothesis>=6.100; extra == "tests"
Provides-Extra: dev
Requires-Dist: splineops[tests,visualization]; extra == "dev"
Requires-Dist: black>=23.10; extra == "dev"
Requires-Dist: mypy>=1.8; extra == "dev"
Requires-Dist: build; extra == "dev"
Provides-Extra: dev-cupy
Requires-Dist: splineops[dev]; extra == "dev-cupy"
Requires-Dist: cupy>=12.2; extra == "dev-cupy"
Provides-Extra: docs-core
Requires-Dist: splineops[visualization]; extra == "docs-core"
Requires-Dist: sphinx>=7.3; extra == "docs-core"
Requires-Dist: sphinx-gallery>=0.17; extra == "docs-core"
Requires-Dist: sphinx-prompt>=1.8; extra == "docs-core"
Requires-Dist: sphinx-copybutton>=0.5; extra == "docs-core"
Requires-Dist: sphinx-remove-toctrees>=1.0; extra == "docs-core"
Requires-Dist: sphinx-design>=0.6; extra == "docs-core"
Requires-Dist: pydata-sphinx-theme>=0.15; extra == "docs-core"
Requires-Dist: myst-parser>=3.0; extra == "docs-core"
Requires-Dist: imageio-ffmpeg>=0.5; extra == "docs-core"
Provides-Extra: docs
Requires-Dist: splineops[docs-core]; extra == "docs"
Requires-Dist: Pillow>=10.0; extra == "docs"
Requires-Dist: scikit-image>=0.25; extra == "docs"
Requires-Dist: opencv-python-headless>=4.8; extra == "docs"
Requires-Dist: torch>=2.0; extra == "docs"
Description-Content-Type: text/markdown

# SplineOps

**Projection-based antialiased resizing for N-D scientific arrays.**

SplineOps is designed for precise, repeatable downsampling of regular-grid
2-D images and 3-D volumes. It combines explicit coordinate semantics, a
readable Python reference implementation, a native CPU backend, and reusable
plans for fixed-geometry workloads.

## Installation

SplineOps requires Python 3.11 or newer:

```shell
python -m pip install splineops
```

Published wheels include the native resize extension on supported platforms.

## Quick start

```python
import numpy as np
from splineops import resize

volume = np.random.default_rng(0).random((64, 192, 192), dtype=np.float32)
coarse = resize(
    volume,
    output_size=(32, 96, 96),
    method="cubic-antialiasing",
)
```

The `*-antialiasing` methods project the input spline onto a coarser spline
space instead of treating downsampling as interpolation alone. For repeated
arrays with the same geometry, `ResizePlan` reuses setup and workspace state.

## When to use SplineOps

SplineOps is a good fit when:

- continuous-valued 2-D or 3-D NumPy data must be downsampled;
- coordinate, boundary, and output-shape semantics must be explicit;
- aliasing matters; or
- many arrays share one resize geometry.

Another tool may be a better fit when:

- differentiable GPU execution is required;
- physical-space image metadata must be managed automatically;
- ordinary display-image scaling is the only goal; or
- categorical labels are being resampled, where nearest-neighbour semantics
  are normally appropriate.

## Public maturity

| Module | Status | Public position |
| --- | --- | --- |
| `resize`, `ResizePlan` | Stable | Native N-D interpolation and projection antialiasing with a Python reference path |
| `TensorSpline` | Stabilizing | Continuous tensor-product models evaluated at arbitrary coordinates |
| Affine, differentials, smoothing, regression, pyramids, wavelets | Experimental | Available for research while their contracts and reference coverage mature |

Experimental describes API and validation maturity, not the importance of the
underlying methods. See the [project status](https://splineops.github.io/project-status.html)
for exact evidence and remaining graduation work.

## Numerical and performance position

SplineOps does not claim to be the fastest generic 2-D image resizer. OpenCV,
PyTorch, or other libraries can be faster when their coordinate, boundary,
kernel, and antialiasing conventions are acceptable.

SplineOps is strongest when the spline model matters: defined grids and
boundaries, N-D projection antialiasing, native/reference parity, and repeated
fixed-geometry execution. Cross-library reports include semantic differences
as well as timings; numerical difference from SplineOps is not treated as an
independent accuracy metric.

The flagship [SELMA3D microvessel validation](https://splineops.github.io/selma3d-vessels-study.html)
uses 18 held-out expert-labelled 3-D microscopy patches. For the tested lateral
2x coarsening, SplineOps had higher mean vessel-ranking ROC AUC than the named
SciPy, scikit-image, and PyTorch pipelines under a predeclared family-wise rule.
It was 12.49x, 15.17x, and 1.36x faster, respectively, on the recorded
one-thread CPU run. This is narrow preprocessing superiority—not segmentation
or universal resampling superiority.

Explore that result interactively with the
[installed SELMA3D napari comparison demo](https://splineops.github.io/selma3d-demo.html).
It downloads one
checksum-verified public patch, runs the named methods locally, and provides a
curtain slider over their outputs and expert vessel labels.
The default demo extra avoids PyTorch; install `selma3d-demo-all` when the
PyTorch-area comparison is required.

The exact approved public wording and its limits are maintained in
[Claims and evidence](https://splineops.github.io/claims.html).

The [3-D microscopy case study](https://splineops.github.io/cells3d-study.html)
tests that position on a public two-channel volume. It publishes the input
checksum, code, raw results, local timings, and the limits of each metric.

The stricter [BBBC050 segmentation validation](https://splineops.github.io/bbbc050-study.html)
uses manual labels and embryo-level held-out evaluation. SplineOps was fast and
competitive, but the predeclared quality-superiority criterion was not met.

The [controlled 3-D spectral-coarsening validation](https://splineops.github.io/wavefield3d-study.html)
uses analytical targets rather than a library output. Its frozen criterion
passed against six generic resize alternatives: projection reduced mean NRMSE
by 54% versus the nearest frozen baseline over 72 smooth field cases. A post-hoc
polyphase FIR audit was far more accurate, so this is not evidence of broad
scientific-resampling or downstream-task superiority.

## Backends

- NumPy is supported across the package.
- The native C++ backend accelerates resize on CPU.
- CuPy interoperability is experimental and limited to parts of `TensorSpline`.

Set `SPLINEOPS_ACCEL=never` to force the Python resize reference or
`SPLINEOPS_ACCEL=always` to require the native extension. See the
[backend contract](https://splineops.github.io/backend-support.html) for exact
scope.

## Documentation

- [Getting started](https://splineops.github.io/getting-started.html)
- [Modules](https://splineops.github.io/modules.html)
- [Examples](https://splineops.github.io/examples.html)
- [Claims and evidence](https://splineops.github.io/claims.html)
- [Resize guide](https://splineops.github.io/user-guide/02_resize.html)
- [Volume downsampling tutorial](https://splineops.github.io/volume-downsampling.html)
- [SELMA3D microvessel validation](https://splineops.github.io/selma3d-vessels-study.html)
- [Interactive SELMA3D napari demo](https://splineops.github.io/selma3d-demo.html)
- [Controlled 3-D spectral-coarsening validation](https://splineops.github.io/wavefield3d-study.html)
- [3-D microscopy case study](https://splineops.github.io/cells3d-study.html)
- [BBBC050 segmentation validation](https://splineops.github.io/bbbc050-study.html)
- [Performance evidence](https://splineops.github.io/performance.html)
- [API reference](https://splineops.github.io/api/index.html)
- [Provenance](https://splineops.github.io/provenance.html)
- [Changelog](https://github.com/splineops/splineops/blob/main/CHANGELOG.md)

SplineOps modernizes spline methods developed across the Biomedical Imaging
Group at EPFL and its collaborators. Method citations, implementation history,
and source provenance are recorded explicitly.

## Development

```shell
git clone https://github.com/splineops/splineops.git
cd splineops
python -m venv .venv
source .venv/bin/activate
python -m pip install -e '.[dev]'
python -m pytest -q
```

Reproducible resize evidence commands include:

```shell
python scripts/benchmark_resize_pr.py --profile smoke --output-dir /tmp/splineops-smoke
python scripts/benchmark_resize_native.py --backend both --output-csv /tmp/splineops-native.csv
python scripts/benchmark_resize_libraries.py --output-csv /tmp/splineops-libraries.csv
```
