Skip to content

Commit 2edfce6

Browse files
committed
fix: also revise asaffine
1 parent 7f1657c commit 2edfce6

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

nitransforms/manip.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99
"""Common interface for transforms."""
1010
from collections.abc import Iterable
11+
import numpy as np
1112

1213
from .base import (
1314
TransformBase,
@@ -139,10 +140,19 @@ def map(self, x, inverse=False):
139140

140141
return x
141142

142-
def asaffine(self):
143-
"""Combine a succession of linear transforms into one."""
144-
retval = self.transforms[-1]
145-
for xfm in self.transforms[:-1][::-1]:
143+
def asaffine(self, indices=None):
144+
"""
145+
Combine a succession of linear transforms into one.
146+
147+
Parameters
148+
----------
149+
indices : :obj:`numpy.array_like`
150+
The indices of the values to extract.
151+
152+
"""
153+
affines = self.transforms if indices is None else np.take(self.transforms, indices)
154+
retval = affines[0]
155+
for xfm in affines[1:]:
146156
retval @= xfm
147157
return retval
148158

0 commit comments

Comments
 (0)