Skip to content

Commit

Permalink
Merge pull request #415 from ANTsX/init_reg_deformable_only
Browse files Browse the repository at this point in the history
ENH: identity init transform for "deformable only" reg
  • Loading branch information
cookpa authored Dec 14, 2024
2 parents 0adcee0 + 289f6c8 commit c8ccc71
Showing 1 changed file with 16 additions and 5 deletions.
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

0 comments on commit c8ccc71

Please sign in to comment.