Skip to content

Commit 362c835

Browse files
committed
DOC: Use explicit args in SpatialImage.orthoview
TEST: Test vlim functionality
1 parent 3193506 commit 362c835

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
@@ -663,9 +663,18 @@ def __getitem__(self):
663663
"array data with `img.dataobj[slice]` or "
664664
"`img.get_data()[slice]`")
665665

666-
def orthoview(self, **kwargs):
666+
def orthoview(self, axes=None, vlim=None):
667667
"""Plot the image using OrthoSlicer3D
668668
669+
Parameters
670+
------------------
671+
axes : tuple of mpl.Axes or None, optional
672+
3 or 4 axes instances for the 3 slices plus volumes,
673+
or None (default).
674+
vlim : array-like or None, optional
675+
Value limits to display image and time series. Can be None
676+
(default) to derive limits from data.
677+
669678
Returns
670679
-------
671680
viewer : instance of OrthoSlicer3D
@@ -677,5 +686,5 @@ def orthoview(self, **kwargs):
677686
consider using viewer.show() (equivalently plt.show()) to show
678687
the figure.
679688
"""
680-
return OrthoSlicer3D(self.dataobj, self.affine,
681-
title=self.get_filename(), **kwargs)
689+
return OrthoSlicer3D(self.dataobj, self.affine, axes=axes,
690+
title=self.get_filename(), vlim=vlim)

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)