FIX: ensure files are created in temp directory
@@ -265,22 +265,24 @@ def pass_dummy_scans(algo_dummy_scans, dummy_scans=None):
def check_valid_fs_license():
"""Quickly runs mri_convert to weed out FreeSurfer license issues"""
+ from pathlib import Path
import subprocess as sp
from tempfile import TemporaryDirectory
import nibabel as nb
import numpy as np
- with TemporaryDirectory():
- tmp_file = 'test.nii.gz'
+ with TemporaryDirectory() as tmpdir:
+ nii_file = str(Path(tmpdir) / 'test.nii.gz')
+ out_file = str(Path(tmpdir) / 'out.mgz')
# create test NIfTI
- nb.Nifti1Image(np.zeros((5, 5, 5)), np.eye(4)).to_filename(tmp_file)
+ nb.Nifti1Image(np.zeros((5, 5, 5)), np.eye(4)).to_filename(nii_file)
# quick FreeSurfer command
_cmd = (
'mri_convert',
'--out_type', 'mgz',
- '--input_volume', tmp_file,
- '--output_volume', 'out.mgz'
+ '--input_volume', nii_file,
+ '--output_volume', out_file
)
proc = sp.run(_cmd, stdout=sp.PIPE, stderr=sp.PIPE)
return "ERROR: FreeSurfer license file" not in proc.stderr.decode()
