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.

See Examples β†’

πŸ”¬ Statistical Testing

Add cluster permutation tests, box plot significance indicators, and regression fits with confidence intervals to your plots.

See Examples β†’

πŸ“ˆ Multi-line Plots

Publication-ready time series plots with individual traces, mean Β± CI/SD, and automatic significance testing.

See Examples β†’

🎨 Plotly Integration

Beautiful interactive plots with custom templates, metadata annotations, and support for massive datasets via plotly-resampler.

See API β†’

🧠 MNE Plotting

Plotting utilities to create plotly plots from mne instances for raw or epoched data.

See Examples β†’

Quick Start

# Install with all features
pip install md-utils[all]

Example: Combining multiple plots to a single dashboard

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
)

Live Example

Here’s the interactive dashboard created by the code above:

Core Capabilities

πŸ“¦ 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 features

Status

CI codecov Python

  • 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.