@@ -1547,6 +1547,7 @@ def plot_ortho(
1547
1547
flat = False ,
1548
1548
transparent = True ,
1549
1549
resample = False ,
1550
+ allow_xyz_change = True ,
1550
1551
):
1551
1552
"""
1552
1553
Plot an orthographic view of a 3D image
@@ -1564,13 +1565,8 @@ def plot_ortho(
1564
1565
overlay : ANTsImage
1565
1566
image to overlay on base image
1566
1567
1567
- slices : list or tuple of 3 integers
1568
- slice indices along each axis to plot
1569
- This can be absolute array indices (e.g. (80,100,120)), or
1570
- this can be relative array indices (e.g. (0.4,0.5,0.6)).
1571
- The default is to take the middle slice along each axis.
1572
-
1573
1568
xyz : list or tuple of 3 integers
1569
+ selects index location on which to center display
1574
1570
if given, solid lines will be drawn to converge at this coordinate.
1575
1571
This is useful for pinpointing a specific location in the image.
1576
1572
@@ -1656,6 +1652,8 @@ def plot_ortho(
1656
1652
1657
1653
resample : resample image in case of unbalanced spacing
1658
1654
1655
+ allow_xyz_change : boolean will attempt to adjust xyz after padding
1656
+
1659
1657
Example
1660
1658
-------
1661
1659
>>> import ants
@@ -1743,6 +1741,7 @@ def reorient_slice(x, axis):
1743
1741
int (sl * (sold / snew )) for sl , sold , snew in zip (xyz , spacing , new_spacing )
1744
1742
]
1745
1743
1744
+
1746
1745
# potentially crop image
1747
1746
if crop :
1748
1747
plotmask = image .get_mask (cleanup = 0 )
@@ -1753,10 +1752,13 @@ def reorient_slice(x, axis):
1753
1752
overlay = overlay .crop_image (plotmask )
1754
1753
1755
1754
# pad images
1756
- image , lowpad , uppad = image .pad_image (return_padvals = True )
1757
- xyz = [v + l for v , l in zip (xyz , lowpad )]
1758
- if overlay is not None :
1759
- overlay = overlay .pad_image ()
1755
+ if True :
1756
+ image , lowpad , uppad = image .pad_image (return_padvals = True )
1757
+ if allow_xyz_change :
1758
+ xyz = [v + l for v , l in zip (xyz , lowpad )]
1759
+ if overlay is not None :
1760
+ overlay = overlay .pad_image ()
1761
+
1760
1762
1761
1763
# handle `domain_image_map` argument
1762
1764
if domain_image_map is not None :
@@ -1830,8 +1832,10 @@ def reorient_slice(x, axis):
1830
1832
)
1831
1833
1832
1834
# pad image to have isotropic array dimensions
1835
+ imageReturn = image .clone ()
1833
1836
image = image .numpy ()
1834
1837
if overlay is not None :
1838
+ overlayReturn = overlay .clone ()
1835
1839
overlay = overlay .numpy ()
1836
1840
if overlay .dtype not in ["uint8" , "uint32" ]:
1837
1841
overlay [np .abs (overlay ) == 0 ] = np .nan
@@ -2087,6 +2091,7 @@ def reorient_slice(x, axis):
2087
2091
2088
2092
# turn warnings back to default
2089
2093
warnings .simplefilter ("default" )
2094
+ return { "image" : imageReturn , "overlay" : overlayReturn }
2090
2095
2091
2096
2092
2097
def plot (
0 commit comments