spectralbrain.viz.bayes#
Bayesian posterior visualisation for spectral morphometry.
Directly linked to spectralbrain.statistics.bayesian — every
model class has a matching figure function. Also includes general
Bayesian visualisation tools (ridgeline plots, ROPE decision diagrams,
forest plots, prior–posterior overlays).
Figure types#
Posterior distribution with HDI + ROPE (general)
Forest plot (coefficients + credible intervals)
Prior vs posterior overlay
ROPE decision diagram (stacked bar)
Ridgeline plot (multi-group, multi-panel)
Horseshoe shrinkage path (HorseshoeRegression)
BEST effect size posterior (BayesianGroupComparison)
Site effects caterpillar (HierarchicalLinearModel)
GP normative trajectory (GaussianProcessNormative)
Connectome difference matrix (BayesianConnectome)
Functions
|
Three-panel BEST visualisation: Δμ, Δσ, effect size. |
|
Posterior mean edge-difference matrix. |
|
Forest plot — coefficients + credible intervals. |
|
Gaussian Process age trajectory with uncertainty fans. |
|
Horseshoe coefficient plot: forest + shrinkage heatmap. |
|
Posterior distribution with HDI band and optional ROPE. |
|
Overlay prior and posterior distributions. |
|
Multi-panel ridgeline plot. |
|
Stacked horizontal bar — P(below) | P(ROPE) | P(above). |
|
Caterpillar plot of random intercepts per site. |
- spectralbrain.viz.bayes.plot_best_posterior(trace, *, rope=(-0.1, 0.1), title='BEST — Bayesian Group Comparison', save=None)[source]#
Three-panel BEST visualisation: Δμ, Δσ, effect size.
- spectralbrain.viz.bayes.plot_connectome_posterior(edge_diff_matrix, *, labels=None, network_boundaries=None, cmap='RdBu_r', vmax=None, title='Bayesian Connectome — Edge Differences', ax=None, save=None)[source]#
Posterior mean edge-difference matrix.
- spectralbrain.viz.bayes.plot_forest(var_names, posteriors, *, hdi_prob=0.94, ref_val=0.0, colors=None, title='Forest Plot', xlabel='Coefficient', ax=None, save=None)[source]#
Forest plot — coefficients + credible intervals.
- Parameters:
- Return type:
- spectralbrain.viz.bayes.plot_gp_trajectory(ages_train, y_train, ages_pred, y_pred_mean, y_pred_std, *, patient_ages=None, patient_values=None, patient_labels=None, ci_levels=(0.5, 0.9, 0.99), title='GP Normative Trajectory', xlabel='Age (years)', ylabel='Descriptor', ax=None, save=None)[source]#
Gaussian Process age trajectory with uncertainty fans.
Concentric bands show expanding uncertainty. Individual patients plotted as coloured dots with deviation annotation.
- Parameters:
ages_train (ndarray, shape (n,))
y_train (ndarray, shape (n,))
ages_pred (ndarray, shape (m,))
y_pred_mean (ndarray, shape (m,))
y_pred_std (ndarray, shape (m,))
patient_ages (ndarray, optional)
patient_values (ndarray, optional)
ci_levels (tuple of float) – Confidence bands (inner to outer).
title (str)
xlabel (str)
ylabel (str)
ax (Axes | None)
- Return type:
- spectralbrain.viz.bayes.plot_horseshoe_coefficients(trace, *, var_names=None, hdi_prob=0.94, title='Horseshoe Regression — Feature Selection', save=None)[source]#
Horseshoe coefficient plot: forest + shrinkage heatmap.
Left panel: forest plot of β posteriors. Right panel: local shrinkage (κ = 1/(1+λ²)) — darker = more shrunk.
- spectralbrain.viz.bayes.plot_posterior(samples, *, hdi_prob=0.94, rope=None, ref_val=None, color='#4477AA', xlabel='Parameter', title='', ax=None, save=None)[source]#
Posterior distribution with HDI band and optional ROPE.
- Parameters:
- Return type:
- spectralbrain.viz.bayes.plot_prior_posterior(prior_samples, posterior_samples, *, xlabel='Parameter', title='Prior → Posterior', ax=None, save=None)[source]#
Overlay prior and posterior distributions.
- spectralbrain.viz.bayes.plot_ridgeline(data, *, overlap=0.6, colors=None, xlabel='Value', title='', figsize=None, save=None, formats=None)[source]#
Multi-panel ridgeline plot.
Each panel corresponds to one feature. Within each panel, overlapping KDE distributions are stacked vertically by group.
- Parameters:
- Returns:
fig, axes
- Return type:
Examples
>>> plot_ridgeline({ ... "HKS": {"Control": ctrl_hks, "MTLE-L": mtle_l_hks, "MTLE-R": mtle_r_hks}, ... "WKS": {"Control": ctrl_wks, "MTLE-L": mtle_l_wks, "MTLE-R": mtle_r_wks}, ... }, overlap=0.7, save="ridgeline.png")
- spectralbrain.viz.bayes.plot_rope_decision(posteriors, rope=(-0.1, 0.1), *, title='ROPE Decision', xlabel='Probability', ax=None, save=None)[source]#
Stacked horizontal bar — P(below) | P(ROPE) | P(above).