Skip to content

Commit 0e30c15

Browse files
committed
DOC: Use explicit args in SpatialImage.orthoview
TEST: Test vlim functionality
1 parent 160bab4 commit 0e30c15

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
@@ -589,9 +589,18 @@ def __getitem__(self, idx):
589589
"slicing image array data with `img.dataobj[slice]` or "
590590
"`img.get_data()[slice]`")
591591

592-
def orthoview(self, **kwargs):
592+
def orthoview(self, axes=None, vlim=None):
593593
"""Plot the image using OrthoSlicer3D
594594
595+
Parameters
596+
------------------
597+
axes : tuple of mpl.Axes or None, optional
598+
3 or 4 axes instances for the 3 slices plus volumes,
599+
or None (default).
600+
vlim : array-like or None, optional
601+
Value limits to display image and time series. Can be None
602+
(default) to derive limits from data.
603+
595604
Returns
596605
-------
597606
viewer : instance of OrthoSlicer3D
@@ -603,8 +612,8 @@ def orthoview(self, **kwargs):
603612
consider using viewer.show() (equivalently plt.show()) to show
604613
the figure.
605614
"""
606-
return OrthoSlicer3D(self.dataobj, self.affine,
607-
title=self.get_filename(), **kwargs)
615+
return OrthoSlicer3D(self.dataobj, self.affine, axes=axes,
616+
title=self.get_filename(), vlim=vlim)
608617

609618
def as_reoriented(self, ornt):
610619
"""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)