eegproc.model_explainability.model_agnostic.plotting module
Array loading and plotting helpers independent of any dataset or model.
- eegproc.model_explainability.model_agnostic.plotting.flatten_trial(trial)[source]
Flatten chronological window/time axes to
(samples, channels).- Parameters:
trial (
ndarray)- Return type:
ndarray
- eegproc.model_explainability.model_agnostic.plotting.load_counterfactual_trial(npz_path, *, branch=None, reference='input')[source]
Load aligned reference and counterfactual trials from a saved archive.
Save the archive from an optimization result with
numpy.savez_compressed(path, **result["arrays"], channel_positions=...).reference='input'computes the standard counterfactual difference by comparingx_prime_<branch>directly with saved inputx.reference='reconstruction'compares withx_reconstructed_<branch>instead, isolating latent intervention change from reconstruction error.- Parameters:
npz_path (
Path)branch (
str|None, default:None)reference (
str, default:'input')
- Return type:
tuple[ndarray,ndarray,str,list[str] |None]
- eegproc.model_explainability.model_agnostic.plotting.plot_band_topographies(values, *, channel_names, band_names, colorbar_label, channel_positions=None, title=None, shared_scale=False, signed=None)[source]
Plot
(bands, channels)values with band-relative color scales.- Parameters:
values (
ndarray)channel_names (
list[str])band_names (
list[str])colorbar_label (
str)channel_positions (
ndarray|None, default:None)title (
str|None, default:None)shared_scale (
bool, default:False)signed (
bool|None, default:None)
- eegproc.model_explainability.model_agnostic.plotting.resolve_channel_names(n_channels, provided=None, saved=None)[source]
Resolve explicit or saved labels, falling back to numbered channels.
- Parameters:
n_channels (
int)provided (
Optional[Iterable[str]], default:None)saved (
Optional[Iterable[str]], default:None)
- Return type:
list[str]
- eegproc.model_explainability.model_agnostic.plotting.split_channel_bands(signal, *, n_channels, n_bands, feature_order)[source]
Return
(samples, bands, channels)from flattened channel-band data.channel-majormeans the flattened feature axis is ordered as all bands for channel 1, then all bands for channel 2.band-majormeans all channels for band 1, then all channels for band 2.- Parameters:
signal (
ndarray)n_channels (
int)n_bands (
int)feature_order (
str)
- Return type:
ndarray