diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f7124b6641a6c8b6613f3f6a10528f667e478f87..04949778e3fa9d9147a0f976e3fc3ecab52fbf31 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -34,6 +34,9 @@ Fixed * Improved the algorithm used by the :func:`.mesh.needsFixing` function. * The :meth:`.fslmaths.run` method now accepts :attr:`.wrappers.LOAD` as an output specification. +* Fixed a bug in the :class:`.Mesh` class to prevent indices from being loaded + as floating point type. +* Fixed a bug in the :func:`.resample` function. Deprecated diff --git a/fsl/data/mesh.py b/fsl/data/mesh.py index 383afcb17d0f31fe329886212a2a81d814f85c4e..30b4548f5c7ce9c46561e00b693ecb29f30a8f18 100644 --- a/fsl/data/mesh.py +++ b/fsl/data/mesh.py @@ -154,14 +154,6 @@ class Mesh(notifier.Notifier, meta.Meta): """ - def __new__(cls, *args, **kwargs): - """Create a ``Mesh``. We must override ``__new__``, otherwise the - :class:`Meta` and :class:`Notifier` ``__new__`` methods will not be - called correctly. - """ - return super(Mesh, cls).__new__(cls, *args, **kwargs) - - def __init__(self, indices, name='mesh', @@ -189,7 +181,7 @@ class Mesh(notifier.Notifier, meta.Meta): self.__name = name self.__dataSource = dataSource - self.__nvertices = indices.max() + 1 + self.__nvertices = int(indices.max()) + 1 self.__selected = None # We potentially store two copies of @@ -197,7 +189,7 @@ class Mesh(notifier.Notifier, meta.Meta): # orders. The vindices dict stores refs # to one or the other for each vertex # set. - self.__indices = np.asarray(indices).reshape((-1, 3)) + self.__indices = np.asarray(indices, dtype=np.int32).reshape((-1, 3)) self.__fixedIndices = None self.__vindices = collections.OrderedDict() diff --git a/fsl/utils/image/resample.py b/fsl/utils/image/resample.py index 7679c56b02a4b31ff91e4fd3b499f63015d38792..371e87b602c60b777bc6e8587aec32b185f08e1d 100644 --- a/fsl/utils/image/resample.py +++ b/fsl/utils/image/resample.py @@ -47,9 +47,9 @@ def resampleToReference(image, reference, matrix=None, **kwargs): along the spatial (first three) dimensions. :arg image: :class:`.Image` to resample - :arg matrix: Optional world-to-world affine alignment matrix :arg reference: :class:`.Nifti` defining the space to resample ``image`` into + :arg matrix: Optional world-to-world affine alignment matrix """ oldShape = list(image.shape) @@ -204,9 +204,10 @@ def resample(image, if matrix is None: matrix = affine.rescale(data.shape, newShape, origin) - # identity matrix? the image - # doesn't need to be resampled - if np.all(np.isclose(matrix, np.eye(len(newShape) + 1))): + # same shape and identity matrix? the + # image doesn't need to be resampled + if np.all(np.isclose(data.shape, newShape)) and \ + np.all(np.isclose(matrix, np.eye(len(newShape) + 1))): return data, image.voxToWorldMat newShape = np.array(np.round(newShape), dtype=np.int) diff --git a/requirements-extra.txt b/requirements-extra.txt index 333cde7a982fd7502eec2af60e26b87b332dac0f..735bdaff40382b196be77390a2ee610bbeee8258 100644 --- a/requirements-extra.txt +++ b/requirements-extra.txt @@ -1,5 +1,5 @@ indexed_gzip>=0.7.0 wxpython==4.* trimesh>=2.37.29 -rtree==0.8.3 +rtree>=0.8.3 Pillow>=3.2.0