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
c9140729
Commit
c9140729
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Test changing intent property
parent
8d03a212
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_image.py
+42
-1
42 additions, 1 deletion
tests/test_image.py
with
42 additions
and
1 deletion
tests/test_image.py
+
42
−
1
View file @
c9140729
...
...
@@ -21,7 +21,6 @@ from nibabel.spatialimages import ImageFileError
import
fsl.data.constants
as
constants
import
fsl.data.image
as
fslimage
import
fsl.data.imagewrapper
as
imagewrapper
import
fsl.utils.path
as
fslpath
import
fsl.utils.transform
as
transform
...
...
@@ -743,6 +742,48 @@ def _test_Image_changeXform(imgtype, sformcode=None, qformcode=None):
image
=
None
def
test_Image_changeIntent_analyze
():
_test_Image_changeIntent
(
0
)
def
test_Image_changeIntent_nifti1
():
_test_Image_changeIntent
(
1
)
def
test_Image_changeIntent_nifti2
():
_test_Image_changeIntent
(
2
)
def
_test_Image_changeIntent
(
imgtype
):
"""
Test changing the Nifti.intent attribute.
"""
with
tempdir
()
as
testdir
:
imagefile
=
op
.
join
(
testdir
,
'
image
'
)
image
=
make_image
(
imagefile
,
imgtype
)
if
imgtype
>
0
:
image
.
header
.
set_intent
(
constants
.
NIFTI_INTENT_NONE
)
nib
.
save
(
image
,
imagefile
)
notified
=
{}
def
onHdr
(
*
a
):
notified
[
'
header
'
]
=
True
def
onSave
(
*
a
):
notified
[
'
save
'
]
=
True
img
=
fslimage
.
Image
(
imagefile
)
img
.
register
(
'
name1
'
,
onHdr
,
'
header
'
)
img
.
register
(
'
name2
'
,
onSave
,
'
saveState
'
)
assert
img
.
intent
==
constants
.
NIFTI_INTENT_NONE
img
.
intent
=
constants
.
NIFTI_INTENT_BETA
if
imgtype
==
0
:
exp
=
constants
.
NIFTI_INTENT_NONE
else
:
exp
=
constants
.
NIFTI_INTENT_BETA
assert
img
.
intent
==
exp
if
imgtype
>
0
:
assert
img
.
header
.
get_intent
(
'
code
'
)[
0
]
==
exp
assert
img
.
nibImage
.
header
.
get_intent
(
'
code
'
)[
0
]
==
exp
assert
notified
.
get
(
'
header
'
,
False
)
assert
notified
.
get
(
'
save
'
,
False
)
def
test_Image_changeData_analyze
(
seed
):
_test_Image_changeData
(
0
)
def
test_Image_changeData_nifti1
(
seed
):
_test_Image_changeData
(
1
)
def
test_Image_changeData_nifti2
(
seed
):
_test_Image_changeData
(
2
)
...
...
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