diff --git a/fsl/fsleyes/gl/slicecanvas.py b/fsl/fsleyes/gl/slicecanvas.py index f38983d671f846fc05e8696785c01cd2f1881a82..ef31b1c1eb7bac03aa3ac27c27a6853c79b42e1e 100644 --- a/fsl/fsleyes/gl/slicecanvas.py +++ b/fsl/fsleyes/gl/slicecanvas.py @@ -245,14 +245,15 @@ class SliceCanvas(props.HasProperties): :class:`.DisplayContext`, and :class:`.Display` instances, and destroys OpenGL representations of all overlays. """ - self.removeListener('zax', self.name) - self.removeListener('pos', self.name) - self.removeListener('displayBounds', self.name) - self.removeListener('showCursor', self.name) - self.removeListener('invertX', self.name) - self.removeListener('invertY', self.name) - self.removeListener('zoom', self.name) - self.removeListener('renderMode', self.name) + self.removeListener('zax', self.name) + self.removeListener('pos', self.name) + self.removeListener('displayBounds', self.name) + self.removeListener('showCursor', self.name) + self.removeListener('invertX', self.name) + self.removeListener('invertY', self.name) + self.removeListener('zoom', self.name) + self.removeListener('renderMode', self.name) + self.removeListener('resolutionLimit', self.name) self.overlayList.removeListener('overlays', self.name) self.displayCtx .removeListener('bounds', self.name) diff --git a/fsl/fsleyes/overlay.py b/fsl/fsleyes/overlay.py index a90abfc50743e7d453c74ab2365ef9a9151cc9bc..daad912f809b5c56b98acfcef985a491ff37690d 100644 --- a/fsl/fsleyes/overlay.py +++ b/fsl/fsleyes/overlay.py @@ -65,6 +65,7 @@ import os.path as op import props import fsl.data.strings as strings +import fsl.data.image as fslimage import fsl.utils.settings as fslsettings import fsl.utils.status as status import fsl.utils.async as async @@ -157,9 +158,27 @@ class OverlayList(props.HasProperties): """Returns the first overlay with the given ``name`` or ``dataSource``, or ``None`` if there is no overlay with said ``name``/``dataSource``. """ + + if name is None: + return None + for overlay in self.overlays: - if overlay.name == name or overlay.dataSource == name: + + if overlay.name == name: return overlay + + if overlay.dataSource is None: + return None + + # Ignore file extensions for NIFTI1 images. + if isinstance(overlay, fslimage.Image): + if fslimage.removeExt(overlay.dataSource) == \ + fslimage.removeExt(name): + return overlay + else: + if overlay.dataSource == name: + return overlay + return None