Skip to content

Commit ef802fd

Browse files
committed
changed use of os.unlink in favour of os.remove
1 parent 12399f3 commit ef802fd

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Next Release
22
============
33

4+
* ENH: New FSL interfaces: WarpPoints, WarpPointsToStd.
45
* ENH: FUGUE interface has been refactored to use the name_template system, 3 examples
56
added to doctests, some bugs solved.
67
* ENH: Added new interfaces (fsl.utils.WarpUtils, ConvertWarp) to fnirtfileutils and convertwarp

nipype/interfaces/fsl/utils.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,8 +1722,12 @@ class WarpPoints(CommandLine):
17221722

17231723
def __init__(self, command=None, **inputs):
17241724
self._tmpfile = None
1725+
self._in_file = None
1726+
self._outformat = None
1727+
17251728
super(WarpPoints, self).__init__(command=command, **inputs)
17261729

1730+
17271731
def _format_arg(self, name, trait_spec, value):
17281732
if name == 'out_file':
17291733
return ''
@@ -1732,6 +1736,7 @@ def _format_arg(self, name, trait_spec, value):
17321736

17331737
def _parse_inputs(self, skip=None):
17341738
import os.path as op
1739+
17351740
fname, ext = op.splitext(self.inputs.in_coords)
17361741
setattr(self, '_in_file', fname)
17371742
setattr(self, '_outformat', ext[1:])
@@ -1741,7 +1746,8 @@ def _parse_inputs(self, skip=None):
17411746

17421747
if ext in ['.vtk', '.trk']:
17431748
if self._tmpfile is None:
1744-
self._tmpfile = tempfile.NamedTemporaryFile(suffix='.txt', dir=os.getcwd()).name
1749+
self._tmpfile = tempfile.NamedTemporaryFile(suffix='.txt', dir=os.getcwd(),
1750+
delete=False).name
17451751
second_args = self._tmpfile
17461752

17471753
return first_args + [ second_args ]
@@ -1817,7 +1823,10 @@ def _run_interface(self, runtime):
18171823
newpoints = np.fromstring('\n'.join(runtime.stdout.split('\n')[1:]), sep=' ')
18181824

18191825
if not tmpfile is None:
1820-
os.unlink(tmpfile.name)
1826+
try:
1827+
os.remove(tmpfile.name)
1828+
except:
1829+
pass
18211830

18221831
out_file = self._filename_from_source('out_file')
18231832

@@ -1827,6 +1836,7 @@ def _run_interface(self, runtime):
18271836
self._coords_to_trk(newpoints, out_file)
18281837
else:
18291838
np.savetxt(out_file, newpoints.reshape(-1,3))
1839+
18301840
return runtime
18311841

18321842

0 commit comments

Comments
 (0)