A reglist is read as a set of transformations to be applied sequentially starting with the first element, then applying the second transformation to the result of the first and so on. Each individual transformation is considered to map data from the sample (floating/moving) space to the reference (fixed/template) space.

Each transformation may have an attribute "swap" indicating that the natural direction of the transformation should be swapped (i.e. inverted). This can be done trivially in the case of affine transformations, expensively for others such as CMTK registrations (see cmtkreg) and not at all for others. Note that the term 'swap' is used to avoid a direct equivalence with inversion - many registration tools use the term inverse for directions that one might naively think of as as the natural direction of the transformation (see xformpoints.cmtkreg for discussion).

invert_reglist inverts a reglist object

c.reglist combines multiple reglists into a single reglist.

reglist(..., swap = NULL)

invert_reglist(x)

# S3 method for reglist
c(..., recursive = FALSE)

Arguments

...

One or more transformations/reglists to combine

swap

A vector of the same length as ... indicating whether the direction of each transformation should be swapped (i.e. mapping reference -> sample).

x

A reglist object to invert

recursive

Presently ignored

Details

The swap argument is provided as a convenience, but an attribute 'swap' can also be set directly on each registration.

Inversion

invert_reglist takes a minimal approach to inversion. It reverses the order of the individual elements of the registration and tags each of them with a swap attribute (or changes the value of the attribute if it already exists)

See also

Examples

I=diag(4)
S=I
diag(S)=c(1, 2, 3, 1)
rl=reglist(S, I)
rli=invert_reglist(rl)

## We can check the inversion by simplifying
m=simplify_reglist(rl)[[1]]
mi=simplify_reglist(rli)[[1]]
# NB solve will invert a homogeneous affine matrix
all.equal(m, solve(mi))
#> [1] TRUE
I=diag(4)
S=I
diag(S)=c(1, 2, 3, 1)
rl=reglist(S, I)
rl2=c(rl, 'path/to/my/reg.list')
rl3=c(reglist('path/to/my/reg.list'), rl)