|
3 | 3 | #' @aliases axes CTlist CTname CTtype CTdata addCT rmvCT |
4 | 4 | #' |
5 | 5 | #' @param x \code{SpatialData}, an element, or \code{SpatialDataAttrs}. |
| 6 | +#' @param y NULL (default) returns a list where each element is |
| 7 | +#' an axis: a list with name/type/unit (e.g., x/space/micrometer); |
| 8 | +#' \code{y="name/type/unit"} extracts specific data over all axiis. |
6 | 9 | #' @param i for \code{CTpath}, source node label; else, string or |
7 | 10 | #' scalar integer giving the name or index of a coordinate space. |
8 | 11 | #' @param name character(1); name of coordinate space |
|
51 | 54 |
|
52 | 55 | #' @rdname CTutils |
53 | 56 | #' @export |
54 | | -setMethod("axes", "SpatialDataAttrs", \(x, ...) { |
| 57 | +setMethod("axes", "SpatialDataAttrs", \(x, y=NULL, ...) { |
55 | 58 | ms <- multiscales(x) |
56 | 59 | if (!is.null(ms)) x <- ms[[1]] |
57 | 60 | if (is.null(x <- x$axes)) stop("couldn't find 'axes'") |
58 | | - return(x) |
| 61 | + if (is.null(y)) return(x) |
| 62 | + y <- match.arg(y, c("name", "type", "unit")) |
| 63 | + vapply(x, `[[`, character(1), y) |
59 | 64 | }) |
60 | 65 |
|
61 | 66 | # CTlist/data/type/name() ---- |
@@ -105,7 +110,7 @@ setMethod("CTname", "SpatialDataAttrs", \(x, ...) { |
105 | 110 |
|
106 | 111 | #' @rdname CTutils |
107 | 112 | #' @export |
108 | | -setMethod("axes", "SpatialDataElement", \(x, ...) axes(meta(x), ...)) |
| 113 | +setMethod("axes", "SpatialDataElement", \(x, y=NULL, ...) axes(meta(x), y, ...)) |
109 | 114 |
|
110 | 115 | #' @rdname CTutils |
111 | 116 | #' @export |
|
0 commit comments