From d19d4708e7cc6cb1c32f153fe92ff7499f09cdfd Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Mon, 24 Jun 2019 16:53:53 +0930
Subject: [PATCH] ENH: New Image.nvals property, for RGB/RGBA images

---
 fsl/data/image.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fsl/data/image.py b/fsl/data/image.py
index 651992c4d..417a0445c 100644
--- a/fsl/data/image.py
+++ b/fsl/data/image.py
@@ -1025,6 +1025,18 @@ class Image(Nifti):
         return self[tuple(coords)].dtype
 
 
+    @property
+    def nvals(self):
+        """Returns the number of values per voxel in this image. This will
+        usually be 1, but may be 3 or 4, for images of type
+        ``NIFTI_TYPE_RGB24`` or ``NIFTI_TYPE_RGBA32``.
+        """
+
+        nvals = len(self.dtype)
+        if nvals == 0: return 1
+        else:          return nvals
+
+
     @Nifti.voxToWorldMat.setter
     def voxToWorldMat(self, xform):
         """Overrides the :meth:`Nifti.voxToWorldMat` property setter.
-- 
GitLab