Skip to content

Commit 4e3d750

Browse files
committed
Merge pull request #1035 from duboism/fix_split_filename
Fix split filename
2 parents 6cf32b0 + e3794c2 commit 4e3d750

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
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+
* FIX: Fix split_filename behaviour when path has no file component (https://github.com/nipy/nipype/pull/1035)
45
* ENH: Updated FSL dtifit to include option for grad non-linearities (https://github.com/nipy/nipype/pull/1032)
56
* ENH: Updated Camino tracking interfaces, which can now use FSL bedpostx output.
67
New options also include choice of tracker, interpolator, stepsize and

nipype/utils/filemanip.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,8 @@ def split_filename(fname):
6161

6262
special_extensions = [".nii.gz", ".tar.gz"]
6363

64-
if fname and fname.endswith(os.path.sep):
65-
fname = fname[:-1]
66-
67-
pth, fname = os.path.split(fname)
64+
pth = os.path.dirname(fname)
65+
fname = os.path.basename(fname)
6866

6967
ext = None
7068
for special_ext in special_extensions:

nipype/utils/tests/test_filemanip.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ def test_split_filename():
2424
yield assert_equal, res, ('../usr/local', 'foo', '.nii')
2525
res = split_filename('/usr/local/foo.a.b.c.d')
2626
yield assert_equal, res, ('/usr/local', 'foo.a.b.c', '.d')
27+
res = split_filename('/usr/local/')
28+
yield assert_equal, res, ('/usr/local', '', '')
2729

2830
def test_fname_presuffix():
2931
fname = 'foo.nii'

0 commit comments

Comments
 (0)