Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: reduce unused or rarely used dependencies #395

Merged
merged 18 commits into from
Mar 24, 2024
Merged
30 changes: 25 additions & 5 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +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:
schedule:
- cron: '0 0 * * *'
pull_request:
branches: [main, master]

name: R-CMD-check

@@ -21,6 +21,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true

steps:
- uses: actions/checkout@v4
@@ -33,10 +34,29 @@ jobs:
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v3
with:
extra-packages: any::rcmdcheck
needs: check
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1
restore-keys: |
${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1
${{ runner.os }}-${{ hashFiles('.github/R-version') }}
${{ runner.os }}-

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- uses: r-lib/actions/check-r-package@v2
with:
18 changes: 6 additions & 12 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -5,11 +5,11 @@ Version: 0.6.0
Date: 2024-03-23
Authors@R: c(
person(c("Brian", "B"), "Avants", role = c("aut", "cre"), email = "stnava@gmail.com"),
person(c("Benjamin", "M"), "Kandel", role = "ctb", email = "NA"),
person(c("Jeff", "T"), "Duda", role = "ctb", email = "NA"),
person(c("Philip", "A"), "Cook", role = "ctb", email = "NA"),
person(c("Nicholas", "J"), "Tustison", role = "ctb", email = "NA"),
person(c("Dorian"), "Pustina", role = "ctb", email = "NA")
person(c("Benjamin", "M"), "Kandel", role = "ctb"),
person(c("Jeff", "T"), "Duda", role = "ctb"),
person(c("Philip", "A"), "Cook", role = "ctb"),
person(c("Nicholas", "J"), "Tustison", role = "ctb"),
person(c("Dorian"), "Pustina", role = "ctb")
)
Maintainer: Brian B. Avants <stnava@gmail.com>
Description: ANTsR interfaces state of the art image processing with R
@@ -33,8 +33,8 @@ Imports:
stats,
utils
Suggests:
colormap,
magic,
psych,
rsvd,
abind,
BGLR,
@@ -43,12 +43,10 @@ Suggests:
corpcor,
dplyr,
e1071,
extremevalues,
fastICA,
fpc,
ggplot2,
glasso,
glmnet,
grid,
hdf5r,
igraph,
@@ -57,14 +55,11 @@ Suggests:
MASS,
Matrix,
mFilter,
misc3d,
moments,
networkD3,
pixmap,
png,
pracma,
randomForest,
R.matlab,
RcppEigen,
RcppHNSW,
rgl,
@@ -76,7 +71,6 @@ Suggests:
testthat,
tools,
viridis,
visreg,
xgboost,
FNN
LazyData: TRUE
65 changes: 5 additions & 60 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -124,6 +124,7 @@ export(combineNuisancePredictors)
export(compcor)
export(components)
export(composeAntsrTransforms)
export(composeDisplacementFields)
export(composeTransformsToField)
export(computeDVARS)
export(computeDVARSspatialMap)
@@ -279,11 +280,8 @@ export(readNormalizedPopulationData)
export(reflectImage)
export(reflectionMatrix)
export(regressProjections)
export(regressionNetworkViz)
export(regularizeSimlr)
export(reho)
export(renderImageLabels)
export(renderSurfaceFunction)
export(renormalizeProbabilityImages)
export(reorientImage)
export(resampleImage)
@@ -398,9 +396,12 @@ exportMethods(tan)
exportMethods(tanh)
exportMethods(tanpi)
exportMethods(trunc)
import(ANTsRCore)
import(grDevices)
import(methods)
import(stats)
import(tools)
import(utils)
importFrom(grDevices,colorRampPalette)
importFrom(grDevices,dev.new)
importFrom(grDevices,dev.off)
@@ -426,60 +427,4 @@ importFrom(graphics,title)
importFrom(magrittr,"%>%")
importFrom(methods,is)
importFrom(methods,new)
importFrom(stats,ar)
importFrom(stats,as.formula)
importFrom(stats,chisq.test)
importFrom(stats,coefficients)
importFrom(stats,convolve)
importFrom(stats,cor)
importFrom(stats,cor.test)
importFrom(stats,cov)
importFrom(stats,density)
importFrom(stats,dist)
importFrom(stats,dnorm)
importFrom(stats,formula)
importFrom(stats,glm)
importFrom(stats,lm)
importFrom(stats,lm.fit)
importFrom(stats,loess)
importFrom(stats,median)
importFrom(stats,model.frame)
importFrom(stats,model.matrix)
importFrom(stats,model.response)
importFrom(stats,na.omit)
importFrom(stats,optim)
importFrom(stats,optimize)
importFrom(stats,p.adjust)
importFrom(stats,pchisq)
importFrom(stats,pf)
importFrom(stats,pnorm)
importFrom(stats,ppois)
importFrom(stats,prcomp)
importFrom(stats,predict)
importFrom(stats,pt)
importFrom(stats,qchisq)
importFrom(stats,qf)
importFrom(stats,qnorm)
importFrom(stats,qt)
importFrom(stats,quantile)
importFrom(stats,residuals)
importFrom(stats,rnorm)
importFrom(stats,sd)
importFrom(stats,spec.pgram)
importFrom(stats,spline)
importFrom(stats,stl)
importFrom(stats,t.test)
importFrom(stats,toeplitz)
importFrom(stats,ts)
importFrom(stats,var)
importFrom(utils,capture.output)
importFrom(utils,data)
importFrom(utils,download.file)
importFrom(utils,glob2rx)
importFrom(utils,install.packages)
importFrom(utils,read.csv)
importFrom(utils,setTxtProgressBar)
importFrom(utils,tail)
importFrom(utils,txtProgressBar)
importFrom(utils,unzip)
importFrom(utils,write.csv)
importFrom(stats,AIC)
14 changes: 14 additions & 0 deletions R/ANTsR-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#' @title Advanced Normalization Tools in R
#' @name ANTsR
#'
#' @importFrom stats AIC
#'
#' @import ANTsRCore stats grDevices utils
#'
#' @keywords internal
"_PACKAGE"
# The following block is used by usethis to automatically manage
# roxygen namespace tags. Modify with care!
## usethis namespace: start
## usethis namespace: end
NULL
24 changes: 3 additions & 21 deletions R/abpBrainExtraction.R
Original file line number Diff line number Diff line change
@@ -20,9 +20,6 @@
#' @return outputs a brain image and brain mask.
#' @author Tustison N, Avants BB
#' @examples
#'
#' Sys.setenv(ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS = 1)
#' set.seed(1)
#' n <- 64
#' fn <- getANTsRData("r16")
#' img <- antsImageRead(fn)
@@ -33,25 +30,10 @@
#' temmask <- antsImageClone(tem)
#' temmask[tem > 20] <- 1
#' temmask[tem <= 20] <- 0
#' bm <- ANTsR::abpBrainExtraction(img = img, tem = tem, temmask = temmask, num_threads = 1)
#' stopifnot(sum(bm$bmask) != prod(dim(bm$brain)))
#' bm2 <- ANTsR::abpBrainExtraction(img = img, tem = tem, temmask = temmask, num_threads = 1)
#' stopifnot(sum(bm2$bmask) != prod(dim(bm2$brain)))
#'
#' \dontrun{
#' bm <- abpBrainExtraction(img = img, tem = tem, temmask = temmask)
#' }
#' @export abpBrainExtraction
#' @importFrom magrittr %>%
#' @importFrom graphics hist par plot points
#' @importFrom grDevices colorRampPalette dev.off hsv png rainbow rgb
#' @importFrom methods new
#' @importFrom stats ar as.formula coefficients convolve
#' cor cor.test cov dist formula glm lm
#' lm.fit loess median model.matrix na.omit
#' optimize p.adjust pchisq pf pnorm ppois
#' predict pt qchisq qf qnorm qt quantile
#' residuals rnorm sd spec.pgram spline stl
#' t.test toeplitz ts var
#' @importFrom utils data glob2rx read.csv setTxtProgressBar tail
#' txtProgressBar write.csv
abpBrainExtraction <- function(img, tem, temmask,
temregmask = NULL, regtype = "SyN", tdir = NA,
num_threads = 1,
2 changes: 1 addition & 1 deletion R/abpN4.R
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ abpN4 <- function(
mask, usen3 = FALSE,
...) {
numargs <- nargs()
if (numargs < 1 | missing(img) | class(img)[1] != "antsImage") {
if (numargs < 1 | missing(img) | !inherits(img, "antsImage")) {
stop("Missing image.")
}
if (length(intensityTruncation) != 3) {
11 changes: 0 additions & 11 deletions R/antsAffineInitializer.R
Original file line number Diff line number Diff line change
@@ -31,17 +31,6 @@
#' mi2 <- resampleImage(mi, c(1.25, 1.25))
#' tx <- affineInitializer(fi, mi2)
#' tx2 <- affineInitializer(fi, mi2)
#' if ("R.matlab" %in% installed.packages()) {
#' tx_hdr <- R.matlab::readMat(tx)
#' trans <- tx_hdr$AffineTransform.double.2.2
#' fixed <- tx_hdr$fixed
#'
#' tx2_hdr <- R.matlab::readMat(tx2)
#' trans2 <- tx2_hdr$AffineTransform.double.2.2
#' fixed2 <- tx2_hdr$fixed
#'
#' testthat::expect_equal(tx_hdr, tx2_hdr)
#' }
#'
#' @export affineInitializer
affineInitializer <- function(
6 changes: 3 additions & 3 deletions R/antsApplyTransformsToPoints.R
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
#' moving <- resampleImage(moving, c(64, 64), 1, 0)
#' mytx <- antsRegistration(
#' fixed = fixed, moving = moving,
#' typeofTransform = c("SyN"), verbose = TRUE
#' typeofTransform = c("SyN"), verbose = FALSE
#' )
#' pts <- data.frame(
#' x = c(110.5, 120, 130), y = c(108.1, 121.0, 130),
@@ -104,7 +104,7 @@ antsApplyTransformsToPoints <- function(
)
}
}
if (class(points)[[1]] != "antsImage") {
if (!inherits(points, "antsImage")) {
usepts <- as.antsImage(data.matrix(points))
} else {
usepts <- antsImageClone(points)
@@ -125,7 +125,7 @@ antsApplyTransformsToPoints <- function(
}
ANTsRCore::antsApplyTransformsToPoints(c(myargs, "-f", 1, "--precision", 0))

if (class(points)[[1]] == "antsImage") {
if (inherits(points, "antsImage")) {
return(pointsout)
}
pointsout <- data.frame(as.matrix(pointsout))
2 changes: 1 addition & 1 deletion R/antsAverageImages.R
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ antsAverageImages <- function(imageList, normalize = FALSE, weights,
verbose = TRUE) {
# determine if input is list of images or filenames
isfile <- FALSE
if (class(imageList) == "character") {
if (inherits(imageList, "character")) {
if (any(!file.exists(imageList))) {
stop("One or more files do not exist.")
}
4 changes: 0 additions & 4 deletions R/antsBOLDNetworkAnalysis.R
Original file line number Diff line number Diff line change
@@ -55,7 +55,6 @@ antsBOLDNetworkAnalysis <- function(
}
return(x)
}
# if ( !usePkg("psych") ) { print("Need pysch package"); return(NULL) }
# if ( !usePkg("glasso") ) { print("Need glasso package"); return(NULL) }
# if ( !usePkg("igraph") ) { print("Need igraph package"); return(NULL) }
stopifnot(!is.null(bold))
@@ -133,9 +132,6 @@ antsBOLDNetworkAnalysis <- function(
bgdnuis <- bgsvd$u[, 1:newnuisv]
colnames(bgdnuis) <- paste("bgdNuis", 1:newnuisv, sep = "")
}
if (winsortrim > 0) {
omat <- psych::winsor(omat, trim = winsortrim)
}
omat <- omat[keepinds, ]
##################################################
classiccompcor <- compcor(omat, mask = mask, ncompcor = 4)
4 changes: 2 additions & 2 deletions R/antsCopyImageInfo.R
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
antsCopyImageInfo <- function(reference, target) {
reference <- check_ants(reference)
target <- check_ants(target)
if (!(class(reference) == "antsImage") || !(class(target) == "antsImage")) {
if (!(inherits(reference, "antsImage")) || !(inherits(target, "antsImage"))) {
stop("Both inputs must be of class 'antsImage'")
}
antsSetOrigin(target, as.numeric(antsGetOrigin(reference)))
@@ -47,7 +47,7 @@ antsCopyImageInfo <- function(reference, target) {
antsCopyImageInfo2 <- function(target, reference) {
reference <- check_ants(reference)
target <- check_ants(target)
if (!(class(reference) == "antsImage") || !(class(target) == "antsImage")) {
if (!(inherits(reference, "antsImage")) || !(inherits(target, "antsImage"))) {
stop("Both inputs must be of class 'antsImage'")
}
antsSetOrigin(target, as.numeric(antsGetOrigin(reference)))
6 changes: 3 additions & 3 deletions R/antsImageRead.R
Original file line number Diff line number Diff line change
@@ -23,16 +23,16 @@
antsImageRead <- function(filename, dimension = NULL, pixeltype = "float") {
components <- 1

if (class(filename) != "character" || length(filename) != 1) {
if (!is.character(filename) || length(filename) != 1) {
stop("'filename' argument must be of class 'character' and have length 1")
}
filename <- path.expand(filename)
if (!file.exists(filename)) stop("file does not exist")
if (class(pixeltype) != "character" || length(pixeltype) != 1) {
if (!is.character(pixeltype) || length(pixeltype) != 1) {
stop("'pixeltype' argument must be of class 'character' and have length 1")
}
if (!is.null(dimension)) {
if (((class(dimension) != "numeric") && (class(dimension) != "integer")) || length(dimension) !=
if (((!is.numeric(dimension)) && (!is.integer(dimension))) || length(dimension) !=
1) {
stop("'dimension' argument must be of class 'numeric' and have length 1")
}
Loading