Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD 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
FSL
fslpy
Commits
c1e5a347
Commit
c1e5a347
authored
11 months ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Failing regression test for fileOrImage file suffix issue
parent
781a3619
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
fsl/tests/test_wrappers/test_wrapperutils.py
+50
-2
50 additions, 2 deletions
fsl/tests/test_wrappers/test_wrapperutils.py
with
50 additions
and
2 deletions
fsl/tests/test_wrappers/test_wrapperutils.py
+
50
−
2
View file @
c1e5a347
...
...
@@ -27,8 +27,8 @@ import fsl.data.image as fslimage
import
fsl.wrappers.wrapperutils
as
wutils
from
..
import
mockFSLDIR
,
cleardir
,
checkdir
,
testdir
,
touch
from
.
.test_run
import
mock_fsl_sub
from
fsl.tests
import
mockFSLDIR
,
cleardir
,
checkdir
,
testdir
,
touch
from
fsl.tests
.test_run
import
mock_fsl_sub
def
test_applyArgStyle_default
():
...
...
@@ -407,6 +407,54 @@ def test_fileOrImage():
assert
np
.
all
(
np
.
asanyarray
(
result
.
dataobj
)[:]
==
expected
)
# fsl/fslpy!452
def
test_fileOrImage_FSLOUTPUTTYPE
():
@wutils.fileOrImage
(
'
img
'
,
'
output
'
)
def
func
(
img
,
output
):
img
=
np
.
asanyarray
(
nib
.
load
(
img
).
dataobj
)
# Save without specifying file suffix,
# so the Image object uses $FSLOUTPUTTYPE
fslimage
.
Image
(
img
*
5
,
xform
=
np
.
eye
(
4
)).
save
(
fslimage
.
removeExt
(
output
))
fsloutputtypes
=
[
fslimage
.
FileType
.
NIFTI
,
fslimage
.
FileType
.
NIFTI2
,
fslimage
.
FileType
.
NIFTI_GZ
,
fslimage
.
FileType
.
NIFTI2_GZ
]
for
fsloutputtype
in
fsloutputtypes
:
with
tempdir
.
tempdir
(),
\
mock
.
patch
.
dict
(
os
.
environ
,
FSLOUTPUTTYPE
=
fsloutputtype
.
name
):
img
=
fslimage
.
Image
(
np
.
array
([[[
1
,
2
],
[
3
,
4
]]],
dtype
=
np
.
int32
),
xform
=
np
.
eye
(
4
))
expected
=
np
.
array
([[[
5
,
10
],
[
15
,
20
]]],
dtype
=
np
.
int32
)
imgfname
=
op
.
join
(
os
.
getcwd
(),
f
'
image
{
fslimage
.
defaultExt
()
}
'
)
img
.
save
(
imgfname
)
result1
=
func
(
imgfname
,
wutils
.
LOAD
)
result2
=
func
(
img
,
wutils
.
LOAD
)
r1data
=
np
.
asanyarray
(
result1
[
'
output
'
].
dataobj
)
r2data
=
result2
[
'
output
'
].
data
# first call will return a nibabel image,
# second a fsl Image
assert
np
.
all
(
r1data
==
expected
)
assert
np
.
all
(
r2data
==
expected
)
for
inarg
in
(
img
,
imgfname
):
with
tempdir
.
tempdir
():
func
(
inarg
,
'
output
'
)
assert
op
.
exists
(
f
'
output
{
fslimage
.
defaultExt
()
}
'
)
out
=
fslimage
.
Image
(
'
output
'
)
assert
np
.
all
(
out
.
data
==
expected
.
data
)
def
test_fileOrThing_sequence
():
@wutils.fileOrArray
(
'
arrs
'
,
'
out
'
)
...
...
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