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
08b6ab36
Commit
08b6ab36
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: callfsl no longer exists
parent
35cfaa17
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_callfsl.py
+0
-85
0 additions, 85 deletions
tests/test_callfsl.py
with
0 additions
and
85 deletions
tests/test_callfsl.py
deleted
100644 → 0
+
0
−
85
View file @
35cfaa17
#!/usr/bin/env python
#
# test_callfsl.py -
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import
os
import
os.path
as
op
import
subprocess
as
sp
import
numpy
as
np
import
nibabel
as
nib
import
mock
import
pytest
import
fsl.utils.callfsl
as
callfsl
from
fsl.utils.platform
import
platform
as
fslplatform
import
tests
pytestmark
=
pytest
.
mark
.
fsltest
def
setup_module
():
fsldir
=
os
.
environ
.
get
(
'
FSLDIR
'
,
None
)
if
fsldir
is
None
or
not
op
.
exists
(
fsldir
):
raise
Exception
(
'
FSLDIR is not set - callfsl tests cannot be run
'
)
# mock subprocess.check_output command
# which expects 'fslstats -m filename'
# or 'fslinfo ...'
def
mock_check_output
(
args
):
if
args
[
0
].
endswith
(
'
fslinfo
'
):
return
'
info
'
.
encode
(
'
utf-8
'
)
img
=
nib
.
load
(
args
[
-
2
])
return
str
(
img
.
get_data
().
mean
()).
encode
(
'
utf-8
'
)
def
test_callfsl
():
with
tests
.
testdir
()
as
testdir
:
fname
=
op
.
join
(
testdir
,
'
myimage.nii.gz
'
)
img
=
tests
.
make_random_image
(
fname
)
img
=
img
.
get_data
()
# Pass a single string
cmd
=
'
fslstats {} -m
'
.
format
(
fname
)
with
mock
.
patch
(
'
fsl.utils.callfsl.sp.check_output
'
,
mock_check_output
):
result
=
callfsl
.
callFSL
(
cmd
)
assert
np
.
isclose
(
float
(
result
),
img
.
mean
())
# Or pass a list of args
result
=
callfsl
.
callFSL
(
*
cmd
.
split
())
assert
np
.
isclose
(
float
(
result
),
img
.
mean
())
# Bad commands
badcmds
=
[
'
fslblob
'
,
'
fslstats notafile
'
]
for
cmd
in
badcmds
:
with
pytest
.
raises
((
OSError
,
sp
.
CalledProcessError
)):
callfsl
.
callFSL
(
cmd
)
# No FSL - should crash
cmd
=
'
fslinfo {}
'
.
format
(
fname
)
with
mock
.
patch
(
'
fsl.utils.callfsl.sp.check_output
'
,
mock_check_output
):
callfsl
.
callFSL
(
cmd
)
try
:
oldval
=
fslplatform
.
fsldir
fslplatform
.
fsldir
=
None
with
pytest
.
raises
(
Exception
):
callfsl
.
callFSL
(
cmd
)
finally
:
fslplatform
.
fsldir
=
oldval
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