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
fslpy
Commits
82c96206
Commit
82c96206
authored
Jul 23, 2017
by
Paul McCarthy
🚵
Browse files
transform method now has a 'vector' option, which skips translation.
parent
1614e9ee
Changes
1
Hide whitespace changes
Inline
Side-by-side
fsl/utils/transform.py
View file @
82c96206
...
...
@@ -412,24 +412,28 @@ def axisBounds(shape,
else
:
return
(
lo
,
hi
)
def
transform
(
p
,
xform
,
axes
=
None
):
def
transform
(
p
,
xform
,
axes
=
None
,
vector
=
False
):
"""Transforms the given set of points ``p`` according to the given affine
transformation ``xform``.
:arg p: A sequence or array of points of shape :math:`N
\\
times 3`.
:arg p:
A sequence or array of points of shape :math:`N
\\
times 3`.
:arg xform: An affine transformation matrix with which to transform the
points in ``p``.
:arg xform:
An affine transformation matrix with which to transform the
points in ``p``.
:arg axes: If you are only interested in one or two axes, and the source
axes are orthogonal to the target axes (see the note below),
you may pass in a 1D, ``N*1``, or ``N*2`` array as ``p``, and
use this argument to specify which axis/axes that the data in
``p`` correspond to.
:arg axes:
If you are only interested in one or two axes, and the source
axes are orthogonal to the target axes (see the note below),
you may pass in a 1D, ``N*1``, or ``N*2`` array as ``p``, and
use this argument to specify which axis/axes that the data in
``p`` correspond to.
:returns: The points in ``p``, transformed by ``xform``, as a ``numpy``
array with the same data type as the input.
:arg vector: Defaults to ``False``. If ``True``, the points are treated
as vectors - the translation component of the transformation
is not applied.
:returns: The points in ``p``, transformed by ``xform``, as a ``numpy``
array with the same data type as the input.
.. note:: The ``axes`` argument should only be used if the source
...
...
@@ -442,7 +446,10 @@ def transform(p, xform, axes=None):
"""
p
=
_fillPoints
(
p
,
axes
)
t
=
np
.
dot
(
xform
[:
3
,
:
3
],
p
.
T
).
T
+
xform
[:
3
,
3
]
t
=
np
.
dot
(
xform
[:
3
,
:
3
],
p
.
T
).
T
if
not
vector
:
t
=
t
+
xform
[:
3
,
3
]
if
axes
is
not
None
:
t
=
t
[:,
axes
]
...
...
Write
Preview
Supports
Markdown
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