Visualization
plot_image(image, *, channel=0, indices=None, coordinates=None, axes=None, cmap=None, percentiles=(0.5, 99.5), figsize=None, title=None, output_path=None, show=True, savefig_kwargs=None, voxels=False, figsize_multiplier=2.0, intersections=True, **imshow_kwargs)
plot_image(image: Image, *, show: Literal[False], channel: int = ..., indices: tuple[int | None, int | None, int | None] | None = ..., coordinates: tuple[float | None, float | None, float | None] | None = ..., axes: Sequence[Axes] | None = ..., cmap: str | Colormap | dict[int, tuple[int, int, int]] | None = ..., percentiles: tuple[float, float] = ..., figsize: tuple[float, float] | None = ..., title: str | None = ..., output_path: TypePath | None = ..., savefig_kwargs: dict[str, Any] | None = ..., voxels: bool = ..., figsize_multiplier: float = ..., intersections: bool = ..., **imshow_kwargs: Any) -> Figure
plot_image(image: Image, *, show: Literal[True] = ..., channel: int = ..., indices: tuple[int | None, int | None, int | None] | None = ..., coordinates: tuple[float | None, float | None, float | None] | None = ..., axes: Sequence[Axes] | None = ..., cmap: str | Colormap | dict[int, tuple[int, int, int]] | None = ..., percentiles: tuple[float, float] = ..., figsize: tuple[float, float] | None = ..., title: str | None = ..., output_path: TypePath | None = ..., savefig_kwargs: dict[str, Any] | None = ..., voxels: bool = ..., figsize_multiplier: float = ..., intersections: bool = ..., **imshow_kwargs: Any) -> None
Plot 3 orthogonal slices of a 3D image.
Always displays Sagittal, Coronal, Axial with fixed anatomical
positions regardless of image orientation. Data is flipped and
transposed as needed. Uses lazy Image.__getitem__ so only
the 3 requested planes are read from disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
The image to plot. |
required |
channel
|
int
|
Which channel to display. |
0
|
indices
|
tuple[int | None, int | None, int | None] | None
|
Slice index for each spatial axis. |
None
|
coordinates
|
tuple[float | None, float | None, float | None] | None
|
World coordinates in mm for each slice.
|
None
|
axes
|
Sequence[Axes] | None
|
Pre-created sequence of 3 matplotlib |
None
|
cmap
|
str | Colormap | dict[int, tuple[int, int, int]] | None
|
Colormap. Defaults to |
None
|
percentiles
|
tuple[float, float]
|
Intensity percentile range for display windowing. Ignored for label maps. |
(0.5, 99.5)
|
figsize
|
tuple[float, float] | None
|
Figure size in inches |
None
|
title
|
str | None
|
Figure super-title. |
None
|
output_path
|
TypePath | None
|
Save figure to this path. |
None
|
show
|
bool
|
Call |
True
|
savefig_kwargs
|
dict[str, Any] | None
|
Extra keyword arguments for |
None
|
voxels
|
bool
|
Show voxel indices on ticks instead of world coordinates in mm. |
False
|
figsize_multiplier
|
float
|
Scale factor applied to the default
|
2.0
|
intersections
|
bool
|
Draw coloured cross-hair lines showing where the other two slices intersect each view. |
True
|
**imshow_kwargs
|
Any
|
Forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
Figure | None
|
The matplotlib |
Figure | None
|
(the figure is displayed and closed to prevent duplicate |
Figure | None
|
rendering in notebooks). |
Source code in src/torchio/visualization.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | |
plot_subject(subject, *, channel=0, indices=None, coordinates=None, cmap_dict=None, percentiles=(0.5, 99.5), figsize=None, title=None, output_path=None, show=True, savefig_kwargs=None, voxels=False, figsize_multiplier=2.0, intersections=True, **imshow_kwargs)
plot_subject(subject: Subject, *, show: Literal[False], channel: int = ..., indices: tuple[int | None, int | None, int | None] | None = ..., coordinates: tuple[float | None, float | None, float | None] | None = ..., cmap_dict: dict[str, Any] | None = ..., percentiles: tuple[float, float] = ..., figsize: tuple[float, float] | None = ..., title: str | None = ..., output_path: TypePath | None = ..., savefig_kwargs: dict[str, Any] | None = ..., voxels: bool = ..., figsize_multiplier: float = ..., intersections: bool = ..., **imshow_kwargs: Any) -> Figure
plot_subject(subject: Subject, *, show: Literal[True] = ..., channel: int = ..., indices: tuple[int | None, int | None, int | None] | None = ..., coordinates: tuple[float | None, float | None, float | None] | None = ..., cmap_dict: dict[str, Any] | None = ..., percentiles: tuple[float, float] = ..., figsize: tuple[float, float] | None = ..., title: str | None = ..., output_path: TypePath | None = ..., savefig_kwargs: dict[str, Any] | None = ..., voxels: bool = ..., figsize_multiplier: float = ..., intersections: bool = ..., **imshow_kwargs: Any) -> None
Plot all images in a subject as a grid.
Each image gets a row (or column if >3 images) of Sagittal, Coronal, Axial views. LabelMaps are automatically detected and use categorical colormaps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject
|
Subject
|
The subject to plot. |
required |
channel
|
int
|
Which channel to display. |
0
|
indices
|
tuple[int | None, int | None, int | None] | None
|
Voxel indices for each slice. Mutually exclusive
with |
None
|
coordinates
|
tuple[float | None, float | None, float | None] | None
|
World coordinates in mm. Mutually exclusive
with |
None
|
cmap_dict
|
dict[str, Any] | None
|
Per-image colormap overrides, keyed by image name. |
None
|
percentiles
|
tuple[float, float]
|
Intensity percentile range for windowing. |
(0.5, 99.5)
|
figsize
|
tuple[float, float] | None
|
Figure size in inches. |
None
|
title
|
str | None
|
Figure super-title. |
None
|
output_path
|
TypePath | None
|
Save figure to this path. |
None
|
show
|
bool
|
Call |
True
|
savefig_kwargs
|
dict[str, Any] | None
|
Extra keyword arguments for |
None
|
voxels
|
bool
|
Show voxel ticks instead of world coordinates. |
False
|
figsize_multiplier
|
float
|
Scale factor for default figure size. |
2.0
|
intersections
|
bool
|
Draw slice intersection cross-hairs. |
True
|
**imshow_kwargs
|
Any
|
Forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
Figure | None
|
The |
Source code in src/torchio/visualization.py
597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 | |