braindecode.visualization.compute_ssim_metrics#
- braindecode.visualization.compute_ssim_metrics(explanations, reference, chs_info=None, abs_reference=True, abs_explanation=False, prctile_val=95, win_size=7)[source]#
Compute four SSIM-based attribution-quality metrics.
Companion to
compute_metrics(). Returned column order matchesSSIM_METRIC_NAMES:SSIM_topperc: SSIM between top-percentile masks (each kept at its own scale).SSIM_absnorm: SSIM between min-max-normalized|explanation|and reference.SSIM_norm: SSIM between min-max-normalized raw explanation and reference.SSIM_raw: SSIM between raw explanation and normalized reference.
No extra dependencies; SSIM is computed with a pure-PyTorch implementation.
- Parameters:
explanations (numpy.ndarray) – Same shape
(n_samples, n_chans, n_times). Whenchs_infois given, each sample is time-averaged and projected to a 2-D topomap before SSIM, matchingcompute_metrics()’ topographic mode.reference (numpy.ndarray) – Same shape
(n_samples, n_chans, n_times). Whenchs_infois given, each sample is time-averaged and projected to a 2-D topomap before SSIM, matchingcompute_metrics()’ topographic mode.chs_info (list of dict, optional) – Channel info; enables topographic projection.
abs_reference (bool) – Same semantics as in
compute_metrics().abs_explanation (bool) – Same semantics as in
compute_metrics().prctile_val (float) – Top-percentile threshold for the
SSIM_toppercmask.win_size (int) – SSIM sliding-window size.
7matches the benchmark in Sujatha Ravindran & Contreras-Vidal (2023).
- Returns:
scores (numpy.ndarray of shape
(n_samples, 4)) – SSIM values per sample. Skipped samples have an all-zero row.n_skipped (int) – Number of samples skipped due to all-zero or constant attributions or reference.