@@ -131,7 +131,10 @@ setMethod("data_type", "DelayedArray", \(x) {
131131 v <- tryCatch(.ome_ver(x ), error = \(e ) NULL )
132132 if (is.null(v )) return ()
133133 if (v == " 0.5" ) x <- x $ ome
134- unlist(x $ omero $ channels )
134+ # NOTE: can't use 'vapply' as we
135+ # have encountered integer 'label's
136+ x <- x $ omero $ channels
137+ x $ label %|| % unlist(lapply(x , `[[` , " label" ))
135138}
136139
137140# ' @export
@@ -173,8 +176,6 @@ setMethod("channels", "SpatialDataElement", \(x, ...) stop("only 'images' have c
173176# https://github.com/Huber-group-EMBL/Rarr/blob/1795c676e2ac81a9ba2a592c7210cc59036544b6/R/utils.R#L74-L79
174177.sub <- \(x , ix ) rlang :: inject(x [!!! ix , drop = FALSE ])
175178
176- # ' @exportMethod [
177- # ' @rdname SpatialDataArray
178179# ' @importFrom utils head tail
179180.sub_sda <- \(x , yx , z = list ()) {
180181 # x <- label(sd); yx <- list(1:10, 1:10); z <- list()
@@ -208,13 +209,17 @@ setMethod("channels", "SpatialDataElement", \(x, ...) stop("only 'images' have c
208209 x
209210}
210211
212+ # ' @exportMethod [
213+ # ' @rdname SpatialDataArray
211214setMethod ("[ ", "SpatialDataImage", \(x, i, j, k, ..., drop=FALSE) {
212215 if (missing(i )) i <- TRUE
213216 if (missing(j )) j <- TRUE else if (isFALSE(j )) j <- 0 else .check_jk(j , " j" )
214217 if (missing(k )) k <- TRUE else if (isFALSE(k )) k <- 0 else .check_jk(k , " k" )
215218 .sub_sda(x , yx = list (j , k ), z = list (i ))
216219})
217220
221+ # ' @exportMethod [
222+ # ' @rdname SpatialDataArray
218223setMethod ("[ ", "SpatialDataLabel", \(x, i, j, ..., drop=FALSE) {
219224 if (missing(i )) i <- TRUE else if (isFALSE(i )) i <- 0 else .check_jk(i , " i" )
220225 if (missing(j )) j <- TRUE else if (isFALSE(j )) j <- 0 else .check_jk(j , " j" )
0 commit comments