From 76afc63102fd53bc259d3dee3d105a985fd16008 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Fri, 7 Sep 2018 15:20:46 +0100 Subject: [PATCH] BF: Make sure only the first few bytes of the image are read when detecting memmaps --- fsl/data/image.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fsl/data/image.py b/fsl/data/image.py index 7af1e6960..6d1a7e4a8 100644 --- a/fsl/data/image.py +++ b/fsl/data/image.py @@ -1171,7 +1171,9 @@ class Image(Nifti): # memory-mapped, nibabel does all of # the hard work. newnibimage = False - ismmap = isinstance(self[0, 0, :10], np.memmap) + sample = self[(slice(0, 5),) + (0,) * (len(self.shape) - 1)] + ismmap = isinstance(sample, np.memmap) + if self.__fileobj is None and (not ismmap): nib.save(self.__nibImage, filename) -- GitLab