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
1b997118
Commit
1b997118
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: test premat
parent
1886a941
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_transform/test_nonlinear.py
+54
-0
54 additions, 0 deletions
tests/test_transform/test_nonlinear.py
with
54 additions
and
0 deletions
tests/test_transform/test_nonlinear.py
+
54
−
0
View file @
1b997118
...
...
@@ -411,6 +411,60 @@ def test_applyDeformation_altsrc():
assert
np
.
all
(
np
.
isclose
(
expect
,
result
))
def
test_applyDeformation_premat
():
src2ref
=
affine
.
compose
(
np
.
random
.
randint
(
2
,
5
,
3
),
np
.
random
.
randint
(
1
,
10
,
3
),
[
0
,
0
,
0
])
ref2src
=
affine
.
invert
(
src2ref
)
srcdata
=
np
.
random
.
randint
(
1
,
65536
,
(
10
,
10
,
10
))
refdata
=
np
.
random
.
randint
(
1
,
65536
,
(
10
,
10
,
10
))
src
=
fslimage
.
Image
(
srcdata
)
ref
=
fslimage
.
Image
(
refdata
,
xform
=
src2ref
)
field
=
_affine_field
(
src
,
ref
,
ref2src
,
'
world
'
,
'
world
'
)
# First try a down-sampled version
# of the original source image
altsrc
,
xf
=
resample
.
resample
(
src
,
(
5
,
5
,
5
),
origin
=
'
corner
'
)
altsrc
=
fslimage
.
Image
(
altsrc
,
xform
=
xf
,
header
=
src
.
header
)
expect
,
xf
=
resample
.
resampleToReference
(
altsrc
,
ref
,
matrix
=
src2ref
,
order
=
1
,
mode
=
'
nearest
'
)
premat
=
affine
.
concat
(
src
.
getAffine
(
'
world
'
,
'
voxel
'
),
altsrc
.
getAffine
(
'
voxel
'
,
'
world
'
))
result
=
nonlinear
.
applyDeformation
(
altsrc
,
field
,
order
=
1
,
mode
=
'
nearest
'
,
premat
=
premat
)
assert
np
.
all
(
np
.
isclose
(
expect
,
result
))
# Now try a down-sampled ROI
# of the original source image
altsrc
=
roi
.
roi
(
src
,
[(
2
,
9
),
(
2
,
9
),
(
2
,
9
)])
altsrc
,
xf
=
resample
.
resample
(
altsrc
,
(
4
,
4
,
4
))
altsrc
=
fslimage
.
Image
(
altsrc
,
xform
=
xf
,
header
=
src
.
header
)
expect
,
xf
=
resample
.
resampleToReference
(
altsrc
,
ref
,
matrix
=
src2ref
,
order
=
1
,
mode
=
'
nearest
'
)
premat
=
affine
.
concat
(
src
.
getAffine
(
'
world
'
,
'
voxel
'
),
altsrc
.
getAffine
(
'
voxel
'
,
'
world
'
))
result
=
nonlinear
.
applyDeformation
(
altsrc
,
field
,
order
=
1
,
mode
=
'
nearest
'
,
premat
=
premat
)
assert
np
.
all
(
np
.
isclose
(
expect
,
result
))
# down-sampled and offset ROI
# of the original source image
altsrc
=
roi
.
roi
(
src
,
[(
-
5
,
8
),
(
-
5
,
8
),
(
-
5
,
8
)])
altsrc
,
xf
=
resample
.
resample
(
altsrc
,
(
6
,
6
,
6
))
altsrc
=
fslimage
.
Image
(
altsrc
,
xform
=
xf
,
header
=
src
.
header
)
expect
,
xf
=
resample
.
resampleToReference
(
altsrc
,
ref
,
matrix
=
src2ref
,
order
=
1
,
mode
=
'
nearest
'
)
premat
=
affine
.
concat
(
src
.
getAffine
(
'
world
'
,
'
voxel
'
),
altsrc
.
getAffine
(
'
voxel
'
,
'
world
'
))
result
=
nonlinear
.
applyDeformation
(
altsrc
,
field
,
order
=
1
,
mode
=
'
nearest
'
,
premat
=
premat
)
assert
np
.
all
(
np
.
isclose
(
expect
,
result
))
def
test_applyDeformation_altref
():
src2ref
=
affine
.
compose
(
np
.
random
.
randint
(
2
,
5
,
3
),
...
...
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