Skip to content

Commit 7cf699d

Browse files
authored
Merge pull request #422 from ANTsX/IncCheck
BUG: Remove labelGeom dependency and fix logic bug.
2 parents 5fb52b1 + fc1efaf commit 7cf699d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

R/labelImageRegistration.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#' specifically the family of \code{antsRegistrationSyN*[so]} or
2121
#' \code{antsRegistrationSyN*[bo]} transforms. See 'typeOfTransform'
2222
#' in \code{antsRegistration}. Additionally, one can use a list
23-
#' to pass a more tailored deformably-only transform optimization using
23+
#' to pass a more tailored deformable-only transform optimization using
2424
#' SyN or BSplineSyN transforms. The order of parameters in the list
2525
#' would be 1) transform specification, i.e. "SyN" or "BSplineSyN",
2626
#' 2) gradient (real), 3) intensity metric (string), 4) intensity metric
@@ -137,10 +137,10 @@ labelImageRegistration <- function( fixedLabelImages, movingLabelImages,
137137
totalNumberOfLabels <- 0
138138
for( i in seq.int( length( fixedLabelImages ) ) )
139139
{
140-
fixedLabelGeoms <- labelGeometryMeasures( fixedLabelImages[[i]] )
141-
fixedLabelIds <-fixedLabelGeoms$Label
142-
movingLabelGeoms <- labelGeometryMeasures( movingLabelImages[[i]] )
143-
movingLabelIds <- movingLabelGeoms$Label
140+
fixedLabelIds <- unique( fixedLabelImages[[i]] )
141+
fixedLabelIds <- fixedLabelIds[! fixedLabelIds %in% c( 0 )]
142+
movingLabelIds <- unique( movingLabelImages[[i]] )
143+
movingLabelIds <- movingLabelIds[! movingLabelIds %in% c( 0 )]
144144
commonLabelIds[[i]] <- intersect( fixedLabelIds, movingLabelIds )
145145
totalNumberOfLabels = totalNumberOfLabels + length( commonLabelIds[[i]] )
146146
if( verbose )
@@ -411,7 +411,7 @@ labelImageRegistration <- function( fixedLabelImages, movingLabelImages,
411411

412412
fwdtransforms <- c()
413413
invtransforms <- c()
414-
if( is.null( linearXfrm ) )
414+
if( ! is.null( linearXfrm ) )
415415
{
416416
if( length( findInverseWarps ) > 0 )
417417
{
@@ -432,7 +432,7 @@ labelImageRegistration <- function( fixedLabelImages, movingLabelImages,
432432
if( verbose )
433433
{
434434
message( "\n\nResulting transforms" )
435-
if( length( findInverseWarps ) > 0 )
435+
if( length( fwdtransforms ) > 1 )
436436
{
437437
message( paste0( " fwdtransforms: [", fwdtransforms[1], ", ", fwdtransforms[2], "]" ) )
438438
message( paste0( " invtransforms: [", invtransforms[1], ", ", invtransforms[2], "]" ) )

0 commit comments

Comments
 (0)