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

Logic for updating coverage previously in updateDataRangeOnRead moved

into a separate method, as it will probably come in handy for write
support.
parent caf473a1
No related branches found
No related tags found
No related merge requests found
...@@ -228,28 +228,12 @@ class ImageWrapper(notifier.Notifier): ...@@ -228,28 +228,12 @@ class ImageWrapper(notifier.Notifier):
shape = self.__image.shape shape = self.__image.shape
slices = zip([0] * len(shape), shape) slices = zip([0] * len(shape), shape)
return sliceCovered(slices, self.__coverage) return sliceCovered(slices, self.__coverage)
def __updateDataRangeOnRead(self, slices, data):
"""Called by :meth:`__getitem__`. Calculates the minimum/maximum
values of the given data (which has been extracted from the portion of
the image specified by ``slices``), and updates the known data range
of the image.
:arg slices: A tuple of tuples, each tuple being a ``(low, high)`` def __expandCoverage(self, slices):
index pair, one for each dimension in the image. """Expands the current image data range and coverage to encompass the
given ``slices``.
:arg data: The image data at the given ``slices`` (as a ``numpy``
array).
""" """
log.debug('Updating image {} data range (current range: '
'[{}, {}]; current coverage: {})'.format(
self.__name,
self.__range[0],
self.__range[1],
self.__coverage))
volumes, expansions = calcExpansion(slices, self.__coverage) volumes, expansions = calcExpansion(slices, self.__coverage)
oldmin, oldmax = self.__range oldmin, oldmax = self.__range
...@@ -280,7 +264,35 @@ class ImageWrapper(notifier.Notifier): ...@@ -280,7 +264,35 @@ class ImageWrapper(notifier.Notifier):
oldmax, oldmax,
newmin, newmin,
newmax)) newmax))
self.notify() self.notify()
def __updateDataRangeOnRead(self, slices, data):
"""Called by :meth:`__getitem__`. Calculates the minimum/maximum
values of the given data (which has been extracted from the portion of
the image specified by ``slices``), and updates the known data range
of the image.
:arg slices: A tuple of tuples, each tuple being a ``(low, high)``
index pair, one for each dimension in the image.
:arg data: The image data at the given ``slices`` (as a ``numpy``
array).
"""
log.debug('Updating image {} data range (current range: '
'[{}, {}]; current coverage: {})'.format(
self.__name,
self.__range[0],
self.__range[1],
self.__coverage))
# TODO You could do something with
# the provided data to avoid
# reading it in again.
self.__expandCoverage(slices)
def __getitem__(self, sliceobj): def __getitem__(self, sliceobj):
......
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