Skip to content
Snippets Groups Projects
Commit d4a505f2 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

BF,ENH: ImageWrapper and naninfrange have support for structured

arrays (e.g. RGB data)
parent 424d0e18
No related branches found
No related tags found
No related merge requests found
......@@ -303,9 +303,11 @@ class ImageWrapper(notifier.Notifier):
# data range for each volume/slice/vector
#
# We use nan as a placeholder, so the
# dtype must be non-integral
# dtype must be non-integral. The
# len(dtype) check takes into account
# structured data (e.g. RGB)
dtype = self.__image.get_data_dtype()
if np.issubdtype(dtype, np.integer):
if np.issubdtype(dtype, np.integer) or len(dtype) > 0:
dtype = np.float32
self.__volRanges = np.zeros((nvols, 2),
dtype=dtype)
......
......@@ -23,6 +23,12 @@ def naninfrange(data):
use an alternate approach to calculating the minimum/maximum.
"""
# For structured arrays, we assume that
# all fields are numeric, and we simply
# take the range across all fields
if len(data.dtype) > 0:
data = np.concatenate([data[n] for n in data.dtype.names])
if not np.issubdtype(data.dtype, np.floating):
return data.min(), data.max()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment