Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 25b46b1

Browse files
Merge pull request #1831 from effigies/bug/mmap
FIX: Import NUMPY_MMAP inside functions
2 parents 102d8d7 + 72cb924 commit 25b46b1

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

‎nipype/interfaces/dipy/preprocess.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from ... import logging
1717
from ..base import (traits, TraitedSpec, File, isdefined)
1818
from .base import DipyBaseInterface
19-
from ...utils import NUMPY_MMAP
2019

2120
IFLOGGER = logging.getLogger('interface')
2221

@@ -180,6 +179,7 @@ def resample_proxy(in_file, order=3, new_zooms=None, out_file=None):
180179
Performs regridding of an image to set isotropic voxel sizes using dipy.
181180
"""
182181
from dipy.align.reslice import reslice
182+
from nipype.utils import NUMPY_MMAP
183183

184184
if out_file is None:
185185
fname, fext = op.splitext(op.basename(in_file))
@@ -223,6 +223,7 @@ def nlmeans_proxy(in_file, settings,
223223
from dipy.denoise.nlmeans import nlmeans
224224
from scipy.ndimage.morphology import binary_erosion
225225
from scipy import ndimage
226+
from nipype.utils import NUMPY_MMAP
226227

227228
if out_file is None:
228229
fname, fext = op.splitext(op.basename(in_file))

‎nipype/workflows/dmri/dipy/denoise.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# vi: set ft=python sts=4 ts=4 sw=4 et:
55

66
from builtins import range
7-
from nipype.utils import NUMPY_MMAP
87
from ....pipeline import engine as pe
98
from ....interfaces import utility as niu
109
from ....interfaces import dipy
@@ -57,6 +56,7 @@ def csf_mask(in_file, in_mask, out_file=None):
5756
from scipy.ndimage import binary_erosion, binary_opening, label
5857
import scipy.ndimage as nd
5958
import os.path as op
59+
from nipype.utils import NUMPY_MMAP
6060

6161
if out_file is None:
6262
fname, ext = op.splitext(op.basename(in_file))
@@ -100,6 +100,7 @@ def bg_mask(in_file, in_mask, out_file=None):
100100
from scipy.ndimage import binary_dilation
101101
import scipy.ndimage as nd
102102
import os.path as op
103+
from nipype.utils import NUMPY_MMAP
103104

104105
if out_file is None:
105106
fname, ext = op.splitext(op.basename(in_file))

‎nipype/workflows/dmri/fsl/epi.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import warnings
77

8-
from nipype.utils import NUMPY_MMAP
98
from ....pipeline import engine as pe
109
from ....interfaces import utility as niu
1110
from ....interfaces import fsl as fsl
@@ -722,6 +721,7 @@ def _prepare_phasediff(in_file):
722721
import nibabel as nb
723722
import os
724723
import numpy as np
724+
from nipype.utils import NUMPY_MMAP
725725
img = nb.load(in_file, mmap=NUMPY_MMAP)
726726
max_diff = np.max(img.get_data().reshape(-1))
727727
min_diff = np.min(img.get_data().reshape(-1))
@@ -741,6 +741,7 @@ def _dilate_mask(in_file, iterations=4):
741741
import nibabel as nb
742742
import scipy.ndimage as ndimage
743743
import os
744+
from nipype.utils import NUMPY_MMAP
744745
img = nb.load(in_file, mmap=NUMPY_MMAP)
745746
img._data = ndimage.binary_dilation(img.get_data(), iterations=iterations)
746747

@@ -756,6 +757,7 @@ def _fill_phase(in_file):
756757
import nibabel as nb
757758
import os
758759
import numpy as np
760+
from nipype.utils import NUMPY_MMAP
759761
img = nb.load(in_file, mmap=NUMPY_MMAP)
760762
dumb_img = nb.Nifti1Image(np.zeros(img.shape), img.affine, img.header)
761763
out_nii = nb.funcs.concat_images((img, dumb_img))
@@ -772,6 +774,7 @@ def _vsm_remove_mean(in_file, mask_file, in_unwarped):
772774
import os
773775
import numpy as np
774776
import numpy.ma as ma
777+
from nipype.utils import NUMPY_MMAP
775778
img = nb.load(in_file, mmap=NUMPY_MMAP)
776779
msk = nb.load(mask_file, mmap=NUMPY_MMAP).get_data()
777780
img_data = img.get_data()
@@ -794,6 +797,7 @@ def _ms2sec(val):
794797
def _split_dwi(in_file):
795798
import nibabel as nb
796799
import os
800+
from nipype.utils import NUMPY_MMAP
797801
out_files = []
798802
frames = nb.funcs.four_to_three(nb.load(in_file, mmap=NUMPY_MMAP))
799803
name, fext = os.path.splitext(os.path.basename(in_file))

‎nipype/workflows/dmri/fsl/tbss.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
import os
66
from warnings import warn
77

8-
from nipype.utils import NUMPY_MMAP
98
from ....pipeline import engine as pe
109
from ....interfaces import utility as util
1110
from ....interfaces import fsl as fsl
1211

1312

1413
def tbss1_op_string(in_files):
1514
import nibabel as nb
15+
from nipype.utils import NUMPY_MMAP
1616
op_strings = []
1717
for infile in in_files:
1818
img = nb.load(infile, mmap=NUMPY_MMAP)

‎nipype/workflows/dmri/fsl/utils.py‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from __future__ import print_function, division, unicode_literals, absolute_import
77
from builtins import zip, next, range, str
88

9-
from nipype.utils import NUMPY_MMAP
10-
119
from ....pipeline import engine as pe
1210
from ....interfaces import utility as niu
1311
from ....interfaces import fsl
@@ -209,6 +207,7 @@ def extract_bval(in_dwi, in_bval, b=0, out_file=None):
209207
import numpy as np
210208
import nibabel as nb
211209
import os.path as op
210+
from nipype.utils import NUMPY_MMAP
212211

213212
if out_file is None:
214213
fname, ext = op.splitext(op.basename(in_dwi))
@@ -244,6 +243,7 @@ def hmc_split(in_file, in_bval, ref_num=0, lowbval=5.0):
244243
import nibabel as nb
245244
import os.path as op
246245
from nipype.interfaces.base import isdefined
246+
from nipype.utils import NUMPY_MMAP
247247

248248
im = nb.load(in_file, mmap=NUMPY_MMAP)
249249
data = im.get_data()
@@ -288,6 +288,7 @@ def remove_comp(in_file, in_bval, volid=0, out_file=None):
288288
import numpy as np
289289
import nibabel as nb
290290
import os.path as op
291+
from nipype.utils import NUMPY_MMAP
291292

292293
if out_file is None:
293294
fname, ext = op.splitext(op.basename(in_file))
@@ -337,6 +338,7 @@ def recompose_dwi(in_dwi, in_bval, in_corrected, out_file=None):
337338
import numpy as np
338339
import nibabel as nb
339340
import os.path as op
341+
from nipype.utils import NUMPY_MMAP
340342

341343
if out_file is None:
342344
fname, ext = op.splitext(op.basename(in_dwi))
@@ -397,6 +399,7 @@ def time_avg(in_file, index=[0], out_file=None):
397399
import numpy as np
398400
import nibabel as nb
399401
import os.path as op
402+
from nipype.utils import NUMPY_MMAP
400403

401404
if out_file is None:
402405
fname, ext = op.splitext(op.basename(in_file))
@@ -444,6 +447,7 @@ def b0_average(in_dwi, in_bval, max_b=10.0, out_file=None):
444447
import numpy as np
445448
import nibabel as nb
446449
import os.path as op
450+
from nipype.utils import NUMPY_MMAP
447451

448452
if out_file is None:
449453
fname, ext = op.splitext(op.basename(in_dwi))
@@ -623,6 +627,7 @@ def rads2radsec(in_file, delta_te, out_file=None):
623627
import nibabel as nb
624628
import os.path as op
625629
import math
630+
from nipype.utils import NUMPY_MMAP
626631

627632
if out_file is None:
628633
fname, fext = op.splitext(op.basename(in_file))
@@ -644,6 +649,7 @@ def demean_image(in_file, in_mask=None, out_file=None):
644649
import nibabel as nb
645650
import os.path as op
646651
import math
652+
from nipype.utils import NUMPY_MMAP
647653

648654
if out_file is None:
649655
fname, fext = op.splitext(op.basename(in_file))
@@ -674,6 +680,7 @@ def add_empty_vol(in_file, out_file=None):
674680
import os.path as op
675681
import numpy as np
676682
import math
683+
from nipype.utils import NUMPY_MMAP
677684

678685
if out_file is None:
679686
fname, fext = op.splitext(op.basename(in_file))
@@ -696,6 +703,7 @@ def reorient_bvecs(in_dwi, old_dwi, in_bvec):
696703
import os
697704
import numpy as np
698705
import nibabel as nb
706+
from nipype.utils import NUMPY_MMAP
699707

700708
name, fext = os.path.splitext(os.path.basename(in_bvec))
701709
if fext == '.gz':
@@ -721,6 +729,7 @@ def copy_hdr(in_file, in_file_hdr, out_file=None):
721729
import numpy as np
722730
import nibabel as nb
723731
import os.path as op
732+
from nipype.utils import NUMPY_MMAP
724733

725734
if out_file is None:
726735
fname, fext = op.splitext(op.basename(in_file))
@@ -744,6 +753,7 @@ def enhance(in_file, clip_limit=0.010, in_mask=None, out_file=None):
744753
import nibabel as nb
745754
import os.path as op
746755
from skimage import exposure, img_as_int
756+
from nipype.utils import NUMPY_MMAP
747757

748758
if out_file is None:
749759
fname, fext = op.splitext(op.basename(in_file))

‎nipype/workflows/misc/utils.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
from __future__ import print_function, division, unicode_literals, absolute_import
55

66
from builtins import map, range
7-
from nipype.utils import NUMPY_MMAP
87

98

109
def get_vox_dims(volume):
1110
import nibabel as nb
11+
from nipype.utils import NUMPY_MMAP
1212
if isinstance(volume, list):
1313
volume = volume[0]
1414
nii = nb.load(volume, mmap=NUMPY_MMAP)
@@ -19,6 +19,7 @@ def get_vox_dims(volume):
1919

2020
def get_data_dims(volume):
2121
import nibabel as nb
22+
from nipype.utils import NUMPY_MMAP
2223
if isinstance(volume, list):
2324
volume = volume[0]
2425
nii = nb.load(volume, mmap=NUMPY_MMAP)
@@ -29,6 +30,7 @@ def get_data_dims(volume):
2930

3031
def get_affine(volume):
3132
import nibabel as nb
33+
from nipype.utils import NUMPY_MMAP
3234
nii = nb.load(volume, mmap=NUMPY_MMAP)
3335
return nii.affine
3436

@@ -50,6 +52,7 @@ def select_aparc_annot(list_of_files):
5052
def region_list_from_volume(in_file):
5153
import nibabel as nb
5254
import numpy as np
55+
from nipype.utils import NUMPY_MMAP
5356
segmentation = nb.load(in_file, mmap=NUMPY_MMAP)
5457
segmentationdata = segmentation.get_data()
5558
rois = np.unique(segmentationdata)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /