Skip to content

Commit 1a2e959

Browse files
committed
DOC: Use explicit args in SpatialImage.orthoview
TEST: Test vlim functionality
1 parent 072c176 commit 1a2e959

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

nibabel/spatialimages.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,18 @@ def __getitem__(self, idx):
574574
"slicing image array data with `img.dataobj[slice]` or "
575575
"`img.get_data()[slice]`")
576576

577-
def orthoview(self, **kwargs):
577+
def orthoview(self, axes=None, vlim=None):
578578
"""Plot the image using OrthoSlicer3D
579579
580+
Parameters
581+
------------------
582+
axes : tuple of mpl.Axes or None, optional
583+
3 or 4 axes instances for the 3 slices plus volumes,
584+
or None (default).
585+
vlim : array-like or None, optional
586+
Value limits to display image and time series. Can be None
587+
(default) to derive limits from data.
588+
580589
Returns
581590
-------
582591
viewer : instance of OrthoSlicer3D
@@ -588,8 +597,8 @@ def orthoview(self, **kwargs):
588597
consider using viewer.show() (equivalently plt.show()) to show
589598
the figure.
590599
"""
591-
return OrthoSlicer3D(self.dataobj, self.affine,
592-
title=self.get_filename(), **kwargs)
600+
return OrthoSlicer3D(self.dataobj, self.affine, axes=axes,
601+
title=self.get_filename(), vlim=vlim)
593602

594603
def as_reoriented(self, ornt):
595604
"""Apply an orientation change and return a new image

nibabel/tests/test_viewers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ def test_viewer():
6868
v.close()
6969
v._draw() # should be safe
7070

71+
# Manually set value limits
72+
vlim = np.array([-20, 20])
73+
v = OrthoSlicer3D(data, vlim=vlim)
74+
assert_array_equal(v._clim, vlim)
75+
for im in v._ims:
76+
assert_array_equal(im.get_clim(), vlim)
77+
assert_array_equal(v._axes[3].get_ylim(), vlim)
78+
7179
# non-multi-volume
7280
v = OrthoSlicer3D(data[:, :, :, 0])
7381
v._on_scroll(nt('event', 'button inaxes key')('up', v._axes[0], 'shift'))

0 commit comments

Comments
 (0)