ANTsX / ANTsRCore

Rcpp bindings for the C++ ANTs library used by the ANTsR package
9 stars 9 forks source link

ENH: Add moving mask options. #158

Closed ntustison closed 1 year ago

ntustison commented 1 year ago

Update following similar functionality in ANTsPy.

ntustison commented 1 year ago

Testing code:

library( ANTsR )

fixedImage <- antsImageRead( getANTsRData( "r16" ) )
fixedMask <- thresholdImage( fixedImage, 0, 0, 0, 1 )
movingImage <- antsImageRead( getANTsRData( "r64" ) )
movingMask <- thresholdImage( movingImage, 0, 0, 0, 1 )

maskOptions <- list( list( fixedMask, movingMask ),
                     list( NULL, NULL ),
                     list( fixedMask, NULL )
                      )
maskStageOptions <- c( TRUE, FALSE )

transforms <- c( "Translation","Rigid", "Similarity", "Affine", "TRSAA",
                 "SyN", "SyNRA", "SyNOnly",
                 "SyNCC","SyNabp", "SyNBold", "SyNBoldAff",
                 "SyNAggro", "SyNLessAggro", "TV[2]",
                 "TVMSQ", #  "TVMSQC",
                 "ElasticSyN","Elastic", "ElasticOnly",
                 "antsRegistrationSyNQuick[s,16]", "antsRegistrationSyN[s,2]" 
                )

for( i in seq.int( length( transforms ) ) )
  {
  for( j in seq.int( length( maskOptions ) ) )
    {
    for( k in seq.int( length( maskStageOptions ) ) )
      {
      cat( transforms[i], ": ", j, " - ", maskStageOptions[k], "\n" ) 

      reg <- antsRegistration( fixedImage, movingImage, typeofTransform = transforms[i],
                               mask = maskOptions[[j]][[1]],
                               movingMask = maskOptions[[j]][[2]],
                               maskAllStages = maskStageOptions[k]
                            #    ,
                            #    verbose = TRUE,
                            #    printArgs = TRUE 
                               )
      }
    }
  }