From ff3e8133cf816df3b380e703ac1acb80b3c4ff40 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Tue, 27 Feb 2018 16:32:52 +0000
Subject: [PATCH] New module fsl.utils.ensure, which ensures things.

---
 fsl/utils/ensure.py | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 fsl/utils/ensure.py

diff --git a/fsl/utils/ensure.py b/fsl/utils/ensure.py
new file mode 100644
index 000000000..eb3368e4b
--- /dev/null
+++ b/fsl/utils/ensure.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+#
+# ensure.py - Functions which ensure things.
+#
+# Author: Paul McCarthy <pauldmccarthy@gmail.com>
+#
+"""This module contains a handful of utility functions which attempt to ensure
+that some condition is met.
+
+.. autosummary::
+   :nosignatures:
+
+   ensureIsImage
+"""
+
+
+import six
+
+import nibabel as nib
+
+
+def ensureIsImage(img):
+    """Ensures that the given ``img`` is an in-memory ``nibabel`` object.
+    """
+    if isinstance(img, six.string_types):
+        img = nib.load(img)
+    return img
-- 
GitLab