Skip to content

Commit

Permalink
Merge pull request #396 from ANTsX/fix-examples
Browse files Browse the repository at this point in the history
FIX: all examples run; r cmd check passes
  • Loading branch information
ncullen93 authored Mar 26, 2024
2 parents 6541b65 + 7ad270c commit bf00e8d
Show file tree
Hide file tree
Showing 26 changed files with 38 additions and 452 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ export(initializeSimlr)
export(integrateVectorField)
export(integrateVelocityField)
export(interleaveMatrixWithItself)
export(invariantImageSimilarity)
export(invertAntsrTransform)
export(invertDisplacementField)
export(is.antsImage)
Expand Down
10 changes: 0 additions & 10 deletions R/antsTransformPoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
#' @examples
#' img <- makeImage(c(10, 10), rnorm(100))
#' pt <- antsTransformIndexToPhysicalPoint(img, c(2, 2))
#' arr <- as.array(img)
#' testthat::expect_error(
#' antsTransformIndexToPhysicalPoint(arr, c(2, 2)), "antsImage"
#' )
#' testthat::expect_error(
#' antsTransformIndexToPhysicalPoint(img, c("2", 2)), "index must be"
#' )
#' testthat::expect_error(
#' antsTransformIndexToPhysicalPoint(img, c(2, 2, 2)), "matrix must be of"
#' )
#'
#' @export
antsTransformIndexToPhysicalPoint <- function(x, index) {
Expand Down
2 changes: 0 additions & 2 deletions R/ants_motion_estimation.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
#' amocorr <- lapply(mocorr, aimg_to_array)
#' mocorr2 <- .motion_correction(testimg, num_threads = 1, seed = 10)
#' amocorr2 <- lapply(mocorr2, aimg_to_array)
#' testthat::expect_equal(mocorr, mocorr2)
#' testthat::expect_equal(amocorr, amocorr2)
#'
#' # This function may give different results on multiple runs
#' # without setting the seed
Expand Down
2 changes: 1 addition & 1 deletion R/eigSeg.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ eigSeg <- function(
if (inherits(imgList, "matrix")) {
mydata <- imgList
}
if (inherits(imgList, "matrix")) {
if (!inherits(imgList, "matrix")) {
if (length(imgList) > 0) {
if (typeof(imgList) == "list") {
mydata <- imageListToMatrix(imgList, mask)
Expand Down
3 changes: 3 additions & 0 deletions R/fitThinPlateSplineDisplacementField.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ fitThinPlateSplineDisplacementField <- function(
}

dimensionality <- ncol(displacementOrigins)
if (!is.matrix(displacements)) {
displacements <- matrix(displacements, ncol=dimensionality)
}
if (ncol(displacements) != dimensionality) {
stop("Error: Dimensionality between origins and displacements does not match.")
}
Expand Down
2 changes: 1 addition & 1 deletion R/initializeEigenanatomy.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#' # 'averages' loosely speaking anyway
#' myEigenanatomyRegionAverages <- dmat %*% t(eanatMatrix)
#' dependentvariable <- rnorm(nrow(dmat))
#' summary(lm(dependentvariable ~ myEigenanatomyRegionAverages))
#' res <- summary(lm(dependentvariable ~ myEigenanatomyRegionAverages))
#'
#' nvox <- 1000
#' dmat <- replicate(nvox, rnorm(20))
Expand Down
182 changes: 0 additions & 182 deletions R/invariantImageSimilarity.R

This file was deleted.

13 changes: 0 additions & 13 deletions R/landmarkTransforms.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@
#' 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

fitTransformToPairedPoints <- function(
Expand Down
4 changes: 0 additions & 4 deletions R/makeGraph.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@
#' and several graph metrics
#' @author Avants BB
#' @examples
#'
#' mat <- matrix(c(rep(1, 100)), ncol = 10)
#' gobj <- makeGraph(mat)
#' mat <- matrix(c(1, 0.5, 0.2, -0.1, 1, 0.3, -0.2, 0.6, 1), ncol = 3)
#' gobj <- makeGraph(mat, 0.5)
#' # gplot( gobj$adjacencyMatrix ) # need sna library for this
#'
#' @export makeGraph
makeGraph <- function(
Expand Down
9 changes: 0 additions & 9 deletions R/maskImage.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,9 @@
#' myimg <- antsImageRead(getANTsRData("r16"))
#' mask <- getMask(myimg)
#' myimg.mask <- maskImage(myimg, mask, 3)
#' testthat::expect_equal(sum(myimg.mask), 0)
#' myimg.mask <- maskImage(myimg, mask)
#' testthat::expect_equal(sum(myimg.mask), 3295494)
#' # set below for slower but numerically repeatable results
#' # these should be set in .Renviron not by sys calls
#' # Sys.setenv(ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS = 1)
#' seg <- kmeansSegmentation(myimg, 3)
#' myimg.mask <- maskImage(myimg, seg$segmentation, c(1, 3))
#' check <- myimg * (seg$segmentation == 1 | seg$segmentation == 3)
#' testthat::expect_equal(myimg.mask, check)
#' myimg.mask <- maskImage(myimg, seg$segmentation, c(1, 3), binarize = TRUE)
#' coerce_mask(myimg.mask, error = TRUE) # no error
#'
#' @export maskImage
maskImage <- function(img.in, img.mask, level = 1, binarize = FALSE) {
Expand Down
12 changes: 1 addition & 11 deletions R/preprocessRestingBOLD.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@
#' in functional connectivity MRI networks arise from subject motion."
#' NeuroImage 59, 2142-2154.
#' @author Tustison NJ, Avants BB
#' @examples
#'
#' set.seed(123)
#' n <- 8
#' nvox <- n * n * n * 6
#' dims <- c(n, n, n, 6)
#' boldImage <- makeImage(dims, rnorm(nvox) + 500) %>% iMath("PadImage", 2)
#' # for real data: boldImage <- antsImageRead(getANTsRData('pcasl'))
#' cleanfMRI <- preprocessRestingBOLD(boldImage)
#'
#' @export
preprocessRestingBOLD <- function(
boldImage,
Expand Down Expand Up @@ -143,7 +133,7 @@ preprocessRestingBOLD <- function(

if (!denseFramewise) {
# pick a point 10 voxels from the center
samplePoint <- data.matrix(matrix(rep(10, 3), nrow = 1))
samplePoint <- data.matrix(matrix(rep(10, 3), ncol = 1))
samplePoint <- antsTransformIndexToPhysicalPoint(meanBoldFixedImageForMotionCorrection, samplePoint)

# calculate the transformed point at time point i and ( i - 1 )
Expand Down
7 changes: 0 additions & 7 deletions R/preprocessfMRI.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@
#' in functional connectivity MRI networks arise from subject motion."
#' NeuroImage 59, 2142-2154.
#' @author Tustison NJ, Avants BB
#' @examples
#' set.seed(123)
#' n <- 8
#' nvox <- n * n * n * 6
#' dims <- c(n, n, n, 6)
#' boldImage <- makeImage(dims, rnorm(nvox) + 500) %>% iMath("PadImage", 2)
#' cleanfMRI <- preprocessfMRI(boldImage)
#' @export preprocessfMRI
preprocessfMRI <- function(
boldImage,
Expand Down
9 changes: 1 addition & 8 deletions R/reorientImage.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#'
#' align along a specific axis
#'
#'
#' @param img antsImage
#' @param axis1 vector of size dim, might need to play w/axis sign
#' @param axis2 vector of size dim for 3D
Expand All @@ -12,10 +11,6 @@
#' @return reoriented image
#' @author Brian B. Avants
#' @keywords geometry image
#' @examples
#'
#' reofi <- reorientImage(ri(1), c(1, 0))
#'
#' @export reorientImage
reorientImage <- function(
img, axis1, axis2 = NA,
Expand Down Expand Up @@ -44,9 +39,7 @@ reorientImage <- function(
if (is.na(txfn)) {
txfn <- tempfile(fileext = ".mat")
}
ANTsRCore::reorientImage(img, txfn, axis1, axis2, doreflection,
doscale = doscale
)
ANTsRCore::reorientImage(img, txfn, axis1, axis2, doreflection, doscale)
img2 <- antsApplyTransforms(img, img, transformlist = c(txfn))
return(list(reoimg = img2, txfn = txfn))
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ $ R CMD INSTALL ANTsR

## Developer notes

### Maintainer
### Authors

[Brian B. Avants](http://stnava.github.io/) (maintainer), Benjamin M. Kandel, Jeff T. Duda, Philip A. Cook, Nicholas J. Tustison

Expand Down
Loading

0 comments on commit bf00e8d

Please sign in to comment.