Python toolbox that incorporates tools from biological signal processing and musical theory to extract harmonic structures from biosignals.
- ๐ต Harmonic Analysis: Extract harmonic structures from biosignals using music theory principles
- ๐ Multiple Peak Detection Methods: FOOOF, EMD, fixed-frequency, and harmonic-recurrence based methods
- ๐งฎ Harmonicity Metrics: Compute consonance, dissonance, harmonic similarity, Tenney height, and more
- ๐น Musical Applications: Generate musical scales, tuning systems, and MIDI output from biosignals
- ๐ฌ Group Analysis (BETA): Batch processing for multiple time series with automatic aggregation
- ๐ Rich Visualizations: Publication-ready plots for spectral analysis and harmonic relationships
- ๐ง Multi-modal Support: Compatible with EEG, ECG, EMG, plant signals, and other biosignals
- ๐จ Interactive GUI: Graphical interface for easy exploration
To install the latest stable version of Biotuner from PyPI, run:
pip install biotunerIf you want the latest development version or contribute to the code, follow these steps:
The easiest way to set up a development environment is by using invoke, which will:
โ
Create a Conda environment
โ
Install dependencies
โ
Install Biotuner in editable mode
# Clone the repository
git clone https://github.com/AntoineBellemare/biotuner.git
cd biotuner
# Install Invoke (if not already installed)
pip install invoke
# Automatically create a Conda environment and install Biotuner
invoke setup๐ This will create a Conda environment named biotuner_env and install all dependencies.
To activate the Conda environment manually:
conda activate biotuner_envIf you prefer to set up the environment manually, follow these steps:
conda create --name biotuner_env python=3.11 -y
conda activate biotuner_envpip install -r requirements.txt
pip install -e .To confirm that Biotuner is installed correctly, run the test suite:
invoke testor manually using:
pytest tests/If all tests pass โ , your installation is complete!
- For general users: Install via
pip install biotuner - For development: Clone the repo and run
invoke setup - To verify installation: Run
invoke test
from biotuner import compute_biotuner
# Initialize the object
biotuning = compute_biotuner(sf=1000)
# Extract spectral peaks
biotuning.peaks_extraction(data, peaks_function='FOOOF')
# Get consonance metrics for spectral peaks
biotuning.compute_peaks_metrics()Analyze multiple time series simultaneously with automatic aggregation and group comparisons:
from biotuner import BiotunerGroup
import numpy as np
# Multiple trials or electrodes: shape (n_series, n_samples)
data = np.random.randn(10, 5000)
# Create group object
btg = BiotunerGroup(data, sf=1000, axis_labels=['trials'])
# Run analysis pipeline
btg.compute_peaks(peaks_function='FOOOF', min_freq=1, max_freq=50)
btg.compute_metrics(n_harm=10)
# Get summary statistics
summary = btg.summary()Note: The BiotunerGroup module is currently in beta. The API may change in future releases.
Explore Biotuner's capabilities through our interactive web interface:
biotuner-engine.kairos-hive.org
The Biotuner Engine provides a user-friendly web application to analyze biosignals, visualize harmonic structures, and explore musical applications directly in your browserโno installation required!
The figure above illustrates Biotuner's ability to extract harmonic structures across different biological and physical systems. It showcases harmonic ratios detected in biosignals from the brain, heart, and plants, as well as their correspondence with audio signals. By analyzing the fundamental frequency relationships in these diverse modalities, Biotuner enables a cross-domain exploration of resonance and tuning in biological and artificial systems.
- Full Documentation - Complete API reference and tutorials
- Getting Started Guide - Step-by-step introduction
- API Reference - Detailed function and class documentation
- BiotunerObject - Single time series analysis
- BiotunerGroup (BETA) - Group analysis
- Metrics - Harmonicity metrics
- Peak Extraction - Peak detection methods
- Examples & Notebooks - Jupyter notebook tutorials
We welcome contributions! Whether it's:
- ๐ Bug reports
- ๐ก Feature requests
- ๐ Documentation improvements
- ๐ง Code contributions
Please feel free to open an issue or submit a pull request on GitHub.
Biotuner is licensed under the MIT License.
If you use Biotuner in your research, please cite our work. See the citation guide for more information.
- Issues: GitHub Issues
- Email: antoine.bellemare9@gmail.com
- Documentation: https://antoinebellemare.github.io/biotuner/
Made with โค๏ธ by the Biotuner development team



