Skip to content

Commit 751b0d5

Browse files
committed
BUG: xyz locations not correctly used
1 parent 41f2dd3 commit 751b0d5

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

ants/viz/plot.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,7 @@ def plot_ortho(
15471547
flat=False,
15481548
transparent=True,
15491549
resample=False,
1550+
allow_xyz_change=True,
15501551
):
15511552
"""
15521553
Plot an orthographic view of a 3D image
@@ -1564,13 +1565,8 @@ def plot_ortho(
15641565
overlay : ANTsImage
15651566
image to overlay on base image
15661567
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-
15731568
xyz : list or tuple of 3 integers
1569+
selects index location on which to center display
15741570
if given, solid lines will be drawn to converge at this coordinate.
15751571
This is useful for pinpointing a specific location in the image.
15761572
@@ -1656,6 +1652,8 @@ def plot_ortho(
16561652
16571653
resample : resample image in case of unbalanced spacing
16581654
1655+
allow_xyz_change : boolean will attempt to adjust xyz after padding
1656+
16591657
Example
16601658
-------
16611659
>>> import ants
@@ -1743,6 +1741,7 @@ def reorient_slice(x, axis):
17431741
int(sl * (sold / snew)) for sl, sold, snew in zip(xyz, spacing, new_spacing)
17441742
]
17451743

1744+
17461745
# potentially crop image
17471746
if crop:
17481747
plotmask = image.get_mask(cleanup=0)
@@ -1753,10 +1752,13 @@ def reorient_slice(x, axis):
17531752
overlay = overlay.crop_image(plotmask)
17541753

17551754
# 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+
17601762

17611763
# handle `domain_image_map` argument
17621764
if domain_image_map is not None:
@@ -1830,8 +1832,10 @@ def reorient_slice(x, axis):
18301832
)
18311833

18321834
# pad image to have isotropic array dimensions
1835+
imageReturn = image.clone()
18331836
image = image.numpy()
18341837
if overlay is not None:
1838+
overlayReturn = overlay.clone()
18351839
overlay = overlay.numpy()
18361840
if overlay.dtype not in ["uint8", "uint32"]:
18371841
overlay[np.abs(overlay) == 0] = np.nan
@@ -2087,6 +2091,7 @@ def reorient_slice(x, axis):
20872091

20882092
# turn warnings back to default
20892093
warnings.simplefilter("default")
2094+
return { "image": imageReturn, "overlay": overlayReturn }
20902095

20912096

20922097
def plot(

0 commit comments

Comments
 (0)