Commit 537dec2e authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'rel/3.0.0' into 'v3.0'

Rel/3.0.0

See merge request fsl/fslpy!222
parents 081a43cc 3b12b325
Pipeline #5173 passed with stages
in 2 minutes and 13 seconds
......@@ -75,7 +75,8 @@ Fixed
functions.
* Fixed the :func:`.DeformationField.transform` method so it works with
a single set of coordinates.
* :class:`.Image` creation does not fail if ``loadMeta`` is set, and a
sidecar file containing invalid JSON is present.
Removed
^^^^^^^
......
......@@ -1162,11 +1162,19 @@ class Image(Nifti):
self.register(self.name, self.__headerChanged, topic='transform')
self.register(self.name, self.__headerChanged, topic='header')
# calculate min/max
# of image data
if calcRange:
self.calcRange()
# try and load metadata
# from JSON sidecar files
if self.dataSource is not None and loadMeta:
self.updateMeta(loadMetadata(self))
try:
self.updateMeta(loadMetadata(self))
except Exception as e:
log.warning('Failed to load metadata for %s: %s',
self.dataSource, e)
self.__imageWrapper.register(self.__lName, self.__dataRangeChanged)
......
......@@ -1414,11 +1414,23 @@ def test_loadMeta_nonBids():
with open(op.join('data', 'dataset_description.json'), 'wt') as f:
pass
img = fslimage.Image(imgfile, loadMeta=True)
assert list(img.metaKeys()) == []
def test_loadMeta_badJSON():
with tempdir():
make_image('image.nii.gz')
# spurious comma after b:2
with open('image.json', 'wt') as f:
f.write('{"a" : 1, "b" : 2,}')
# bad json should not cause failure
img = fslimage.Image('image.nii.gz', loadMeta=True)
assert list(img.metaKeys()) == []
def test_loadMetadata():
with tempdir():
......
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