55"""
66Pytest fixtures used in tests.
77"""
8+ from __future__ import print_function , division , unicode_literals , absolute_import
9+
810
911import os
1012import pytest
1113import numpy as np
12-
1314import nibabel as nb
15+
16+ from io import open
17+ from builtins import str
18+
1419from nipype .interfaces .fsl import Info
1520from nipype .interfaces .fsl .base import FSLCommand
1621
@@ -25,12 +30,13 @@ def analyze_pair_image_files(outdir, filelist, shape):
2530
2631
2732def 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