5
5
"""
6
6
Pytest fixtures used in tests.
7
7
"""
8
+ from __future__ import print_function , division , unicode_literals , absolute_import
9
+
8
10
9
11
import os
10
12
import pytest
11
13
import numpy as np
12
-
13
14
import nibabel as nb
15
+
16
+ from io import open
17
+ from builtins import str
18
+
14
19
from nipype .interfaces .fsl import Info
15
20
from nipype .interfaces .fsl .base import FSLCommand
16
21
@@ -25,12 +30,13 @@ def analyze_pair_image_files(outdir, filelist, shape):
25
30
26
31
27
32
def nifti_image_files (outdir , filelist , shape ):
33
+ if not isinstance (filelist , (list , tuple )):
34
+ filelist = [filelist ]
35
+
28
36
for f in filelist :
29
- hdr = nb .Nifti1Header ()
30
- hdr .set_data_shape (shape )
31
37
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 ))
34
40
35
41
36
42
@pytest .fixture ()
@@ -88,7 +94,7 @@ def create_surf_file_in_directory(request, tmpdir):
88
94
cwd = os .getcwd ()
89
95
os .chdir (outdir )
90
96
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 ))
92
98
93
99
def change_directory ():
94
100
os .chdir (cwd )
0 commit comments