Skip to main content

tscv-vision

CI Publish License: MIT Python

tscv-vision is a NumPy-first Python package for computer-vision feature engineering of one-dimensional time series. It converts signals into image representations, extracts classical image descriptors, and scales the workflow to long signals with sliding-window processing.

The project is designed for research, reproducible feature extraction, and lightweight production pipelines where the core dependency footprint should stay small.

Highlights

  • Time-series imaging encoders: Gramian Angular Field, Gramian Angular Difference Field, recurrence plots, spectrograms, and additional registry encoders.
  • Classical feature extractors: intensity statistics, normalized histograms, gradient histograms, Local Binary Patterns, and batch extraction.
  • Sliding-window pipelines for long 1D or multichannel signals.
  • CLI for .npy inputs with metadata-rich .npz outputs.
  • Optional extras for analytics, GPU acceleration, neural integrations, MLOps, and domain adapters.
  • Release-ready packaging with PyPI Trusted Publishing and Zenodo metadata.

Installation

Install the core package:

pip install tscv-vision

Install optional extras only when needed:

Extra Command Purpose
cli pip install "tscv-vision[cli]" YAML configuration files
analytics pip install "tscv-vision[analytics]" SHAP, LIME, UMAP, plotting, wavelets
domains pip install "tscv-vision[domains]" Domain adapters backed by scikit-learn
gpu pip install "tscv-vision[gpu]" CuPy-accelerated encoder paths
mlops pip install "tscv-vision[mlops]" FastAPI, Prometheus, Feast integrations
torch pip install "tscv-vision[torch]" Torch-based neural components

For local development:

git clone https://github.com/DiogoRibeiro7/tscv-vision.git
cd tscv-vision
poetry install

Quick Start

import numpy as np
from tscv_vision import encoders, features, sliding

x = np.sin(np.linspace(0, 4 * np.pi, 128))

# Encode a series as a 2D image.
img = encoders.gaf(x)
print(img.shape)  # (128, 128)

# Extract a feature vector from one image.
vec = features.extract_feature_vector(img, bins=32)
print(vec.shape)

# Extract a stacked feature matrix from multiple images.
batch = features.extract_batch(np.stack([img, img]), bins=32)
print(batch.shape)

# Encode overlapping windows and keep their start indices.
images, starts = sliding.encode_sliding(x, encoder="gaf", size=64, hop=32)
print(images.shape, starts)

# Extract sliding-window feature vectors directly.
matrix, starts = sliding.features_for_sliding(x, encoder="gaf", size=64, hop=32)
print(matrix.shape, starts)

Command Line

Generate sample data:

python samples/generate.py

Extract features from one signal:

tscv-features \
  --encoders gaf \
  --input samples/sine.npy \
  --output out.npz \
  --features all \
  --bins 32

Run a sliding-window, multi-encoder pipeline:

tscv-features \
  --encoders gaf,spec \
  --fusion concat \
  --sliding \
  --win-len 128 \
  --hop 64 \
  --input samples/sine.npy \
  --output out_sliding.npz \
  --save-images \
  --save-meta

The output .npz contains feature arrays plus JSON metadata. Sliding runs can include window_starts, win_len, hop, and encoded image stacks.

Feature Surface

Encoders

Encoder Function or name Output
GAF encoders.gaf(x, method="summation") or gaf (N, N)
GADF encoders.gaf(x, method="difference") or gadf (N, N)
Recurrence plot encoders.recurrence_plot(x) or rp (N, N)
Spectrogram encoders.spectrogram(x) or spec (F, T)
Continuous wavelet cwt (scales, N)

Feature Extractors

Function Description
features.intensity_stats(img) mean, std, min, max, skewness, kurtosis
features.histogram(img, bins=32) normalized intensity histogram
features.gradient_histogram(img, bins=16) Sobel-like gradient magnitude histogram
features.lbp(img, radius=1) Local Binary Pattern histogram
features.extract_feature_vector(img, bins=32) unified feature vector
features.extract_batch(images, bins=32) stacked feature matrix

Documentation

Development

The project uses Poetry, Ruff, mypy, pytest, and pre-commit.

poetry install
poetry run pre-commit run --all-files
poetry run ruff check .
poetry run mypy src
poetry run pytest -q

Build and check distribution artifacts:

python -m build
python -m twine check dist/*

The default package build is pure Python. To opt into building the optional Cython extension locally, set:

TSCV_BUILD_EXT=1 python -m build

See CONTRIBUTING.md for contribution workflow, coding standards, and pull request expectations.

Releases, PyPI, and Zenodo

Tagged releases are published to PyPI through GitHub Actions using PyPI Trusted Publishing with OpenID Connect. No PyPI API token is stored in the repository.

Zenodo archiving is configured through .zenodo.json. After the repository is enabled in Zenodo's GitHub integration, each GitHub Release can be archived with a version DOI. Add the DOI badge here after the first archive is created.

Citation

If you use tscv-vision in academic work, cite the archived Zenodo release once available, or use the metadata in CITATION.cff.

Diogo Ribeiro. tscv-vision: Computer-vision feature engineering for 1D time series.
https://github.com/DiogoRibeiro7/tscv-vision

Support and Security

  • General questions and usage problems: open a GitHub Discussion or issue.
  • Bug reports and feature requests: use the issue templates.
  • Security concerns: follow SECURITY.md.

Maintainer

License

tscv-vision is distributed under the MIT License.

Download files

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

Source Distribution

tscv_vision-0.1.1.tar.gz (172.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tscv_vision-0.1.1-py3-none-any.whl (84.1 kB view details)

Uploaded Python 3

File details

Details for the file tscv_vision-0.1.1.tar.gz.

File metadata

  • Download URL: tscv_vision-0.1.1.tar.gz
  • Upload date:
  • Size: 172.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for tscv_vision-0.1.1.tar.gz
Algorithm Hash digest
SHA256 101c6ee73efd5cf94c767552a0962bc70fd2bc0e3b07e8784c3776319aad54fb
MD5 bf9f2d69778e37729c91d8a5e32d3641
BLAKE2b-256 522a66b1853927c8c81d872b926df119b0a4c17626baba62b4ffaa433d5dda97

See more details on using hashes here.

Provenance

The following attestation bundles were made for tscv_vision-0.1.1.tar.gz:

Publisher: publish.yml on DiogoRibeiro7/tscv-vision

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tscv_vision-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tscv_vision-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 84.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for tscv_vision-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dd365eba2783fa9f1356a313ef6a44caf4a91e456d16f5f3ec68cb189cacf673
MD5 f0afde274a7b5b25c67b902938b34563
BLAKE2b-256 35c920f841c1e17a2c1cbb87b9fab53a0337ea5e259f5cf3e395ee252497e7bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for tscv_vision-0.1.1-py3-none-any.whl:

Publisher: publish.yml on DiogoRibeiro7/tscv-vision

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page