Skip to content

Commit

Permalink
ENH: More.
Browse files Browse the repository at this point in the history
  • Loading branch information
ntustison committed Feb 24, 2023
1 parent 551ac27 commit fc0d33d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 65 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export(fastMarchingExtension)
export(filterfMRIforNetworkAnalysis)
export(fitBsplineDisplacementField)
export(fitBsplineObjectToScatteredData)
export(fitTimeVaryingTransformToPointSets)
export(fitTransformToPairedPoints)
export(frequencyFilterfMRI)
export(fsl2antsrTransform)
Expand Down
49 changes: 14 additions & 35 deletions R/fitTransformToPairedPoints.R → R/landmarkTransforms.R
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ fitTransformToPairedPoints <- function(
updateDerivativeField <- createZeroVelocityField( domainImage, numberOfIntegrationPoints )
updateDerivativeFieldArray <- as.array( updateDerivativeField )

for( n in seq.int( numberOfIntegrationPoints ) )
for( n in seq_len( numberOfIntegrationPoints ) )
{
t <- ( n - 1 ) / ( numberOfIntegrationPoints - 1.0 )

Expand Down Expand Up @@ -585,35 +585,7 @@ fitTransformToPairedPoints <- function(
#' @return object containing ANTsR transform, error, and scale (or displacement field)
#'
#' @author B Avants, N Tustison
#' @examples
#' fixed <- matrix( c( 50, 50, 200, 50, 50, 200 ), ncol = 2, byrow = TRUE )
#' moving <- matrix( c( 50, 50, 50, 200, 200, 200 ), ncol = 2, byrow = TRUE )
#'
#' # Affine transform
#' xfrm <- fitTransformToPairedPoints( moving, fixed, transformType = "Affine", regularization = 0 )
#' params <- getAntsrTransformParameters( xfrm )
#'
#' # Rigid transform
#' xfrm <- fitTransformToPairedPoints( moving, fixed, transformType = "Rigid", regularization = 0 )
#' params <- getAntsrTransformParameters( xfrm )
#'
#' # Similarity transform
#' xfrm <- fitTransformToPairedPoints( moving, fixed, transformType = "Similarity", regularization = 0 )
#' params <- getAntsrTransformParameters( xfrm )
#'
#' # B-spline transform
#' domainImage <- antsImageRead( getANTsRData( "r16" ) )
#' xfrm <- fitTransformToPairedPoints( moving, fixed, transformType = "Bspline", domainImage = domainImage, numberOfFittingLevels = 5 )
#'
#' # Diffeo transform
#' domainImage <- antsImageRead( getANTsRData( "r16" ) )
#' xfrm <- fitTransformToPairedPoints( moving, fixed, transformType = "Diffeo", domainImage = domainImage, numberOfFittingLevels = 6 )
#'
#' # SyN transform
#' domainImage <- antsImageRead( getANTsRData( "r16" ) )
#' xfrm <- fitTransformToPairedPoints( moving, fixed, transformType = "SyN", domainImage = domainImage, numberOfFittingLevels = 6, numberOfCompositions = 10, compositionStepSize = 0.01 )
#' @export fitTransformToPairedPoints

#' @export fitTimeVaryingTransformToPointSets
fitTimeVaryingTransformToPointSets <- function(
pointSets,
timePoints = NULL,
Expand Down Expand Up @@ -675,7 +647,7 @@ fitTimeVaryingTransformToPointSets <- function(
stop( "The number of time points should be the same as the number of point sets." )
}

if( ! is.null( timePoints ) )
if( is.null( timePoints ) )
{
timePoints <- seq( from = 0.0, to = 1.0, length.out = numberOfPointSets )
}
Expand All @@ -685,6 +657,11 @@ fitTimeVaryingTransformToPointSets <- function(
stop( "Time point values should be between 0 and 1." )
}

if( is.null( numberOfIntegrationPoints ) )
{
numberOfIntegrationPoints <- length( timePoints )
}

if( numberOfIntegrationPoints < numberOfPointSets )
{
stop( "The number of integration points should be at least as great as the number of point sets." )
Expand Down Expand Up @@ -733,7 +710,7 @@ fitTimeVaryingTransformToPointSets <- function(
updateDerivativeField <- createZeroVelocityField( domainImage, numberOfIntegrationPoints )
updateDerivativeFieldArray <- as.array( updateDerivativeField )

for( n in seq.int( numberOfIntegrationPoints ) )
for( n in seq_len( numberOfIntegrationPoints ) )
{
t <- ( n - 1 ) / ( numberOfIntegrationPoints - 1.0 )

Expand All @@ -747,7 +724,7 @@ fitTimeVaryingTransformToPointSets <- function(
}
}

if( n > 1 && n < number_of_integration_points && timePoints[tIndex-1] == t )
if( n > 1 && n < numberOfIntegrationPoints && timePoints[tIndex-1] == t )
{
updatedFixedPoints <- pointSets[[tIndex-1]]
integratedInverseField <- integrateVelocityField( velocityField, timePoints[tIndex], t, 100 )
Expand Down Expand Up @@ -804,6 +781,8 @@ fitTimeVaryingTransformToPointSets <- function(

if( t == 1.0 && timePoints[tIndex] == 1.0 )
{
updatedMovingPoints <- pointSets[[length( pointSets )]]
} else {
integratedInverseField <- integrateVelocityField( velocityField, timePoints[tIndex], t, 100 )
integratedInverseFieldXfrm <- createAntsrTransform( type = "DisplacementFieldTransform", displacement.field = integratedInverseField )
updatedMovingPoints <- applyAntsrTransformToPoint( integratedInverseFieldXfrm, pointSets[[tIndex]] )
Expand Down Expand Up @@ -862,10 +841,10 @@ fitTimeVaryingTransformToPointSets <- function(
}
}

integratedForwardField <- integrateVelocityField( velocityField, 0.0, t, 100 )
integratedForwardField <- integrateVelocityField( velocityField, 0.0, 1.0, 100 )
forwardXfrm <- createAntsrTransform( type = "DisplacementFieldTransform", displacement.field = integratedForwardField )

integratedInverseField <- integrateVelocityField( velocityField, 1.0, t, 100 )
integratedInverseField <- integrateVelocityField( velocityField, 1.0, 0.0, 100 )
inverseXfrm <- createAntsrTransform( type = "DisplacementFieldTransform", displacement.field = integratedInverseField )

if( verbose )
Expand Down
30 changes: 1 addition & 29 deletions man/fitTimeVaryingTransformToPointSets.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/fitTransformToPairedPoints.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fc0d33d

Please sign in to comment.