Skip to content

Commit 06f8f2a

Browse files
committed
fix #1829
1 parent b7b25b9 commit 06f8f2a

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

nipype/interfaces/freesurfer/tests/test_utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
# vi: set ft=python sts=4 ts=4 sw=4 et:
44
from __future__ import print_function, division, unicode_literals, absolute_import
55
from builtins import open
6-
import os
7-
6+
import os, os.path as op
87
import pytest
9-
from nipype.testing.fixtures import (create_files_in_directory_plus_dummy_file,
8+
from nipype.testing.fixtures import (create_files_in_directory_plus_dummy_file,
109
create_surf_file_in_directory)
1110

1211
from nipype.interfaces.base import TraitError

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)