From d8231fe28494a3d0f2a3461fe49d7dbf8dd8d4be Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Thu, 12 Dec 2019 10:26:40 +0000
Subject: [PATCH] RF: Don't use get_data

---
 fsl/data/dicom.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fsl/data/dicom.py b/fsl/data/dicom.py
index d38d2081d..51c750385 100644
--- a/fsl/data/dicom.py
+++ b/fsl/data/dicom.py
@@ -36,6 +36,7 @@ import               shlex
 import               logging
 import               binascii
 
+import numpy      as np
 import nibabel    as nib
 
 import fsl.utils.tempdir as tempdir
@@ -279,9 +280,11 @@ def loadSeries(series):
 
         # copy images so nibabel no longer
         # refs to the files (as they will
-        # be deleted), and use get_data()
-        # to force-load the image data.
-        images = [nib.Nifti1Image(i.get_data(), None, i.header)
+        # be deleted), and force-load the
+        # the image data into memory (to
+        # avoid any disk accesses due to
+        # e.g. memmap)
+        images = [nib.Nifti1Image(np.asanyarray(i.dataobj), None, i.header)
                   for i in images]
 
         return [DicomImage(i, series, dcmdir, name=desc) for i in images]
-- 
GitLab