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
fsleyes
fsleyes
Commits
bd2f311a
Commit
bd2f311a
authored
Oct 01, 2021
by
Paul McCarthy
🚵
Browse files
TEST: Test -ds scaledVoxel with L/R flipped images
parent
c6de9ea6
Changes
10
Hide whitespace changes
Inline
Side-by-side
fsleyes/tests/__init__.py
View file @
bd2f311a
...
...
@@ -672,6 +672,40 @@ def fliporient(filename):
return
outfile
def
swapdim
(
filename
,
d0
,
d1
,
d2
):
indices
=
{
'x'
:
0
,
'-x'
:
0
,
'y'
:
1
,
'-y'
:
1
,
'z'
:
2
,
'-z'
:
2
}
base
=
fslimage
.
removeExt
(
filename
)
outfile
=
'{}_swapdim_{}_{}_{}'
.
format
(
base
,
d0
,
d1
,
d2
)
img
=
fslimage
.
Image
(
filename
)
s0
,
s1
,
s2
=
[
-
1
if
d
.
startswith
(
'-'
)
else
1
for
d
in
(
d0
,
d1
,
d2
)]
d0
,
d1
,
d2
=
[
indices
[
d
]
for
d
in
(
d0
,
d1
,
d2
)]
if
len
(
img
.
shape
)
==
3
:
order
=
(
d0
,
d1
,
d2
)
else
:
order
=
(
d0
,
d1
,
d2
)
+
tuple
(
range
(
3
,
len
(
img
.
shape
)))
data
=
img
.
data
if
s0
<
0
:
data
=
np
.
flip
(
data
,
d0
)
if
s1
<
0
:
data
=
np
.
flip
(
data
,
d1
)
if
s2
<
0
:
data
=
np
.
flip
(
data
,
d2
)
data
=
data
.
transpose
(
order
)
aff
=
np
.
zeros
((
4
,
4
))
aff
[
0
,
d0
]
=
s0
aff
[
1
,
d1
]
=
s1
aff
[
2
,
d2
]
=
s2
aff
[
3
,
3
]
=
1
aff
=
affine
.
concat
(
aff
,
img
.
voxToWorldMat
)
img
=
fslimage
.
Image
(
data
,
xform
=
aff
)
img
.
save
(
outfile
)
return
outfile
def
roi
(
fname
,
roi
):
...
...
fsleyes/tests/test_displayspace.py
View file @
bd2f311a
...
...
@@ -7,7 +7,7 @@
import
pytest
from
fsleyes.tests
import
run_cli_tests
,
resampled
,
roi
,
rotate
from
fsleyes.tests
import
run_cli_tests
,
resampled
,
roi
,
rotate
,
swapdim
pytestmark
=
pytest
.
mark
.
clitest
...
...
@@ -24,6 +24,16 @@ tests = """
-ds 3d_rotated_20_20_20 3d {{rotate('3d', 20, 20, 20)}} -cm red-yellow -a 50
-ds world 3d {{rotate('3d', 20, 20, 20)}} -cm red-yellow -a 50
-ds scaledVoxel 3d {{rotate('3d', 20, 20, 20)}} -cm red-yellow -a 50
-ds 3d 3d {{swapdim('3d', '-x', 'y', 'z')}} -cm red-yellow -a 50
-ds 3d_swapdim_-x_y_z 3d {{swapdim('3d', '-x', 'y', 'z')}} -cm red-yellow -a 50
-ds scaledVoxel 3d {{swapdim('3d', '-x', 'y', 'z')}} -cm red-yellow -a 50
-ds world 3d {{swapdim('3d', '-x', 'y', 'z')}} -cm red-yellow -a 50
-ds 3d 3d {{resampled(swapdim('3d', '-x', 'y', 'z'), 0.5)}} -cm red-yellow -a 50
-ds 3d_swapdim_-x_y_z_resampled_0.5 3d {{resampled(swapdim('3d', '-x', 'y', 'z'), 0.5)}} -cm red-yellow -a 50
-ds scaledVoxel 3d {{resampled(swapdim('3d', '-x', 'y', 'z'), 0.5)}} -cm red-yellow -a 50
-ds world 3d {{resampled(swapdim('3d', '-x', 'y', 'z'), 0.5)}} -cm red-yellow -a 50
"""
...
...
@@ -31,6 +41,7 @@ def test_displayspace():
extras
=
{
'roi'
:
roi
,
'resampled'
:
resampled
,
'rotate'
:
rotate
'rotate'
:
rotate
,
'swapdim'
:
swapdim
}
run_cli_tests
(
'test_displayspace'
,
tests
,
extras
=
extras
)
fsleyes/tests/testdata/cli_tests/test_displayspace_-ds_3d_3d_3d_swapdim_-x_y_z_-cm_red-yellow_-a_50.png
0 → 100644
View file @
bd2f311a
7.58 KB
fsleyes/tests/testdata/cli_tests/test_displayspace_-ds_3d_3d_3d_swapdim_-x_y_z_resampled_0.5_-cm_red-yellow_-a_50.png
0 → 100644
View file @
bd2f311a
16.8 KB
fsleyes/tests/testdata/cli_tests/test_displayspace_-ds_3d_swapdim_-x_y_z_3d_3d_swapdim_-x_y_z_-cm_red-yellow_-a_50.png
0 → 100644
View file @
bd2f311a
7.58 KB
fsleyes/tests/testdata/cli_tests/test_displayspace_-ds_3d_swapdim_-x_y_z_resampled_0.5_3d_3d_swapdim_-x_y_z_resampled_0.5_-cm_red-yellow_-a_50.png
0 → 100644
View file @
bd2f311a
16.8 KB
fsleyes/tests/testdata/cli_tests/test_displayspace_-ds_scaledVoxel_3d_3d_swapdim_-x_y_z_-cm_red-yellow_-a_50.png
0 → 100644
View file @
bd2f311a
13.4 KB
fsleyes/tests/testdata/cli_tests/test_displayspace_-ds_scaledVoxel_3d_3d_swapdim_-x_y_z_resampled_0.5_-cm_red-yellow_-a_50.png
0 → 100644
View file @
bd2f311a
23.8 KB
fsleyes/tests/testdata/cli_tests/test_displayspace_-ds_world_3d_3d_swapdim_-x_y_z_-cm_red-yellow_-a_50.png
0 → 100644
View file @
bd2f311a
7.58 KB
fsleyes/tests/testdata/cli_tests/test_displayspace_-ds_world_3d_3d_swapdim_-x_y_z_resampled_0.5_-cm_red-yellow_-a_50.png
0 → 100644
View file @
bd2f311a
16.8 KB
Write
Preview
Markdown
is supported
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