Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
fslpy
Commits
0ceeb9ba
Commit
0ceeb9ba
authored
May 18, 2020
by
Paul McCarthy
🚵
Browse files
TEST: test default image object+file type
parent
f2ce0ed9
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/test_image.py
View file @
0ceeb9ba
...
...
@@ -499,8 +499,9 @@ def test_splitExt():
def
test_defaultExt
():
fslOutputTypes
=
[
'NIFTI'
,
'NIFTI_PAIR'
,
'NIFTI_GZ'
]
exts
=
[
'.nii'
,
'.img'
,
'.nii.gz'
]
fslOutputTypes
=
[
'NIFTI'
,
'NIFTI_PAIR'
,
'NIFTI_GZ'
,
'NIFTI_PAIR_GZ'
,
'NIFTI2'
,
'NIFTI2_PAIR'
,
'NIFTI2_GZ'
,
'NIFTI2_PAIR_GZ'
]
exts
=
[
'.nii'
,
'.img'
,
'.nii.gz'
,
'.img.gz'
]
*
2
os
.
environ
.
pop
(
'FSLOUTPUTTYPE'
,
None
)
assert
fslimage
.
defaultExt
()
==
'.nii.gz'
...
...
@@ -512,6 +513,35 @@ def test_defaultExt():
assert
fslimage
.
defaultExt
()
==
e
def
test_defaultImageType
():
fslOutputTypes
=
[
None
,
'NIFTI'
,
'NIFTI_PAIR'
,
'NIFTI_GZ'
,
'NIFTI_PAIR_GZ'
,
'NIFTI2'
,
'NIFTI2_PAIR'
,
'NIFTI2_GZ'
,
'NIFTI2_PAIR_GZ'
]
exts
=
[
'.nii.gz'
]
+
\
[
'.nii'
,
'.img'
,
'.nii.gz'
,
'.img.gz'
]
*
2
with
tempdir
():
for
o
,
e
in
zip
(
fslOutputTypes
,
exts
):
if
o
is
None
:
os
.
environ
.
pop
(
'FSLOUTPUTTYPE'
,
None
)
else
:
os
.
environ
[
'FSLOUTPUTTYPE'
]
=
o
if
o
is
None
or
'NIFTI2'
not
in
o
:
exptype
=
nib
.
Nifti1Image
else
:
exptype
=
nib
.
Nifti2Image
img
=
fslimage
.
Image
(
np
.
random
.
randint
(
1
,
10
,
(
30
,
30
,
30
)))
assert
type
(
img
.
nibImage
)
==
exptype
img
.
save
(
'image'
)
assert
op
.
exists
(
'image'
+
e
)
def
test_fixExt
():
with
tempdir
():
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment