Skip to main content

tnorma

PyPI version DOI

Temporal normalization (from 0 to 100% with step interval).

Temporal normalization is usually employed for the temporal alignment of data obtained from different trials with different duration (number of points). This code implements a procedure known as the normalization to percent cycle.

This code can perform simple linear interpolation passing through each datum or spline interpolation (up to quintic splines) passing through each datum (knots) or not (in case a smoothing parameter > 0 is inputted).

NaNs and any value inputted as a mask parameter and that appears at the extremities might be removed or replaced by the first/last not-NaN value before the interpolation because this code does not perform extrapolation.
For a 2D array, the entire row with NaN or a mask value at the extremity might be removed because of alignment issues with the data from different columns. As result, if there is a column of only NaNs in the data, the temporal normalization can't be performed (empty arrays are returned).
NaNs and any value inputted as a mask parameter and that appears in the middle of the data (which may represent missing data) are ignored and the interpolation is performed through these points.

Installation

pip install tnorma

The plots (parameter show=True) require matplotlib, which can be installed together with:

pip install "tnorma[plot]"

Or

conda install -c duartexyz tnorma

Examples

>>> import numpy as np
>>> from tnorma import tnorma
>>> # Default options: cubic spline interpolation passing through
>>> # each datum, 101 points, and no plot
>>> y = [5,  4, 10,  8,  1, 10,  2,  7,  1,  3]
>>> tnorma(y)

>>> # Deal with missing data (use NaN as mask)
>>> x = np.linspace(-3, 3, 100)
>>> y = np.exp(-x**2) + np.random.randn(100)/10
>>> y[:10] = np.nan # first ten points are missing
>>> y[30: 41] = np.nan # make other 10 missing points
>>> yn, tn, indie = tnorma(y, step=-50, k=3, smooth=1, show=True)

>>> # Deal with 2-D array
>>> x = np.linspace(-3, 3, 100)
>>> y = np.exp(-x**2) + np.random.randn(100)/10
>>> y = np.vstack((y-1, y[::-1])).T
>>> yn, tn, indie = tnorma(y, step=-50, k=3, smooth=1, show=True)

More examples are in a marimo notebook in the docs directory. Run it in your browser, no installation needed:

Notebook molab marimo.app
tnorma Open in molab Open with marimo

The notebook name links to a static preview with the outputs; the badges run the notebook in your browser with WebAssembly.

Or run it locally:

uvx marimo edit --sandbox docs/tnorma_notebook.py

How to cite this work

Here is a suggestion to cite this GitHub repository:

Marcos Duarte. (2021). tnorma: A Python module for temporal normalization (from 0 to 100% with step interval) (Version v0.0.3). Zenodo. http://doi.org/10.5281/zenodo.4599136

And a possible BibTeX entry:

@software{marcos_duarte_2021_4599136,
  author       = {Marcos Duarte},
  title        = {{tnorma: A Python module for temporal normalization 
                   (from 0 to 100\% with step interval)}},
  month        = mar,
  year         = 2021,
  publisher    = {Zenodo},
  version      = {v0.0.3},
  doi          = {10.5281/zenodo.4599136},
  url          = {https://doi.org/10.5281/zenodo.4599136}
}

License

The non-software content of this project is licensed under a Creative Commons Attribution 4.0 International License, and the software code is licensed under the MIT license.

Metadata

Release files for tnorma 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tnorma 0.1.0
File Size Uploaded Provenance Actions
tnorma-0.1.0.tar.gz 8.9 kB With provenance Details for tnorma-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tnorma 0.1.0
File Interpreter ABI Platform Actions
tnorma-0.1.0-py3-none-any.whl Python 3 none any Details for tnorma-0.1.0-py3-none-any.whl

Total release size: 16.3 kB

Release files / tnorma-0.1.0.tar.gz

Download URL tnorma-0.1.0.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
05c204f24de1c08894d9907e05b7ed295f41a11c76259cc60a2178fa426fc573
BLAKE2b-256 checksum
How to use checksums
cae63a71df6ed14d640fc82e2b73664e968bb2a1be891ab1220bc49cef4aabe4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / tnorma-0.1.0-py3-none-any.whl

Download URL tnorma-0.1.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b3e42f74764e81731ca87f0e4361c447147dcae0b3c68120a06809d8588367d4
BLAKE2b-256 checksum
How to use checksums
87cec798c7ab0858615ecaa6a7542a9364a5eef70f8ef356f3fabf3c3e007c11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for tnorma 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tnorma-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page