From 163a9b29c09924dd7e2160b60ee4dde7520707fd Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Tue, 9 Jan 2018 11:31:45 +0000 Subject: [PATCH] Bugfix to ImageWrapper.__expandCoverage - was not taking into account new expansion with nans. Also small deprecation adjustment in naninfrange --- fsl/data/imagewrapper.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fsl/data/imagewrapper.py b/fsl/data/imagewrapper.py index 0334248aa..d2aae5540 100644 --- a/fsl/data/imagewrapper.py +++ b/fsl/data/imagewrapper.py @@ -461,20 +461,22 @@ class ImageWrapper(notifier.Notifier): # coverage and data range. for exp in expansions: - data = self.__getData(exp, isTuple=True) - data = data.squeeze(squeezeDims) - + data = self.__getData(exp, isTuple=True) + data = data.squeeze(squeezeDims) vlo, vhi = exp[self.__numRealDims - 1] for vi, vol in enumerate(range(vlo, vhi)): oldvlo, oldvhi = self.__volRanges[vol, :] voldata = data[..., vi] - newvlo, newvhi = naninfrange(voldata) - if (not np.isnan(oldvlo)) and oldvlo < newvlo: newvlo = oldvlo - if (not np.isnan(oldvhi)) and oldvhi > newvhi: newvhi = oldvhi + if np.isnan(newvlo) or \ + (not np.isnan(oldvlo) and oldvlo < newvlo): + newvlo = oldvlo + if np.isnan(newvhi) or \ + (not np.isnan(oldvhi) and oldvhi > newvhi): + newvhi = oldvhi # Update the stored range and # coverage for each volume @@ -720,7 +722,7 @@ def naninfrange(data): use an alternate approach to calculating the minimum/maximum. """ - if not np.issubdtype(data.dtype, np.float): + if not np.issubdtype(data.dtype, np.floating): return data.min(), data.max() # But np.nanmin/nanmax are substantially -- GitLab