Skip to content

Commit c371f8b

Browse files
committed
DOC: Use explicit args in SpatialImage.orthoview
TEST: Test vlim functionality
1 parent ea73d23 commit c371f8b

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
@@ -572,9 +572,18 @@ def __getitem__(self, idx):
572572
"array data with `img.dataobj[slice]` or "
573573
"`img.get_data()[slice]`")
574574

575-
def orthoview(self, **kwargs):
575+
def orthoview(self, axes=None, vlim=None):
576576
"""Plot the image using OrthoSlicer3D
577577
578+
Parameters
579+
------------------
580+
axes : tuple of mpl.Axes or None, optional
581+
3 or 4 axes instances for the 3 slices plus volumes,
582+
or None (default).
583+
vlim : array-like or None, optional
584+
Value limits to display image and time series. Can be None
585+
(default) to derive limits from data.
586+
578587
Returns
579588
-------
580589
viewer : instance of OrthoSlicer3D
@@ -586,8 +595,8 @@ def orthoview(self, **kwargs):
586595
consider using viewer.show() (equivalently plt.show()) to show
587596
the figure.
588597
"""
589-
return OrthoSlicer3D(self.dataobj, self.affine,
590-
title=self.get_filename(), **kwargs)
598+
return OrthoSlicer3D(self.dataobj, self.affine, axes=axes,
599+
title=self.get_filename(), vlim=vlim)
591600

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