Commit d4d0d342 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'rel/2.8.3' into 'v2.8'

Rel/2.8.3

See merge request fsl/fslpy!201
parents 477a43a5 8ce91f13
Pipeline #5066 passed with stages
in 1 minute and 28 seconds
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
set -e set -e
# Temporary: this should be done
# in docker image definition
apt install -y locales
locale-gen en_US.UTF-8
locale-gen en_GB.UTF-8
update-locale
# If running on a fork repository, we merge in the # If running on a fork repository, we merge in the
# upstream/master branch. This is done so that merge # upstream/master branch. This is done so that merge
# requests from fork to the parent repository will # requests from fork to the parent repository will
...@@ -59,4 +66,4 @@ if [[ $CI_COMMIT_REF_NAME == v* ]]; then ...@@ -59,4 +66,4 @@ if [[ $CI_COMMIT_REF_NAME == v* ]]; then
python setup.py test --addopts="$TEST_OPTS -m 'longtest'" python setup.py test --addopts="$TEST_OPTS -m 'longtest'"
fi fi
python -m coverage report python -m coverage report -i
...@@ -2,6 +2,16 @@ This document contains the ``fslpy`` release history in reverse chronological ...@@ -2,6 +2,16 @@ This document contains the ``fslpy`` release history in reverse chronological
order. order.
2.8.3 (Friday 28th February 2020)
---------------------------------
Fixed
^^^^^
* Fixed a bug in the :meth:`.Image.save` method.
2.8.2 (Thursday 27th February 2020) 2.8.2 (Thursday 27th February 2020)
----------------------------------- -----------------------------------
......
...@@ -254,7 +254,7 @@ class Nifti(notifier.Notifier, meta.Meta): ...@@ -254,7 +254,7 @@ class Nifti(notifier.Notifier, meta.Meta):
shape, shape,
pixdim) pixdim)
self.header = header self.__header = header
self.__shape = shape self.__shape = shape
self.__origShape = origShape self.__origShape = origShape
self.__pixdim = pixdim self.__pixdim = pixdim
...@@ -262,6 +262,11 @@ class Nifti(notifier.Notifier, meta.Meta): ...@@ -262,6 +262,11 @@ class Nifti(notifier.Notifier, meta.Meta):
self.__isNeurological = isneuro self.__isNeurological = isneuro
def __del__(self):
"""Clears the reference to the ``nibabel`` header object. """
self.__header = None
@staticmethod @staticmethod
def determineShape(header): def determineShape(header):
"""This method is called by :meth:`__init__`. It figures out the actual """This method is called by :meth:`__init__`. It figures out the actual
...@@ -492,6 +497,24 @@ class Nifti(notifier.Notifier, meta.Meta): ...@@ -492,6 +497,24 @@ class Nifti(notifier.Notifier, meta.Meta):
return ''.join([c for c in val if c in string.printable]).strip() return ''.join([c for c in val if c in string.printable]).strip()
@property
def header(self):
"""Return a reference to the ``nibabel`` header object. """
return self.__header
@header.setter
def header(self, header):
"""Replace the ``nibabel`` header object managed by this ``Nifti``
with a new header. The new header must have the same dimensions,
voxel size, and orientation as the old one.
"""
new = Nifti(header)
if not (self.sameSpace(new) and self.ndim == new.ndim):
raise ValueError('Incompatible header')
self.__header = header
@property @property
def niftiVersion(self): def niftiVersion(self):
"""Returns the NIFTI file version: """Returns the NIFTI file version:
...@@ -1180,8 +1203,7 @@ class Image(Nifti): ...@@ -1180,8 +1203,7 @@ class Image(Nifti):
def __del__(self): def __del__(self):
"""Closes any open file handles, and clears some references. """ """Closes any open file handles, and clears some references. """
Nifti.__del__(self)
self.header = None
self.__nibImage = None self.__nibImage = None
self.__imageWrapper = None self.__imageWrapper = None
...@@ -1411,12 +1433,6 @@ class Image(Nifti): ...@@ -1411,12 +1433,6 @@ class Image(Nifti):
nib.save(self.__nibImage, tmpfname) nib.save(self.__nibImage, tmpfname)
# nibabel should close any old
# file handles when the image/
# header refs are deleted
self.__nibImage = None
self.header = None
# Copy to final destination, # Copy to final destination,
# and reload from there # and reload from there
imcp.imcp(tmpfname, filename, overwrite=True) imcp.imcp(tmpfname, filename, overwrite=True)
......
...@@ -47,7 +47,7 @@ import re ...@@ -47,7 +47,7 @@ import re
import string import string
__version__ = '2.8.2' __version__ = '2.8.3'
"""Current version number, as a string. """ """Current version number, as a string. """
......
Markdown is supported
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