Skip to content

Commit 875ed0b

Browse files
committed
the last nibabel.load without NUMPY_MMAP
1 parent 05d74ec commit 875ed0b

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

examples/fmri_fsl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,11 @@ def pickfirst(files):
106106

107107
def getmiddlevolume(func):
108108
from nibabel import load
109+
from nipype.utils import NUMPY_MMAP
109110
funcfile = func
110111
if isinstance(func, list):
111112
funcfile = func[0]
112-
_, _, _, timepoints = load(funcfile).shape
113+
_, _, _, timepoints = load(funcfile, mmap=NUMPY_MMAP).shape
113114
return int(timepoints / 2) - 1
114115

115116
preproc.connect(inputnode, ('func', getmiddlevolume), extract_ref, 't_min')

nipype/algorithms/rapidart.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from scipy import signal
3030
import scipy.io as sio
3131

32+
from ..utils import NUMPY_MMAP
3233
from ..interfaces.base import (BaseInterface, traits, InputMultiPath,
3334
OutputMultiPath, TraitedSpec, File,
3435
BaseInterfaceInputSpec, isdefined)
@@ -352,12 +353,12 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None):
352353

353354
# read in functional image
354355
if isinstance(imgfile, (str, bytes)):
355-
nim = load(imgfile)
356+
nim = load(imgfile, mmap=NUMPY_MMAP)
356357
elif isinstance(imgfile, list):
357358
if len(imgfile) == 1:
358-
nim = load(imgfile[0])
359+
nim = load(imgfile[0], mmap=NUMPY_MMAP)
359360
else:
360-
images = [load(f) for f in imgfile]
361+
images = [load(f, mmap=NUMPY_MMAP) for f in imgfile]
361362
nim = funcs.concat_images(images)
362363

363364
# compute global intensity signal
@@ -394,7 +395,7 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None):
394395
mask[:, :, :, t0] = mask_tmp
395396
g[t0] = np.nansum(vol * mask_tmp) / np.nansum(mask_tmp)
396397
elif masktype == 'file': # uses a mask image to determine intensity
397-
maskimg = load(self.inputs.mask_file)
398+
maskimg = load(self.inputs.mask_file, mmap=NUMPY_MMAP)
398399
mask = maskimg.get_data()
399400
affine = maskimg.affine
400401
mask = mask > 0.5

nipype/interfaces/spm/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
# Local imports
3030
from ... import logging
31-
from ...utils import spm_docs as sd
31+
from ...utils import spm_docs as sd, NUMPY_MMAP
3232
from ..base import (BaseInterface, traits, isdefined, InputMultiPath,
3333
BaseInterfaceInputSpec, Directory, Undefined)
3434
from ..matlab import MatlabCommand
@@ -45,7 +45,7 @@ def func_is_3d(in_file):
4545
if isinstance(in_file, list):
4646
return func_is_3d(in_file[0])
4747
else:
48-
img = load(in_file)
48+
img = load(in_file, mmap=NUMPY_MMAP)
4949
shape = img.shape
5050
if len(shape) == 3 or (len(shape) == 4 and shape[3] == 1):
5151
return True
@@ -73,7 +73,7 @@ def scans_for_fname(fname):
7373
for sno, f in enumerate(fname):
7474
scans[sno] = '%s,1' % f
7575
return scans
76-
img = load(fname)
76+
img = load(fname, mmap=NUMPY_MMAP)
7777
if len(img.shape) == 3:
7878
return np.array(('%s,1' % fname,), dtype=object)
7979
else:

0 commit comments

Comments
 (0)