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(..., swap = NULL) invert_reglist(x) # S3 method for reglist c(..., recursive = FALSE)
One or more transformations/reglists to combine
A vector of the same length as
A reglist object to invert
The swap argument is provided as a convenience, but an attribute
'swap' can also be set directly on each registration.
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)
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)[] mi=simplify_reglist(rli)[] # NB solve will invert a homogeneous affine matrix all.equal(m, solve(mi))#>  TRUE