diff --git a/DESCRIPTION b/DESCRIPTION index 040ca43..df934b1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -38,7 +38,8 @@ Suggests: spelling, arrow, knitr, - nat.nblast + nat.nblast, + Morpho Remotes: natverse/nat, natverse/nat.nblast, diff --git a/NAMESPACE b/NAMESPACE index a8409a8..342f3b5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -37,9 +37,12 @@ export(with_fanc) import(bit64) import(fafbseg) import(nat.flybrains) +importFrom(nat,"xyzmatrix<-") importFrom(nat,tpsreg) importFrom(nat,xform) importFrom(nat,xyzmatrix) +importFrom(nat.templatebrains,mirror_brain) +importFrom(nat.templatebrains,templatebrain) importFrom(pbapply,pbsapply) importFrom(utils,browseURL) importFrom(utils,read.csv) diff --git a/R/utils.R b/R/utils.R new file mode 100644 index 0000000..223ab34 --- /dev/null +++ b/R/utils.R @@ -0,0 +1,5 @@ +check_package_available <- function(pkg) { + if(!requireNamespace(pkg, quietly = TRUE)) { + stop("Please install suggested package: ", pkg) + } +} diff --git a/R/xform.R b/R/xform.R index 41be7ab..4a31f41 100644 --- a/R/xform.R +++ b/R/xform.R @@ -90,8 +90,10 @@ transform_fanc2manc <- function(x, inverse = F, ...) { #' @param units Units for both input \emph{and} output data. #' @param subset Optional argument to transform only a subset of a neuron list. #' -#' @return Trge transformed object (calibrated according to the units argument) +#' @return The transformed object (calibrated according to the units argument) #' @export +#' @importFrom nat.templatebrains mirror_brain templatebrain +#' @importFrom nat xyzmatrix<- #' #' @examples #' BANC.surf.m <- mirror_banc(BANC.surf) @@ -102,11 +104,13 @@ transform_fanc2manc <- function(x, inverse = F, ...) { #' wire3d(BANC.surf.m, col='red') #' } mirror_banc <- function(x, units=c("nm", "microns", "raw"), subset=NULL) { + # for thin plate splines + check_package_available("Morpho") units=match.arg(units) if(!is.null(subset)) { xs=x[subset] - xst=mirror_banc(xs, units = units, mirror_reg = fancr::mirror_banc_lm) + xst=mirror_banc(xs, units = units) x[subset]=xst return(x) }