Skip to content

Commit

Permalink
Merge pull request #52 from natverse/fix/suggset-morpho
Browse files Browse the repository at this point in the history
Suggest Morpho instead of importing it
  • Loading branch information
jefferis committed Aug 17, 2023
2 parents 4e78156 + 670ccb7 commit 1b6c5f2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Expand Up @@ -27,14 +27,14 @@ Imports:
digest,
igraph,
memoise,
rappdirs,
Morpho
rappdirs
Suggests:
spelling,
git2r (>= 0.22.1),
nabor,
testthat (>= 2.1.0),
covr
covr,
Morpho
Encoding: UTF-8
RoxygenNote: 7.2.3
BugReports: https://github.com/natverse/nat.templatebrains/issues
Expand Down
12 changes: 8 additions & 4 deletions R/fit-xform.R
Expand Up @@ -8,7 +8,7 @@
#' @param refpts An optional set of points in the target (fixed) space matching
#' \code{samplepts}. You must either supply this or the \code{reg} argument.
#' @param type A character string specifying the type of registration. See
#' \code{\link{computeTransform}} for details.
#' \code{Morpho::computeTransform} for details.
#' @param scale a 2-vector indicating the amount to scale the sample and
#' reference points. You can supply one vector if this is the same. If the
#' transform expects points in microns and returns points in microns then you
Expand All @@ -17,12 +17,15 @@
#' @param subsample A number of points to subsample from
#' \code{samplepts,refpts}. The default value of \code{FALSE} means use all
#' provided points to calculate the new transform.
#' @param ... Additional arguments passed to \code{\link{computeTransform}}
#' @param ... Additional arguments passed to \code{Morpho::computeTransform}
#'
#' @return A homogeneous affine matrix or a \code{nat::tpsreg} object
#' n.b. only in development nat (>= 1.10.1)
#' @return A homogeneous affine matrix or a \code{nat::tpsreg} object n.b. only
#' in development nat (>= 1.10.1)
#' @export
#'
#' @details NB this function relies on installation of the suggested package
#' Morpho.
#'
#' @examples
#' \dontrun{
#' library(nat.flybrains)
Expand Down Expand Up @@ -53,6 +56,7 @@ fit_xform <- function(reg, samplepts, refpts=NULL, type = c("affine","rigid", "s
refpts=xform(samplepts, reg)
type=match.arg(type)
if(length(scale)==1) scale=rep(scale,2)
check_package_available("Morpho")
xt=Morpho::computeTransform(refpts*scale[2], samplepts*scale[1], type=type, ...)
if(type=='tps') {
class(xt)=union('tpsreg', class(xt))
Expand Down
5 changes: 5 additions & 0 deletions R/utils.R
@@ -0,0 +1,5 @@
check_package_available <- function(pkg) {
if(!requireNamespace(pkg, quietly = TRUE)) {
stop("Please install suggested package: ", pkg)
}
}
12 changes: 8 additions & 4 deletions man/fit_xform.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/fit_xform_brain.Rd

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

0 comments on commit 1b6c5f2

Please sign in to comment.