Skip to content

Commit df4fefc

Browse files
committed
ENH: Enable percentile value limits
1 parent 6e7b44d commit df4fefc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

nibabel/viewers.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def __init__(self, data, affine=None, axes=None, title=None, vlim=None,
6464
title.
6565
vlim : array-like or None, optional
6666
Value limits to display image and time series. Can be None
67-
(default) to derive limits from data.
67+
(default) to derive limits from data. Bounds can be of the
68+
form ``'x%'`` to use the ``x`` percentile of the data.
6869
slicer : object or None
6970
Something that can be used to slice an array as in
7071
``arr[sliceobj]``. Can be None (default) to display all data.
@@ -87,6 +88,13 @@ def __init__(self, data, affine=None, axes=None, title=None, vlim=None,
8788
affine = np.array(affine, float) if affine is not None else np.eye(4)
8889
if affine.shape != (4, 4):
8990
raise ValueError('affine must be a 4x4 matrix')
91+
92+
if vlim is not None:
93+
vlim = [float(lim[:-1]) / 100
94+
if isinstance(lim, str) and lim.endswith('%')
95+
else lim
96+
for lim in vlim]
97+
9098
# determine our orientation
9199
self._affine = affine
92100
codes = axcodes2ornt(aff2axcodes(self._affine))

0 commit comments

Comments
 (0)