diff --git a/fsl/data/atlases.py b/fsl/data/atlases.py index 41e7e0905afef577e62a151fd8779d404dd5e748..32e633f7edaa81a4a7ec806c548271039f06c2c7 100644 --- a/fsl/data/atlases.py +++ b/fsl/data/atlases.py @@ -84,6 +84,8 @@ def listAtlases(refresh=False): :attr:`ATLAS_DESCRIPTIONS`). """ + if ATLAS_DIR is None: + return [] if len(ATLAS_DESCRIPTIONS) == 0: refresh = True @@ -109,6 +111,9 @@ def getAtlasDescription(atlasID): """Returns an :class:`AtlasDescription` instance describing the atlas with the given ``atlasID``. """ + + if ATLAS_DIR is None: + return None if len(ATLAS_DESCRIPTIONS) == 0: listAtlases() @@ -124,6 +129,9 @@ def loadAtlas(atlasID, loadSummary=False): loaded. Otherwise, if the atlas is probabilistic, a 4D :class:`ProbabilisticAtlas` image is loaded. """ + + if ATLAS_DIR is None: + return None if len(ATLAS_DESCRIPTIONS) == 0: listAtlases() diff --git a/fsl/fslview/controls/imageselectpanel.py b/fsl/fslview/controls/imageselectpanel.py index 4d0793b2c1ab830bfa6382ffbf2b5cc459c3fcac..4ba65e62fc1dc545278a51189c24a721ba45718c 100644 --- a/fsl/fslview/controls/imageselectpanel.py +++ b/fsl/fslview/controls/imageselectpanel.py @@ -163,11 +163,13 @@ class ImageSelectPanel(fslpanel.FSLViewPanel): allImages = self._displayCtx.getOrderedImages() image = self._displayCtx.getSelectedImage() - idx = allImages.index(image) nimgs = len(allImages) + + if nimgs > 0: idx = allImages.index(image) + else: idx = -1 - self._prevButton.Enable(nimgs > 0 and idx != 0) - self._nextButton.Enable(nimgs > 0 and idx != nimgs - 1) + self._prevButton.Enable(nimgs > 0 and idx > 0) + self._nextButton.Enable(nimgs > 0 and idx < nimgs - 1) if self._imageLabel is None: return