Visualization#
brainmass.viz provides thin plotting helpers that keep the tutorials and the
gallery concise and visually consistent. Each helper surfaces a standard
matplotlib plot or a braintools.metric output (functional connectivity,
power spectrum) – none reimplements a metric.
Note
matplotlib is an optional dependency, imported lazily inside each
function. import brainmass never imports matplotlib on behalf of
viz; calling a helper without matplotlib installed raises a clear
ImportError pointing at the extra. Install it with:
pip install brainmass[viz]
Every helper accepts an optional ax= (returning the
matplotlib.axes.Axes it drew on) and tolerates unit-aware
(brainunit.Quantity) inputs.
Plotting helpers#
|
Plot one or more region time series. |
|
Plot a phase portrait of one variable against another. |
|
Plot a connectivity (or any square) matrix as a heatmap. |
|
Plot a functional-connectivity matrix. |
|
Plot the power spectral density of a 1-D signal. |
Examples#
The doctest setup selects the Agg (headless) backend, so these run in CI:
>>> import brainmass
>>> conn = brainmass.datasets.load_dataset('example_connectome')
>>> ax = brainmass.viz.plot_connectivity(conn.weights, labels=conn.labels)
>>> len(ax.images)
1
>>> sig = brainmass.datasets.load_dataset('example_signal')
>>> ax = brainmass.viz.plot_functional_connectivity(sig.signal)
>>> len(ax.images)
1
>>> ax = brainmass.viz.plot_power_spectrum(sig.signal[:, 0], dt=sig.dt)
>>> ax.get_xlabel()
'frequency'
See Also#
Datasets – the example data these helpers visualise.
Observation Models – mapping neural activity to measurable signals.