Overview
This library simplifies the process of managing and visualizing multi-channel signal data. It provides a high-level API to encapsulate signal data handling and visualization through flexible and intuitive classes.
The library is designed for data scientists, engineers, and researchers working with signal data, enabling them to focus on analysis and visualization without worrying about low-level implementation details.
Features
- Streamlined Signal Management: Encapsulate multi-channel signal data with metadata such as sampling frequency and scale factors.
- Dynamic Viscd ualization: Customize signal plots with channel-specific settings (e.g., colors, labels, and scales).
- Interactive Viewer: Navigate through signals with keyboard controls and timestamps for quick analysis.
Installation
pip install bioviewer
Usage
1. Signal Creation
Create a Signal instance to encapsulate your data and its display settings:
import numpy as np
from bioviewer import Signal
data = np.random.randn(6, 10000)
signal = Signal(
data=data,
fs=128,
scale_factor='auto',
y_ticks=['Ch1', 'Ch2', 'Ch3', 'Ch4', 'Ch5', 'Ch6'],
unit='mV',
colors='rgbcmy',
linewidth=1,
show_scale=True
)
2. Visualize with the Viewer
Combine multiple signals and visualize them interactively:
from bioviewer import Viewer
signal1 = Signal(data=data, fs=128)
signal2 = Signal(data=data, fs=128, colors='bbbkbr')
viewer = Viewer(
signals=[signal1, signal2],
figsize=(14, 4),
t_start=0,
windowsize=15,
stepsize=13,
timestamps=[10, 50, 100]
)
3. Keyboard Controls
- Right Arrow: Move forward in time.
- Left Arrow: Move backward in time.
- n / b: Navigate to the next/previous timestamp.
- z: Save the current view as an image.
Example
from bioviewer import Signal, Viewer
import numpy as np
data = np.random.randn(6, 100000)
timestamps = [3, 7, 12, 21]
signal = Signal(data=data, fs=128, scale_factor='auto', unit='mV')
viewer = Viewer(
signals=[signal],
timestamps=timestamps,
windowsize=10
)
Jupyter notebooks
To enable interactive backends for Matplotlib plots in Jupyter Notebooks, use the following magic command:
%matplotlib widget
This command activates an interactive plot viewer, allowing you to interact with your visualizations directly within the notebook.
Contributing
Contributions are welcome! Feel free to submit a pull request or file an issue.
Support
For questions or issues, open a GitHub issue or contact me at [moritz.alkofer@protonmail.com].