LDDMM with the STalign C++ engine
lddmm.RdJointly estimates an affine map A and a diffeomorphism (a velocity field v) between a
source image I and a target image J, running the C++ engine of the Python package STalign
(CPU, float64). Two problems are supported, chosen by the number of axes of the source: 2D
to 2D (LDDMM) and a 3D volume to a 2D slice (LDDMM_3D_to_slice).
Usage
lddmm(
xI,
I,
xJ,
J,
pointsI = NULL,
pointsJ = NULL,
A = NULL,
a = 500,
p = 2,
expand = NULL,
nt = 3L,
niter = 5000L,
diffeo_start = 0L,
epL = NULL,
epT = NULL,
epV = NULL,
sigmaM = 1,
sigmaB = 2,
sigmaA = 5,
sigmaR = NULL,
sigmaP = 20,
muA = NULL,
muB = NULL,
affine_step_control = NULL,
landmark_exact = TRUE,
num_threads = 1L
)Arguments
- xI
List of coordinate vectors of the source pixels, one per axis (2 or 3).
- I
Source image, array with channels first (a matrix or 3D array is one channel).
- xJ
List of coordinate vectors of the target pixels (in 3D, 2 vectors place the slice at z = 0).
- J
Target image, array with channels first (a matrix is one channel).
- pointsI, pointsJ
Optional
N x 2matrices of corresponding landmarks in the source and target (2D only).- A
Initial affine, a
(d+1) x (d+1)matrix (default: identity). It maps source coordinates to target coordinates.- a
Smoothness scale of the velocity field.
- p
Power of the Laplacian in the regularizer.
- expand
Factor by which the velocity grid extends beyond the source grid (default 2 in 2D, 1.25 in 3D).
- nt
Number of time steps of the velocity field.
- niter
Number of iterations (at least 1).
- diffeo_start
Number of initial iterations that fit the affine only.
- epL, epT, epV
Gradient step sizes of the linear part, the translation and the velocity field (defaults 2e-8, 0.2, 2e3 in 2D; 1e-6, 10, 1e3 in 3D).
- sigmaM, sigmaB, sigmaA
Standard deviations of the matching, background and artifact classes.
- sigmaR
Regularization; smaller is smoother (default 5e5 in 2D, 2e6 in 3D).
- sigmaP
Standard deviation of the landmark term.
- muA, muB
Fixed means of the artifact and background classes (one value or one per target channel).
NULLestimates them.- affine_step_control
Scale the step of every affine parameter by a multiplier that shrinks when its gradient changes sign (default
FALSEin 2D andTRUEin 3D, as in STalign).- landmark_exact
Map the landmarks with the exact inverse of the fitted map (
TRUE) or with forward Euler steps.- num_threads
Number of threads. The result does not depend on it.
Value
A list with the affine A, the velocity field v (nt x grid x d) and its grid
xv, the weights WM, WB, WA (matching, background, artifact) on the target pixels,
the deformed source AI and its contrast-fitted version fAI (channels first, target
pixels), the energies of every iteration Esave (columns E, EM, ER and, with landmarks,
EP), and, when they exist, Xs (3D: the source location sampled for each target pixel)
and pointsIt (the landmarks of pointsI mapped to the target). As in Python, A and v
are those of the last iteration's forward pass.
Details
This is only the engine: there is no affine pre-fit and no data-driven choice of sigmaR,
epL, epT, epV (the Python front-end's default). The defaults here are the fixed
defaults of STalign 1.0 (Python's legacy_defaults = TRUE) and depend on the units and
intensity scale of the data, so set them for your data. Coordinates are assumed to be in
micrometers.
Arrays follow the Python package: channels first, I has dimensions c(C, n1, n2) (2D) or
c(C, n1, n2, n3) (3D), the target J has c(C, m1, m2) (a matrix is one channel; in 3D the
target is a slice, with c(C, 1, m1, m2) also accepted), and the first axis is the "row"
axis. xI and xJ are lists with the pixel coordinates along each axis, and landmarks are
(row, column) coordinates.