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
e59b53e5
Commit
e59b53e5
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: tests for new metadata functions
parent
44966429
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_image.py
+48
-0
48 additions, 0 deletions
tests/test_image.py
tests/test_meta.py
+5
-0
5 additions, 0 deletions
tests/test_meta.py
with
53 additions
and
0 deletions
tests/test_image.py
+
48
−
0
View file @
e59b53e5
...
...
@@ -8,6 +8,7 @@
import
os
import
json
import
os.path
as
op
import
itertools
as
it
...
...
@@ -1382,3 +1383,50 @@ def test_complex():
assert
image
[
3
,
3
,
3
]
==
data
[
3
,
3
,
3
]
assert
dmin
==
data
.
min
()
assert
dmax
==
data
.
max
()
def
test_loadMeta
():
with
tempdir
():
make_image
(
'
image.nii.gz
'
)
meta
=
{
'
a
'
:
1
,
'
b
'
:
2
}
with
open
(
'
image.json
'
,
'
wt
'
)
as
f
:
json
.
dump
(
meta
,
f
)
img
=
fslimage
.
Image
(
'
image.nii.gz
'
,
loadMeta
=
True
)
assert
img
.
getMeta
(
'
a
'
)
==
1
assert
img
.
getMeta
(
'
b
'
)
==
2
def
test_loadMetadata
():
with
tempdir
():
make_image
(
'
image.nii.gz
'
)
meta
=
{
'
a
'
:
1
,
'
b
'
:
2
}
with
open
(
'
image.json
'
,
'
wt
'
)
as
f
:
json
.
dump
(
meta
,
f
)
img
=
fslimage
.
Image
(
'
image.nii.gz
'
)
gotmeta
=
fslimage
.
loadMetadata
(
img
)
assert
gotmeta
==
meta
with
tempdir
():
imgfile
=
op
.
join
(
'
data
'
,
'
sub-01
'
,
'
anat
'
,
'
sub-01_T1w.nii.gz
'
)
metafile
=
op
.
join
(
'
data
'
,
'
T1w.json
'
)
os
.
makedirs
(
op
.
dirname
(
imgfile
))
make_image
(
imgfile
)
with
open
(
op
.
join
(
'
data
'
,
'
dataset_description.json
'
),
'
wt
'
)
as
f
:
pass
meta
=
{
'
a
'
:
1
,
'
b
'
:
2
}
with
open
(
metafile
,
'
wt
'
)
as
f
:
json
.
dump
(
meta
,
f
)
img
=
fslimage
.
Image
(
imgfile
)
gotmeta
=
fslimage
.
loadMetadata
(
img
)
assert
gotmeta
==
meta
This diff is collapsed.
Click to expand it.
tests/test_meta.py
+
5
−
0
View file @
e59b53e5
...
...
@@ -22,3 +22,8 @@ def test_meta():
assert
list
(
data
.
keys
())
==
list
(
m
.
metaKeys
())
assert
list
(
data
.
values
())
==
list
(
m
.
metaValues
())
assert
list
(
data
.
items
())
==
list
(
m
.
metaItems
())
data
.
update
(
{
'
d
'
:
4
,
'
e
'
:
5
})
m
.
updateMeta
({
'
d
'
:
4
,
'
e
'
:
5
})
assert
list
(
data
.
items
())
==
list
(
m
.
metaItems
())
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