From f36b4168858dd6f8d47fc87c39bf7f60ddb667c3 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauld.mccarthy@gmail.com>
Date: Sat, 16 Apr 2016 12:16:45 +0100
Subject: [PATCH] Helper function which does the neuro-radio test.

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

diff --git a/fsl/data/image.py b/fsl/data/image.py
index a9975f5a7..d02af981d 100644
--- a/fsl/data/image.py
+++ b/fsl/data/image.py
@@ -271,6 +271,22 @@ class Nifti1(object):
         return nib.orientations.aff2axcodes(xform, inaxes)
 
 
+    def isNeurological(self):
+        """Returns ``True`` if it looks like this ``Nifti1`` object is in
+        neurological orientation, ``False`` otherwise. This test is purely
+        based on the determinent of the voxel-to-mm transformation matrix -
+        if it has a positive determinant, the image is assumed to be in
+        neurological orientation, otherwise it is assumed to be in
+        radiological orientation.
+
+        http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FLIRT/FAQ#What_is_the_format_\
+          of_the_matrix_used_by_FLIRT.2C_and_how_does_it_relate_to_the_\
+          transformation_parameters.3F
+        """
+        import numpy.linalg as npla
+        return npla.det(self.voxToWorldMat) > 0
+
+
     def getOrientation(self, axis, xform):
         """Returns a code representing the orientation of the specified data
         axis in the coordinate system defined by the given transformation
-- 
GitLab