diff --git a/fsl/data/imagewrapper.py b/fsl/data/imagewrapper.py index 2b49e4af594268f49a48a5dc280c323bc45d8eda..9c4b549ea16db950fc1115d75d3905b2e2656dc4 100644 --- a/fsl/data/imagewrapper.py +++ b/fsl/data/imagewrapper.py @@ -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) diff --git a/fsl/utils/naninfrange.py b/fsl/utils/naninfrange.py index c8437c8d9b10ec8b69b6d6bb54d5292314907c17..bfb497f386499ece2aaf50708937eddc9b7810f6 100644 --- a/fsl/utils/naninfrange.py +++ b/fsl/utils/naninfrange.py @@ -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()