@@ -42,7 +42,7 @@ class OrthoSlicer3D(object):
42
42
"""
43
43
# Skip doctest above b/c not all systems have mpl installed
44
44
45
- def __init__ (self , data , affine = None , axes = None , title = None ):
45
+ def __init__ (self , data , affine = None , axes = None , title = None , vlim = None ):
46
46
"""
47
47
Parameters
48
48
----------
@@ -61,6 +61,9 @@ def __init__(self, data, affine=None, axes=None, title=None):
61
61
title : str or None, optional
62
62
The title to display. Can be None (default) to display no
63
63
title.
64
+ vlim : array-like or None, optional
65
+ Value limits to display image and time series. Can be None
66
+ (default) to derive limits from data.
64
67
"""
65
68
# Use these late imports of matplotlib so that we have some hope that
66
69
# the test functions are the first to set the matplotlib backend. The
@@ -90,7 +93,7 @@ def __init__(self, data, affine=None, axes=None, title=None):
90
93
self ._volume_dims = data .shape [3 :]
91
94
self ._current_vol_data = data [:, :, :, 0 ] if data .ndim > 3 else data
92
95
self ._data = data
93
- self ._clim = np .percentile (data , (1. , 99. ))
96
+ self ._clim = np .percentile (data , (1. , 99. )) if vlim is None else vlim
94
97
del data
95
98
96
99
if axes is None : # make the axes
@@ -183,8 +186,11 @@ def __init__(self, data, affine=None, axes=None, title=None):
183
186
ax .set_xticks (np .unique (np .linspace (0 , self .n_volumes - 1 ,
184
187
5 ).astype (int )))
185
188
ax .set_xlim (x [0 ], x [- 1 ])
186
- yl = [self ._data .min (), self ._data .max ()]
187
- yl = [l + s * np .diff (lims )[0 ] for l , s in zip (yl , [- 1.01 , 1.01 ])]
189
+ if vlim is None :
190
+ yl = [self ._data .min (), self ._data .max ()]
191
+ yl = [l + s * np .diff (lims )[0 ] for l , s in zip (yl , [- 1.01 , 1.01 ])]
192
+ else :
193
+ yl = vlim
188
194
patch = mpl_patch .Rectangle ([- 0.5 , yl [0 ]], 1. , np .diff (yl )[0 ],
189
195
fill = True , facecolor = (0 , 1 , 0 ),
190
196
edgecolor = (0 , 1 , 0 ), alpha = 0.25 )
0 commit comments