Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: identity init transform for "deformable only" reg #415

Merged
merged 1 commit into from
Dec 14, 2024
Merged
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
21 changes: 16 additions & 5 deletions R/antsRegistration.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#' information metric by default. See \code{Details.}
#' @param initialTransform either a single transform file name, a vector of transform file names,
#' or a single antsTransform object. If NA, an initial translation aligns the center of mass
#' of the moving image to that of the fixed image.
#' of the moving image to that of the fixed image, unless the transform is "deformable only", in which case
#' the intial transform is 'Identity'.
#' @param outprefix output will be named with this prefix.
#' @param mask Registration metric mask in the fixed image space.
#' @param movingMask Registration metric mask in the moving image space.
Expand Down Expand Up @@ -410,9 +411,19 @@ antsRegistration <- function(
earlyMaskOption <- "[NA,NA]"
}

# Set up initial transform args
# If no transform is provided, default to align the centers of mass UNLESS the tranform
# is one of the "deformable only" transforms
if (length(initx) == 1 && is.na(initx)) {
initx <- paste("[", f, ",", m, ",1]", sep = "")
deformableOnlyTransforms <- c("SyNOnly", "ElasticOnly", "TVMSQ", "TVMSQC", tvTypes)

if ((typeofTransform %in% deformableOnlyTransforms)) {
initx <- "Identity"
} else {
initx <- paste("[", f, ",", m, ",1]", sep = "")
}
}

if (typeofTransform == "SyNBold") {
args <- list(
"-d", as.character(fixed@dimension), "-r", initx,
Expand Down Expand Up @@ -703,7 +714,7 @@ antsRegistration <- function(
sep = ""
)
args <- list(
"-d", as.character(fixed@dimension), # "-r", initx,
"-d", as.character(fixed@dimension), "-r", initx,
"-m", paste(synMetric, "[", f, ",", m, ",1,", synSampling, "]", sep = ""),
"-t", tvtx,
"-c", paste("[", synits, ",1e-7,8]", collapse = ""),
Expand All @@ -721,7 +732,7 @@ antsRegistration <- function(
sep = ""
)
args <- list(
"-d", as.character(fixed@dimension), # "-r", initx,
"-d", as.character(fixed@dimension), "-r", initx,
"-m", paste("demons[", f, ",", m, ",0.5,0]", sep = ""),
"-m", paste("meansquares[", f, ",", m, ",1,0]", sep = ""),
"-t", tvtx,
Expand All @@ -744,7 +755,7 @@ antsRegistration <- function(
sep = ""
)
args <- list(
"-d", as.character(fixed@dimension), # "-r", initx,
"-d", as.character(fixed@dimension), "-r", initx,
"-m", paste(synMetric, "[", f, ",", m, ",1,", synSampling, "]", sep = ""),
"-t", tvtx,
"-c", paste("[", synits, ",1e-7,8]", collapse = ""),
Expand Down
Loading