Skip to content
Snippets Groups Projects
Commit 7a05e248 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Image using Notifier.skip instead of storing its own flag.

parent 71826cc2
No related branches found
No related tags found
No related merge requests found
......@@ -479,11 +479,11 @@ class Image(Nifti, notifier.Notifier):
Nifti.__init__(self, nibImage.get_header())
self.name = name
self.__lName = '{}_{}'.format(id(self), self.name)
self.__dataSource = dataSource
self.__fileobj = fileobj
self.__nibImage = nibImage
self.__saveState = dataSource is not None
self.__suppressDataRange = False
self.__imageWrapper = imagewrapper.ImageWrapper(self.nibImage,
self.name,
loadData=loadData,
......@@ -492,9 +492,7 @@ class Image(Nifti, notifier.Notifier):
if calcRange:
self.calcRange()
self.__imageWrapper.register(
'{}_{}'.format(id(self), self.name),
self.__dataRangeChanged)
self.__imageWrapper.register(self.__lName, self.__dataRangeChanged)
def __hash__(self):
......@@ -588,8 +586,7 @@ class Image(Nifti, notifier.Notifier):
Notifies any listeners of this ``Image`` (registered through the
:class:`.Notifier` interface) on the ``'dataRange'`` topic.
"""
if not self.__suppressDataRange:
self.notify(topic='dataRange')
self.notify(topic='dataRange')
def calcRange(self, sizethres=None):
......@@ -720,13 +717,11 @@ class Image(Nifti, notifier.Notifier):
sliceobj,
values.shape))
self.__suppressDataRange = True
oldRange = self.__imageWrapper.dataRange
with self.__imageWrapper.skip(self.__lName):
self.__imageWrapper.__setitem__(sliceobj, values)
newRange = self.__imageWrapper.dataRange
self.__suppressDataRange = False
oldRange = self.__imageWrapper.dataRange
self.__imageWrapper.__setitem__(sliceobj, values)
newRange = self.__imageWrapper.dataRange
if values.size > 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment