Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nitransforms/manip.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ def _as_chain(x):
"""Convert a value into a transform chain."""
if isinstance(x, TransformChain):
return x.transforms
if isinstance(x, TransformBase):
return [x]
if isinstance(x, Iterable):
return list(x)
return [x]
Expand Down
14 changes: 14 additions & 0 deletions nitransforms/tests/test_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ def test_loadsave_itk(tmp_path, data_path, testdata_path):
)


def test_mapping_chain(data_path):
xfm = nitl.load(data_path / "itktflist2.tfm", fmt="itk")
xfm = nitl.load(data_path / "itktflist2.tfm", fmt="itk")
assert len(xfm) == 9

# Addiition produces a chain
chain = xfm + xfm
# Length now means number of transforms, not number of affines in one transform
assert len(chain) == 2
# Just because a LinearTransformsMapping is iterable does not mean we decompose it
chain += xfm
assert len(chain) == 3


@pytest.mark.parametrize(
"image_orientation",
[
Expand Down
Loading