Skip to content
Snippets Groups Projects
Commit dba468d2 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

ENH: New function fixExt to fix image extensions.

parent 5dacef11
No related branches found
No related tags found
No related merge requests found
...@@ -1376,6 +1376,20 @@ def removeExt(filename): ...@@ -1376,6 +1376,20 @@ def removeExt(filename):
return fslpath.removeExt(filename, ALLOWED_EXTENSIONS) return fslpath.removeExt(filename, ALLOWED_EXTENSIONS)
def fixExt(filename):
"""Fix the extension of ``filename``.
For example, if a file name is passed in as ``file.nii.gz``, but the
file is actually ``file.nii``, this function will fix the file name.
If ``filename`` already exists, it is returned unchanged.
"""
if op.exists(filename):
return filename
else:
return addExt(removeExt(filename))
def defaultExt(): def defaultExt():
"""Returns the default NIFTI file extension that should be used. """Returns the default NIFTI file extension that should be used.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment