Skip to main content

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

Project description

tnorma

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 knwown 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 extermity 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 (an empty 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

Or

conda install -c duartexyz tnorma

Examples

>>> # 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)

How to cite this work

Here is a suggestion to cite this GitHub repository:

Duarte, M. (2020) tnorma: A Python module for temporal normalization (from 0 to 100% with step interval), https://github.com/demotu/tnorma.

And a possible BibTeX entry:

@misc{Duarte2020,  
    author = {Duarte, M.},
    title = {tnorma: A Python module for temporal normalization (from 0 to 100% with step interval)},  
    year = {2020},  
    publisher = {GitHub},  
    journal = {GitHub repository},  
    howpublished = {\url{https://github.com/demotu/tnorma}}  
}

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tnorma-0.0.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

tnorma-0.0.3-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file tnorma-0.0.3.tar.gz.

File metadata

  • Download URL: tnorma-0.0.3.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1.post20200323 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for tnorma-0.0.3.tar.gz
Algorithm Hash digest
SHA256 6be7d224dff426786d00071fe57df4567e3b2638de562794abd303e81b2c70da
MD5 8686599928526bcc2029a4e8e6ec798e
BLAKE2b-256 79ae68278c7bb6d35a41bafa21ebea712dc943169bce77e599e5d1964bde15ee

See more details on using hashes here.

File details

Details for the file tnorma-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: tnorma-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1.post20200323 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for tnorma-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 91193e8756f2e895012d71b2626edcabfd4ca1c1fc6e0598503b431af597b6d4
MD5 618c8d1c5e141b3a8b30885b3398848a
BLAKE2b-256 81e49423fa45bddb80b4c63b7cf91644bf49ded1fc584eaf4faf9f48737a4cfc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page