visualize_heatmap
ðŸ§
Functions to visualize analyzer (XAI) heatmaps.
Quick Start
Particularly, the plot_heatmap
function is used to visualize the relevance maps of the LRP
analyzer from
xai4mri.model.interpreter
.
from xai4mri.model.interpreter import analyze_model
from xai4mri.visualizer import plot_heatmap
# Analyze model
analyzer_obj = analyze_model(model=model, ipt=mri_image, ...)
# Visualize heatmap / relevance map
analyzer_fig = plot_heatmap(ipt=mri_image, analyser_obj=analyzer_obj, ...)
Author: Simon M. Hofmann
Years: 2023-2024
gregoire_black_fire_red
ðŸ§
gregoire_black_fire_red(analyser_obj: ndarray) -> ndarray
Apply a color scheme to the analyzer object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
analyser_obj |
ndarray
|
XAI analyzer object (e.g., |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Colorized relevance map. |
Source code in src/xai4mri/visualizer/visualize_heatmap.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
list_supported_cmaps
ðŸ§
list_supported_cmaps()
Return a list of supported color maps for heatmap plotting.
Source code in src/xai4mri/visualizer/visualize_heatmap.py
155 156 157 158 |
|
plot_heatmap
ðŸ§
plot_heatmap(
ipt: ndarray,
analyser_obj: ndarray,
cmap_name: str = "black-fire-red",
mode: str = "triplet",
fig_name: str = "Heatmap",
**kwargs
) -> Figure
Plot an XAI-based analyzer object over the model input in the form of a heatmap.
How to use
from xai4mri.model.interpreter import analyze_model
from xai4mri.visualizer import plot_heatmap
# Analyze model
analyzer_obj = analyze_model(model=model, ipt=mri_image, ...)
# Visualize heatmap / relevance map
analyzer_fig = plot_heatmap(ipt=mri_image, analyser_obj=analyzer_obj, ...)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ipt |
ndarray
|
Model input image. |
required |
analyser_obj |
ndarray
|
Analyzer object (relevance map) that is computed by the model interpreter (e.g., |
required |
cmap_name |
str
|
Name of color-map ( |
'black-fire-red'
|
mode |
str
|
"triplet": Plot three slices of different axes. "all": Plot all slices (w/ brain OR w/o brain → set: |
'triplet'
|
fig_name |
str
|
name of figure |
'Heatmap'
|
kwargs |
Additional kwargs: "c_intensifier", "clip_q", "min_sym_clip", "true_scale", "plot_empty", "axis", "every", "crosshair", "gamma". And, |
{}
|
Returns:
Type | Description |
---|---|
Figure
|
|
Source code in src/xai4mri/visualizer/visualize_heatmap.py
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 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
|