Commit 51f0828d authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'rel/3.9.4' into 'v3.9'


See merge request fsl/fslpy!342
parents 95ded539 bf212df7
Pipeline #14483 passed with stages
in 3 minutes and 39 seconds
......@@ -2,6 +2,20 @@ This document contains the ``fslpy`` release history in reverse chronological
3.9.4 (Friday 27th May 2022)
* Changed the behaviour of :meth:`.Image.__getitem__` so that, if image
data is accessed with a boolean mask array (e.g. ``image[mask > 0]``),
the image data is loaded into memory (!341).
* Fixed an issue in the :func:`.func_to_cmd` function (!339).
3.9.3 (Friday 27th May 2022)
......@@ -1068,7 +1068,7 @@ class Image(Nifti):
Internally, the image data is managed using one of the following methods:
1. For read-only access, the ``Image`` class delegates entirely to the
1. For read-only access, the ``Image`` class delegates to the
underlying ``nibabel.Nifti1Image`` instance, accessing the data
via the ``Nifti1Image.dataobj`` attribute. Refer to for
......@@ -1081,7 +1081,13 @@ class Image(Nifti):
the underlying ``nibabel.Nifti1Image`` object (refer to
3. For more complicated requirements, a :class:`DataManager`,
3. The ``nibabel.Nifti1Image`` class does not support indexing of image
data with boolean mask arrays (e.g. ``image[mask > 0]``). If an
attempt is made to access image data in this way, the ``Image`` class
will be loaded into memory in the same way as described in point 2
4. For more complicated requirements, a :class:`DataManager`,
implementing custom data access management logic, can be provided when
an ``Image`` is created. If a ``DataManager``is provided, an
internal reference to the data (see 2 above) will **not** be created or
......@@ -1603,6 +1609,17 @@ class Image(Nifti):
expNdims, expShape = expectedShape( slc, shape)
slc = canonicalSliceObj( slc, realShape)
# The nibabel arrayproxy does not support
# boolean mask-based (a.k.a. "fancy")
# indexing. If we are given a mask, we
# force-load the image data into memory.
if all((fancy,
self.__dataMgr is None,
self.__data is None)):
log.debug('Fancy slice detected - force-loading image '
'data into memory (%s)',
if self.__dataMgr is not None: data = self.__dataMgr[slc]
elif self.__data is not None: data = self.__data[slc]
else: data = self.__nibImage.dataobj[slc]
......@@ -47,7 +47,7 @@ import re
import string
__version__ = '3.9.3'
__version__ = '3.9.4'
"""Current version number, as a string. """
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment