import plotly.express as px
from pathlib import Path
from mdu.plotly.html_grids import create_plotly_grid_html
# Create sample figures
df = px.data.iris()
fig1 = px.scatter(df, x="sepal_width", y="sepal_length", color="species",
title="Sepal Dimensions")
fig2 = px.scatter(df, x="petal_width", y="petal_length", color="species",
title="Petal Dimensions")
fig3 = px.box(df, x="species", y="sepal_length", title="Sepal Length Distribution")
fig4 = px.violin(df, x="species", y="petal_length", title="Petal Length Distribution")
# Create 2x2 grid
create_plotly_grid_html(
figures=[fig1, fig2, fig3, fig4],
grid_shape=(2, 2),
filename=Path("iris_dashboard.html"),
show=True,
min_height=300
)MD Utils Documentation
Advanced Visualization & Statistical Analysis Tools for Electrophysiology and Beyond
Overview
MD Utils is a Python toolkit for creating publication-ready interactive visualizations and performing statistical analysis on plotly plots. It also contains utilities for MNE-Python users for electrophysiology plotting functions.
β Key Features
π HTML Grid Dashboards
Create multi-figure interactive dashboards with grid and tabbed layouts with a very simple interface, just having a list of figures and a specified grid - perfect for comprehensive reports and sharing results.
π¬ Statistical Testing
Add cluster permutation tests, box plot significance indicators, and regression fits with confidence intervals to your plots.
π Multi-line Plots
Publication-ready time series plots with individual traces, mean Β± CI/SD, and automatic significance testing.
π¨ Plotly Integration
Beautiful interactive plots with custom templates, metadata annotations, and support for massive datasets via plotly-resampler.
π§ MNE Plotting
Plotting utilities to create plotly plots from mne instances for raw or epoched data.
Quick Start
# Install with all features
pip install md-utils[all]Example: Combining multiple plots to a single dashboard
Live Example
Hereβs the interactive dashboard created by the code above:
Quick Links
Installation
Get started with MD Utils
API Reference
Detailed function documentation
Examples
Practical usage examples
Core Capabilities
π― Most Popular Functions
create_tabbed_plotly_grid_html- Multi-tab dashboards with custom gridsadd_cluster_permut_sig_to_plotly- Time series significance testingadd_box_significance_indicator- Automatic pairwise comparisonsmultiline_plot- Multi-line plots with stats overlaysadd_statsmodel_fit- Regression with confidence intervalsadd_meta_info- Metadata annotations for reproducibility
π¦ Additional Features
- MNE Integration: Event mapping and electrophysiology plotting
- Time Series: Large dataset support via plotly-resampler
- ML Plotting: ROC curves and model evaluation
- Type Converters: Flexible data type handling
Installation Options
# Basic installation
pip install md-utils
# With development tools
pip install md-utils[dev]
# With specific features
pip install md-utils[resampler] # Large time-series plotting
pip install md-utils[ml] # ML utilities
pip install md-utils[mne] # MNE-Python integration
pip install md-utils[all] # All featuresStatus
- Test Coverage: 27%
- Tests: 176 passing
- Python: 3.10+
- License: MIT
Contributing
Contributions are welcome! See the Contributing Guide for details.
License
MIT License - see LICENSE file for details.