Skip to main content

Research code for basic Rhythmic Segment Analysis.

Project description

CI docs

Rhythmic Segments

This project provides some basic code to simplify Rhythmic Segment Analysis in Python. A rhythmic segment analysis (RSA) analyzes every fixed-length segment of a sequence of time intervals: the short groups you obtain by sliding a window across the data. Each segment has a duration and a pattern. The pattern captures the relative durations of a segment’s intervals, either as a normalized vector or as a ratio. For example, the segment (2, 4, 4) has the pattern (.2, .4, .4) or 1 : 2 : 2; both descriptions are interchangeable. Thinking of patterns as normalized vectors shows that all patterns of a given length live on a simplex: a line for length 2, a triangle for length 3, and so on. The goal is to study rhythmic material by analysing how its segments are distributed of that simplex.

Computing patterns is as simple as normalising the segment, and so you can absolutely do a rhythmic segment analysis without using this package. This package however provides some utilities that make things easier: the RhythmicSegments class allows you to conveniently store large numbers of segments and handle associated metadata.

For more details, have a look at the docs.

Installation

The package has been tested with Python 3.11 and 3.12. You can install the package using pip:

pip install rhythmic-segments

Getting started

from rhythmic_segments import RhythmicSegments

intervals = [1, 2, 3, 4, 5, 6, 7, 8, 9]
rs = RhythmicSegments.from_intervals(intervals, length=3)
rs.segments
# array([[1., 2., 3.], [2., 3., 4.], [3., 4., 5.], ... ])

License

The code is distributed under an MIT license.

Contributing

Feel free to contribute via GitHub: https://github.com/bacor/rhythmic-segments

Citation

A paper describing the idea in more details is currently in preparation. Until a formal reference is available, please cite the repository:

@misc{cornelissen_rhythmic_segments,
  author = {Bas Cornelissen},
  title = {rhythmic_segments},
  howpublished = {\url{https://github.com/bascornelissen/rhythmic-segments}},
  year = {2025},
  note = {Version 0.1.3}
}

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

rhythmic_segments-0.1.12.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

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

rhythmic_segments-0.1.12-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file rhythmic_segments-0.1.12.tar.gz.

File metadata

  • Download URL: rhythmic_segments-0.1.12.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure

File hashes

Hashes for rhythmic_segments-0.1.12.tar.gz
Algorithm Hash digest
SHA256 62313c0b01f2f111edb1e91b3481aae03bab2781d7d6a22b7cb287b6f2d7a2a9
MD5 16deb45b18ec0eb749737092f71d3123
BLAKE2b-256 af32401fab7ea1eb3d562a50f9b55fa5c3d87e13335bc2f2ad9792f728f83423

See more details on using hashes here.

File details

Details for the file rhythmic_segments-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: rhythmic_segments-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure

File hashes

Hashes for rhythmic_segments-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 a55a51dfb5a2b0a41db137544e5a3f1b1c423d5838945377adf90c74657b03dd
MD5 abd451205459f1313623f17b8a8bfefc
BLAKE2b-256 e017604ecaa66a1c12a17b2af094875cb4543e8980a658e4215f58584222e400

See more details on using hashes here.

Supported by

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