Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fslpy
Commits
ee0a37b7
Commit
ee0a37b7
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Plain Diff
Merge branch 'bf/meta' into 'master'
Bf/meta See merge request fsl/fslpy!221
parents
0a972e0c
b2f25b10
No related branches found
No related tags found
No related merge requests found
Pipeline
#5170
passed with warnings
4 years ago
Stage: test
Stage: style
Stage: doc
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.rst
+2
-1
2 additions, 1 deletion
CHANGELOG.rst
fsl/data/image.py
+9
-1
9 additions, 1 deletion
fsl/data/image.py
tests/test_image.py
+13
-1
13 additions, 1 deletion
tests/test_image.py
with
24 additions
and
3 deletions
CHANGELOG.rst
+
2
−
1
View file @
ee0a37b7
...
...
@@ -74,7 +74,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
^^^^^^^
...
...
This diff is collapsed.
Click to expand it.
fsl/data/image.py
+
9
−
1
View file @
ee0a37b7
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_image.py
+
13
−
1
View file @
ee0a37b7
...
...
@@ -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
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment