Skip to content

Commit

Permalink
fix: also revise asaffine
Browse files Browse the repository at this point in the history
  • Loading branch information
oesteban committed Jul 18, 2022
1 parent 7f1657c commit 2edfce6
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions nitransforms/manip.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Common interface for transforms."""
from collections.abc import Iterable
import numpy as np

from .base import (
TransformBase,
Expand Down Expand Up @@ -139,10 +140,19 @@ def map(self, x, inverse=False):

return x

def asaffine(self):
"""Combine a succession of linear transforms into one."""
retval = self.transforms[-1]
for xfm in self.transforms[:-1][::-1]:
def asaffine(self, indices=None):
"""
Combine a succession of linear transforms into one.
Parameters
----------
indices : :obj:`numpy.array_like`
The indices of the values to extract.
"""
affines = self.transforms if indices is None else np.take(self.transforms, indices)
retval = affines[0]
for xfm in affines[1:]:
retval @= xfm
return retval

Expand Down

0 comments on commit 2edfce6

Please sign in to comment.