Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Michiel Cottaar
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
Branches containing commit
No related tags found
No related merge requests found
Changes
3
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
...
@@ -74,7 +74,8 @@ Fixed
functions.
functions.
* Fixed the :func:`.DeformationField.transform` method so it works with
* Fixed the :func:`.DeformationField.transform` method so it works with
a single set of coordinates.
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
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):
...
@@ -1162,11 +1162,19 @@ class Image(Nifti):
self
.
register
(
self
.
name
,
self
.
__headerChanged
,
topic
=
'
transform
'
)
self
.
register
(
self
.
name
,
self
.
__headerChanged
,
topic
=
'
transform
'
)
self
.
register
(
self
.
name
,
self
.
__headerChanged
,
topic
=
'
header
'
)
self
.
register
(
self
.
name
,
self
.
__headerChanged
,
topic
=
'
header
'
)
# calculate min/max
# of image data
if
calcRange
:
if
calcRange
:
self
.
calcRange
()
self
.
calcRange
()
# try and load metadata
# from JSON sidecar files
if
self
.
dataSource
is
not
None
and
loadMeta
:
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
)
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():
...
@@ -1414,11 +1414,23 @@ def test_loadMeta_nonBids():
with
open
(
op
.
join
(
'
data
'
,
'
dataset_description.json
'
),
'
wt
'
)
as
f
:
with
open
(
op
.
join
(
'
data
'
,
'
dataset_description.json
'
),
'
wt
'
)
as
f
:
pass
pass
img
=
fslimage
.
Image
(
imgfile
,
loadMeta
=
True
)
img
=
fslimage
.
Image
(
imgfile
,
loadMeta
=
True
)
assert
list
(
img
.
metaKeys
())
==
[]
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
():
def
test_loadMetadata
():
with
tempdir
():
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