Visualization (pamica.viz)¶
Top-level, backend-agnostic plots for a fitted model's output
(pamica.numpy_impl.load.AmicaOutput, as returned by
pamica.numpy_impl.load.loadmodout). Unlike the legacy
pamica.numpy_impl.viz module, these functions return a Figure and
accept an optional ax/axes to draw on, instead of returning None and
mutating pyplot's global state.
plot_pmi_heatmap— a components-by-components pairwise mutual-information heatmap (seepamica.metrics.pairwise_mi), reordered to cluster related components near the diagonal.plot_model_probability— for a multi-model fit, two stacked panels: each model's posterior probability over time, and the log-likelihood of the most probable model at each timepoint. A per-component scalp-topography plot is not included yet: deriving source activations from a loadedAmicaOutputdepends on an unsettledWconvention question, tracked in #159.
pamica.viz.plot_pmi_heatmap(mi_matrix, *, order=None, labels=None, model=None, mask_diagonal=True, ax=None, cmap='viridis')
¶
Square components-x-components pairwise-MI heatmap (pop_modPMI view).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mi_matrix
|
ndarray
|
(n, n) symmetric mutual-information matrix, e.g. from
|
required |
order
|
ndarray
|
Length-n permutation to reorder both axes before plotting. Defaults to
|
None
|
labels
|
sequence of str
|
Per-original-component labels; tick label at reordered position |
None
|
model
|
int
|
0-based model index, used only for the title ("Model N", 1-based, to match MATLAB's per-model panel titles). Omit for a single, unlabeled heatmap. |
None
|
mask_diagonal
|
bool
|
|
True
|
ax
|
Axes
|
Axes to draw on. A new figure+axes is created if omitted. |
None
|
cmap
|
str
|
Colormap name. A colorbar is always added (a deliberate improvement;
MATLAB's |
"viridis"
|
Returns:
| Type | Description |
|---|---|
Figure
|
The figure the heatmap was drawn on ( |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in pamica/viz.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
pamica.viz.plot_model_probability(out=None, *, lht=None, srate=None, smooth_sec=None, window_sec=None, axes=None)
¶
Two-panel per-model probability + best-model log-likelihood (modprobplot).
Top panel: softmax(Lht) over models, one line per model ("Probability of
Model Being Active"). Bottom panel: the per-sample log-likelihood of the
single most probable model at each timepoint (Lht.max(axis=0)), not
the total Lt, matching the observed MATLAB behaviour.
Provide exactly one source of Lht: a written out (an
:class:AmicaOutput), or a live lht array (for example from
:meth:pamica.AMICA.model_loglik, so an MNE-side fit can plot dominance
without writing an amicaout directory, issue #141).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out
|
AmicaOutput
|
Must have |
None
|
lht
|
np.ndarray of shape (n_models, n_samples)
|
A per-model per-sample log-likelihood array. Mutually exclusive with
|
None
|
srate
|
float
|
Sampling rate in Hz. pamica has no built-in notion of sample rate
( |
None
|
smooth_sec
|
float
|
Hanning-smoothing window, in seconds (requires |
None
|
window_sec
|
float
|
Initial x-axis view width, in seconds (requires |
None
|
axes
|
sequence of 2 Axes
|
|
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
The figure the two panels were drawn on. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither or both of |
Source code in pamica/viz.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |