Commit a428c3e1 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

MNT: Update ensureIsImage and FileOrThing(outprefix) to accept pathlib.Path

parent cfbbd146
......@@ -13,6 +13,7 @@ that some condition is met.
ensureIsImage
"""
import pathlib
import nibabel as nib
......@@ -22,7 +23,7 @@ import fsl.data.image as fslimage
def ensureIsImage(img):
"""Ensures that the given ``img`` is an in-memory ``nibabel`` object.
"""
if isinstance(img, str):
if isinstance(img, (str, pathlib.Path)):
img = fslimage.addExt(img)
img = nib.load(img)
return img
......@@ -709,6 +709,7 @@ class FileOrThing:
- The argument value that was passed in
"""
self.__func = func
self.__prepIn = prepIn
self.__prepOut = prepOut
......@@ -874,6 +875,11 @@ class FileOrThing:
# a directory path.
if prefix is not None:
# Accept pathlib, but all the
# code below works on strings
if isinstance(prefix, pathlib.Path):
prefix = str(prefix)
# If prefix is set to LOAD,
# all generated output files
# should be loaded - we use a
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment