From 3e5d0d59b8832e4065f4d97c6b0bda60f3cc1354 Mon Sep 17 00:00:00 2001 From: Gregory Jefferis Date: Fri, 9 Sep 2016 22:03:35 +0100 Subject: [PATCH] Fix error messages for missing sample brain --- R/transformation.R | 8 ++++++++ man/mirror_brain.Rd | 3 +++ man/xform_brain.Rd | 3 +++ 3 files changed, 14 insertions(+) diff --git a/R/transformation.R b/R/transformation.R index bb273f3..ee2488d 100644 --- a/R/transformation.R +++ b/R/transformation.R @@ -288,6 +288,7 @@ shortest_bridging_seq <- #' directions. See details. #' @param ... extra arguments to pass to \code{\link[nat]{xform}}. #' @export +#' @seealso \code{\link{mirror_brain}}, \code{\link{regtemplate}} #' @examples #' ## depends on nat.flybrains package and system CMTK installation #' \dontrun{ @@ -329,6 +330,9 @@ shortest_bridging_seq <- #' } xform_brain <- function(x, sample=regtemplate(x), reference, via=NULL, imagedata=is.character(x), checkboth=NULL, ...) { + if(is.null(sample)) + stop("Invalid sample argument!\n", + "Either specify manually or use regtemplate(x) <- to set space for x.") if(is.null(via)) { # use bridging_graph, with checkboth = TRUE if(is.null(checkboth)) checkboth=TRUE @@ -354,6 +358,7 @@ xform_brain <- function(x, sample=regtemplate(x), reference, via=NULL, #' @param transform whether to use warp (default) or affine component of #' registration, or simply flip about midplane of axis. #' @param ... extra arguments to pass to \code{\link[nat]{mirror}}. +#' @seealso \code{\link{xform_brain}}, \code{\link{regtemplate}} #' @export #' @examples #' data(FCWB.demo) @@ -395,6 +400,9 @@ xform_brain <- function(x, sample=regtemplate(x), reference, via=NULL, mirror_brain <- function(x, brain=regtemplate(x), mirrorAxis=c("X","Y","Z"), transform = c("warp", "affine", "flip"), ...) { transform=match.arg(transform) + if(is.null(brain)) + stop("Invalid brain argument!\n", + "Either specify manually or use regtemplate(x) <- to set space for x.") warpfile <- if(transform=="flip") NULL else mirror_reg(brain) mirrorAxis <- match.arg(mirrorAxis) axisCol <- which(mirrorAxis == c("X", "Y", "Z")) diff --git a/man/mirror_brain.Rd b/man/mirror_brain.Rd index 2a43d2b..4037d34 100644 --- a/man/mirror_brain.Rd +++ b/man/mirror_brain.Rd @@ -60,4 +60,7 @@ diffs=xyzmatrix(kcs20.jfrc2.flip)-xyzmatrix(kcs20.jfrc2.right) hist(sqrt(rowSums(diffs^2)), xlab='Distance /microns') } } +\seealso{ +\code{\link{xform_brain}}, \code{\link{regtemplate}} +} diff --git a/man/xform_brain.Rd b/man/xform_brain.Rd index 2722f5a..06e0a5b 100644 --- a/man/xform_brain.Rd +++ b/man/xform_brain.Rd @@ -91,4 +91,7 @@ xform_brain('labels.nrrd', sample=FCWB, ref=JFRC2, output='out.nrrd', interpolat xform_brain('in.nrrd', sample=FCWB, ref=JFRC2, output='out.nrrd', mask='neuropil.nrrd') } } +\seealso{ +\code{\link{mirror_brain}}, \code{\link{regtemplate}} +}