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
20883ff7
Commit
20883ff7
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Unit test for MGHImage.save behaviour
parent
fb4b597a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_mghimage.py
+28
-3
28 additions, 3 deletions
tests/test_mghimage.py
with
28 additions
and
3 deletions
tests/test_mghimage.py
+
28
−
3
View file @
20883ff7
...
...
@@ -7,18 +7,21 @@
import
os.path
as
op
import
shutil
import
numpy
as
np
import
nibabel
as
nib
from
.
import
testdir
import
fsl.utils.tempdir
as
tempdir
import
fsl.data.mghimage
as
fslmgh
import
fsl.data.image
as
fslimage
datadir
=
op
.
join
(
op
.
abspath
(
op
.
dirname
(
__file__
)),
'
testdata
'
)
def
test_MGHImage
():
datadir
=
op
.
join
(
op
.
dirname
(
__file__
),
'
testdata
'
)
testfile
=
op
.
join
(
datadir
,
'
example.mgz
'
)
# Load from a file
...
...
@@ -27,10 +30,32 @@ def test_MGHImage():
assert
np
.
all
(
np
.
isclose
(
img
[:],
nbimg
.
get_data
()))
assert
np
.
all
(
np
.
isclose
(
img
.
voxToWorldMat
,
nbimg
.
affine
))
assert
img
.
name
==
op
.
basename
(
testfile
)
assert
img
.
dataSource
==
testfile
assert
img
.
mghImageFile
==
testfile
# Load from an in-memory nibabel object
img
=
fslmgh
.
MGHImage
(
nbimg
)
assert
np
.
all
(
np
.
isclose
(
img
[:],
nbimg
.
get_data
()))
assert
np
.
all
(
np
.
isclose
(
img
.
voxToWorldMat
,
nbimg
.
affine
))
assert
img
.
dataSource
is
None
assert
img
.
mghImageFile
is
None
def
test_MGHImage_save
():
testfile
=
op
.
join
(
datadir
,
'
example.mgz
'
)
with
tempdir
.
tempdir
():
shutil
.
copy
(
testfile
,
'
example.mgz
'
)
testfile
=
'
example.mgz
'
img
=
fslmgh
.
MGHImage
(
testfile
)
img
.
save
()
expfile
=
op
.
abspath
(
fslimage
.
addExt
(
'
example
'
,
mustExist
=
False
))
assert
img
.
dataSource
==
op
.
abspath
(
expfile
)
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