Metadata-Version: 2.4
Name: registration1d
Version: 0.0.2
Summary: Linear and nonlinear registration of one-dimensional data
Author-email: Todd Pataky <spm1d.mail@gmail.com>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/spm1d-org/registration1d
Project-URL: Source, https://github.com/spm1d-org/registration1d
Project-URL: Issues, https://github.com/spm1d-org/registration1d/issues
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 :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: numpy>=1.22
Requires-Dist: scipy>=1.8
Requires-Dist: matplotlib>=3.5
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: jupyter; extra == "dev"
Requires-Dist: nbformat; extra == "dev"
Requires-Dist: nbconvert; extra == "dev"
Requires-Dist: ipykernel; extra == "dev"
Provides-Extra: notebooks
Requires-Dist: jiku-data; extra == "notebooks"
Requires-Dist: power1d; extra == "notebooks"
Provides-Extra: reference
Requires-Dist: fdasrsf; extra == "reference"
Requires-Dist: dtw-python; extra == "reference"
Requires-Dist: scikit-fda; extra == "reference"
Dynamic: license-file

[![Python](https://img.shields.io/badge/Python-FFD43B?style=for-the-badge&logo=python&logoColor=blue)](https://www.python.org)
[![Numpy](https://img.shields.io/badge/Numpy-777BB4?style=for-the-badge&logo=numpy&logoColor=white)](https://numpy.org)
[![Scipy](https://img.shields.io/badge/SciPy-654FF0?style=for-the-badge&logo=SciPy&logoColor=white)](https://scipy.org)
[![License: GPL-3.0](https://img.shields.io/badge/License-GPL--3.0-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
![version](https://img.shields.io/badge/version-0.0.2-blue)

# registration1d

Linear and nonlinear registration of one-dimensional data.

Find this package useful? Please press star ★ , thank you!

`registration1d` aligns sets of 1D observations (e.g. biomechanical time series) in time.
It depends only on `numpy`, `scipy` and `matplotlib`; the registration
algorithms are implemented from their mathematical definitions, so no other
registration package needs to be installed.

## Installation

    pip install registration1d            # from PyPI (numpy, scipy, matplotlib)

## Installation (development)

    git clone https://github.com/spm1d-org/registration1d.git
    cd registration1d
    python3 -m venv .venv
    source .venv/bin/activate          # Windows: .venv\Scripts\activate
    pip install -e ".[dev]"            # editable install + test/notebook tools
    pytest                             # runs tests/

Requires Python 3.10 or later. Minimal install (numpy, scipy, matplotlib only): `pip install -e .`.
Extras: `[dev]` adds pytest and the notebook tools; `[notebooks]` adds the
datasets and simulation packages used by two of the notebooks; `[reference]`
adds fdasrsf, dtw-python and scikit-fda for the tests that compare
registration1d with those implementations (skipped when they are absent).

## Quick start

The recommended import convention is `import registration1d as reg1d`;
the short alias is used throughout the documentation and notebooks.

    import registration1d as reg1d

    y       = [...]                                     # 8 observations of unequal length (lists of 1D arrays)
    yi      = reg1d.register_linear(y, n=101).y         # (8,101) linearly registered
    yr, wf  = reg1d.register_srsf(yi, max_iter=5)       # nonlinearly registered + warps

    result  = reg1d.register_srsf(yi, t=np.linspace(0, 100, 101))   # explicit time grid (% stance)
    result.plot(group=group)                            # before / after / warps
    result.apply(other_variable)                        # same warps applied to another (8,101) variable
    result.displacement_fields_t                        # displacement fields in % stance

## Methods

| function | type | description |
|---|---|---|
| `register_linear` | linear | interpolate to a common number of points |
| `register_shift` | linear | least-squares time shift |
| `register_affine` | linear | least-squares time shift and stretch |
| `register_srsf` | nonlinear | elastic (square-root slope function) registration, dynamic programming, Karcher-mean template |
| `register_dtw` | nonlinear | dynamic time warping (step patterns, window, derivative DTW, DBA, warp smoothing) |
| `register_landmark` | nonlinear | landmark registration with monotone-cubic warps |
| `register_continuous` | nonlinear | Ramsay-Li penalised least-squares smooth warps |
| `register_sim` | nonlinear | self-modelling / shape-invariant model (amplitude + smooth warp) |
| `register_pairwise` | nonlinear | pairwise synchronisation (template-free) |
| `register_bayes` | nonlinear | Bayesian registration (posterior samples and credible bands of the warps) |

All functions return a `RegistrationResult` (`islinear` tells linear from
nonlinear); multivariate (J,Q,D) input is supported by `register_srsf`.
Every nonlinear method takes `center=` ('karcher' | 'pointwise' | 'anchor' |
'none'; see the WarpCentering notebook) and `register_srsf` uses a
data-adaptive elasticity penalty (`lam='auto'`; `lam=0` reproduces fdasrsf).
Observations of different lengths can be registered in **real time**
without prior resampling by passing them as a list with their sampling
interval, e.g. `register_srsf(ylist, t='fs=1000')` (see `reg1d.realtime`
and the RealTimeRegistration notebook).
The package contains registration algorithms only. The example datasets
(`notebooks/data/`) and the permutation tests used in the demonstrations
live in `notebooks/util.py`, outside the package.

See `ALGORITHMS.md` for the provenance of each algorithm, `GPL-COMPLIANCE.md`
for the licensing status of all third-party code, `SUMMARY.md` for development
notes, `TESTS.md` for the test strategy, and the notebooks in `notebooks/`
(HTML renderings in `notebooks/html/`) for demonstrations; the
`jiku-data-datasets` notebook runs every method on all one-dimensional
datasets of the [jiku-data](https://pypi.org/project/jiku-data/) package,
and the `power_simulated_datasets` notebook measures false-positive rates
and statistical power after registration on simulated data built with
[power1d](https://spm1d.org/power1d) (`pip install jiku-data power1d`, or
the `[notebooks]` extra; jiku-data depends on PyTables, which is why these
are not part of `[dev]`). The package
source is in `src/registration1d/`; the draft software paper is in `paper/`.

## Tests

    python -m pytest tests

## Contributing

Please see the [spm1d.org contributing guidelines and AI policy](https://spm1d.org/contributing/).

## License

GNU General Public License v3.0 or later. See `LICENSE.txt`.
