Skip to content

Commit

Permalink
ns fixes for mirror_banc
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferis committed Jul 1, 2024
1 parent 7ee26fc commit d1672b5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ Suggests:
spelling,
arrow,
knitr,
nat.nblast
nat.nblast,
Morpho
Remotes:
natverse/nat,
natverse/nat.nblast,
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 5 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
check_package_available <- function(pkg) {
if(!requireNamespace(pkg, quietly = TRUE)) {
stop("Please install suggested package: ", pkg)
}
}
9 changes: 6 additions & 3 deletions R/xform.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand All @@ -122,7 +126,6 @@ mirror_banc <- function(x, units=c("nm", "microns", "raw"), subset=NULL) {

xyzf=mirror_brain(x, brain = BANCmesh, mirrorAxis = 'X', transform = 'flip')
xyzf2=xform(xyzf, reg = fancr::mirror_banc_lm)

# convert from nm to original units if necessary
if(units=='microns')
xyzf2=xyzf2/1e3
Expand Down
2 changes: 1 addition & 1 deletion man/mirror_banc.Rd

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

0 comments on commit d1672b5

Please sign in to comment.