Skip to content

Commit ea88c60

Browse files
committed
fixes #1829
1 parent e8d8859 commit ea88c60

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

nipype/testing/fixtures.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55
"""
66
Pytest fixtures used in tests.
77
"""
8+
from __future__ import print_function, division, unicode_literals, absolute_import
9+
810

911
import os
1012
import pytest
1113
import numpy as np
12-
1314
import nibabel as nb
15+
16+
from io import open
17+
from builtins import str
18+
1419
from nipype.interfaces.fsl import Info
1520
from nipype.interfaces.fsl.base import FSLCommand
1621

@@ -25,12 +30,13 @@ def analyze_pair_image_files(outdir, filelist, shape):
2530

2631

2732
def nifti_image_files(outdir, filelist, shape):
33+
if not isinstance(filelist, (list, tuple)):
34+
filelist = [filelist]
35+
2836
for f in filelist:
29-
hdr = nb.Nifti1Header()
30-
hdr.set_data_shape(shape)
3137
img = np.random.random(shape)
32-
nb.save(nb.Nifti1Image(img, np.eye(4), hdr),
33-
os.path.join(outdir, f))
38+
nb.Nifti1Image(img, np.eye(4), None).to_filename(
39+
os.path.join(outdir, f))
3440

3541

3642
@pytest.fixture()
@@ -88,7 +94,7 @@ def create_surf_file_in_directory(request, tmpdir):
8894
cwd = os.getcwd()
8995
os.chdir(outdir)
9096
surf = 'lh.a.nii'
91-
nifti_image_files(outdir, filelist=surf, shape=(1,100,1))
97+
nifti_image_files(outdir, filelist=surf, shape=(1, 100, 1))
9298

9399
def change_directory():
94100
os.chdir(cwd)

0 commit comments

Comments
 (0)