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
d27bfa49
Commit
d27bfa49
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Move some tests around
parent
971a88e8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_transform.py
+0
-50
0 additions, 50 deletions
tests/test_transform.py
tests/test_transform_flirt.py
+85
-0
85 additions, 0 deletions
tests/test_transform_flirt.py
with
85 additions
and
50 deletions
tests/test_transform.py
+
0
−
50
View file @
d27bfa49
...
...
@@ -500,56 +500,6 @@ def test_transformNormal(seed):
assert
np
.
all
(
np
.
isclose
(
expected
,
result
))
def
test_flirtMatrixToSform
():
testfile
=
op
.
join
(
datadir
,
'
test_transform_test_flirtMatrixToSform.txt
'
)
lines
=
readlines
(
testfile
)
ntests
=
len
(
lines
)
//
18
for
i
in
range
(
ntests
):
tlines
=
lines
[
i
*
18
:
i
*
18
+
18
]
srcShape
=
[
int
(
w
)
for
w
in
tlines
[
0
].
split
()]
srcXform
=
np
.
genfromtxt
(
tlines
[
1
:
5
])
refShape
=
[
int
(
w
)
for
w
in
tlines
[
5
].
split
()]
refXform
=
np
.
genfromtxt
(
tlines
[
6
:
10
])
flirtMat
=
np
.
genfromtxt
(
tlines
[
10
:
14
])
expected
=
np
.
genfromtxt
(
tlines
[
14
:
18
])
srcImg
=
fslimage
.
Image
(
np
.
zeros
(
srcShape
),
xform
=
srcXform
)
refImg
=
fslimage
.
Image
(
np
.
zeros
(
refShape
),
xform
=
refXform
)
result
=
transform
.
flirtMatrixToSform
(
flirtMat
,
srcImg
,
refImg
)
assert
np
.
all
(
np
.
isclose
(
result
,
expected
))
def
test_sformToFlirtMatrix
():
testfile
=
op
.
join
(
datadir
,
'
test_transform_test_flirtMatrixToSform.txt
'
)
lines
=
readlines
(
testfile
)
ntests
=
len
(
lines
)
//
18
for
i
in
range
(
ntests
):
tlines
=
lines
[
i
*
18
:
i
*
18
+
18
]
srcShape
=
[
int
(
w
)
for
w
in
tlines
[
0
].
split
()]
srcXform
=
np
.
genfromtxt
(
tlines
[
1
:
5
])
refShape
=
[
int
(
w
)
for
w
in
tlines
[
5
].
split
()]
refXform
=
np
.
genfromtxt
(
tlines
[
6
:
10
])
expected
=
np
.
genfromtxt
(
tlines
[
10
:
14
])
srcXformOvr
=
np
.
genfromtxt
(
tlines
[
14
:
18
])
srcImg1
=
fslimage
.
Image
(
np
.
zeros
(
srcShape
),
xform
=
srcXform
)
srcImg2
=
fslimage
.
Image
(
np
.
zeros
(
srcShape
),
xform
=
srcXform
)
refImg
=
fslimage
.
Image
(
np
.
zeros
(
refShape
),
xform
=
refXform
)
srcImg2
.
voxToWorldMat
=
srcXformOvr
result1
=
transform
.
sformToFlirtMatrix
(
srcImg1
,
refImg
,
srcXformOvr
)
result2
=
transform
.
sformToFlirtMatrix
(
srcImg2
,
refImg
)
assert
np
.
all
(
np
.
isclose
(
result1
,
expected
))
assert
np
.
all
(
np
.
isclose
(
result2
,
expected
))
def
test_rmsdev
():
t1
=
np
.
eye
(
4
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_transform_flirt.py
0 → 100644
+
85
−
0
View file @
d27bfa49
#!/usr/bin/env python
#
# test_transform_flirt.py -
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import
os.path
as
op
import
numpy
as
np
import
fsl.data.image
as
fslimage
import
fsl.utils.transform
as
transform
import
fsl.utils.tempdir
as
tempdir
from
.test_transform
import
readlines
datadir
=
op
.
join
(
op
.
dirname
(
__file__
),
'
testdata
'
)
def
test_read_write
():
with
tempdir
.
tempdir
():
aff
=
np
.
random
.
random
((
4
,
4
))
transform
.
writeFlirt
(
aff
,
'
aff.mat
'
)
got
=
transform
.
readFlirt
(
'
aff.mat
'
)
assert
np
.
all
(
np
.
isclose
(
aff
,
got
))
def
test_fromFlirt
():
pass
def
test_toFlirt
():
pass
def
test_flirtMatrixToSform
():
testfile
=
op
.
join
(
datadir
,
'
test_transform_test_flirtMatrixToSform.txt
'
)
lines
=
readlines
(
testfile
)
ntests
=
len
(
lines
)
//
18
for
i
in
range
(
ntests
):
tlines
=
lines
[
i
*
18
:
i
*
18
+
18
]
srcShape
=
[
int
(
w
)
for
w
in
tlines
[
0
].
split
()]
srcXform
=
np
.
genfromtxt
(
tlines
[
1
:
5
])
refShape
=
[
int
(
w
)
for
w
in
tlines
[
5
].
split
()]
refXform
=
np
.
genfromtxt
(
tlines
[
6
:
10
])
flirtMat
=
np
.
genfromtxt
(
tlines
[
10
:
14
])
expected
=
np
.
genfromtxt
(
tlines
[
14
:
18
])
srcImg
=
fslimage
.
Image
(
np
.
zeros
(
srcShape
),
xform
=
srcXform
)
refImg
=
fslimage
.
Image
(
np
.
zeros
(
refShape
),
xform
=
refXform
)
result
=
transform
.
flirtMatrixToSform
(
flirtMat
,
srcImg
,
refImg
)
assert
np
.
all
(
np
.
isclose
(
result
,
expected
))
def
test_sformToFlirtMatrix
():
testfile
=
op
.
join
(
datadir
,
'
test_transform_test_flirtMatrixToSform.txt
'
)
lines
=
readlines
(
testfile
)
ntests
=
len
(
lines
)
//
18
for
i
in
range
(
ntests
):
tlines
=
lines
[
i
*
18
:
i
*
18
+
18
]
srcShape
=
[
int
(
w
)
for
w
in
tlines
[
0
].
split
()]
srcXform
=
np
.
genfromtxt
(
tlines
[
1
:
5
])
refShape
=
[
int
(
w
)
for
w
in
tlines
[
5
].
split
()]
refXform
=
np
.
genfromtxt
(
tlines
[
6
:
10
])
expected
=
np
.
genfromtxt
(
tlines
[
10
:
14
])
srcXformOvr
=
np
.
genfromtxt
(
tlines
[
14
:
18
])
srcImg1
=
fslimage
.
Image
(
np
.
zeros
(
srcShape
),
xform
=
srcXform
)
srcImg2
=
fslimage
.
Image
(
np
.
zeros
(
srcShape
),
xform
=
srcXform
)
refImg
=
fslimage
.
Image
(
np
.
zeros
(
refShape
),
xform
=
refXform
)
srcImg2
.
voxToWorldMat
=
srcXformOvr
result1
=
transform
.
sformToFlirtMatrix
(
srcImg1
,
refImg
,
srcXformOvr
)
result2
=
transform
.
sformToFlirtMatrix
(
srcImg2
,
refImg
)
assert
np
.
all
(
np
.
isclose
(
result1
,
expected
))
assert
np
.
all
(
np
.
isclose
(
result2
,
expected
))
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