From 5109b746e9b1f98389ac597f8a4387bc1a5de694 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauld.mccarthy@gmail.com>
Date: Wed, 9 Nov 2016 17:26:15 +0000
Subject: [PATCH] Changed LabelAtlas.label lookup return value. Jeez, messed up
 fix to previous commit.

---
 fsl/data/atlases.py   |  4 ++--
 fsl/utils/platform.py | 10 +++++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/fsl/data/atlases.py b/fsl/data/atlases.py
index 0f885e004..652064aa4 100644
--- a/fsl/data/atlases.py
+++ b/fsl/data/atlases.py
@@ -411,7 +411,7 @@ class LabelAtlas(Atlas):
         
     def label(self, worldLoc):
         """Looks up and returns the label of the region at the given world
-        location, or ``np.nan`` if the location is out of bounds.
+        location, or ``None`` if the location is out of bounds.
         """
 
         voxelLoc = transform.transform([worldLoc], self.worldToVoxMat.T)[0]
@@ -423,7 +423,7 @@ class LabelAtlas(Atlas):
            voxelLoc[0] >= self.shape[0] or \
            voxelLoc[1] >= self.shape[1] or \
            voxelLoc[2] >= self.shape[2]:
-            return np.nan        
+            return None
         
         val = self[voxelLoc[0], voxelLoc[1], voxelLoc[2]]
 
diff --git a/fsl/utils/platform.py b/fsl/utils/platform.py
index f015a9e0b..fc9c7d113 100644
--- a/fsl/utils/platform.py
+++ b/fsl/utils/platform.py
@@ -92,8 +92,16 @@ def isWidgetAlive(widget):
     
     elif platform.wxFlavour == WX_PYTHON:
         try:
-            widget.IsEnabled()
+            # GetId seems to be available on all wx
+            # objects, despite not being documented.
+            # 
+            # I was originally calling IsEnabled,
+            # but this causes segfaults if called
+            # on a wx.MenuItem from within an
+            # event handler on that menu item!
+            widget.GetId()
             return True
+        
         except wx.PyDeadObjectError:
             return False
 
-- 
GitLab