Skip to content
Snippets Groups Projects
Commit e255a176 authored by Jean-Karim Heriche's avatar Jean-Karim Heriche
Browse files

Fix handling of ome-zarr.

parent bf0fc354
No related branches found
No related tags found
Loading
......@@ -29,7 +29,7 @@ explore_image_server <-function(input, output, session, rv, parent_input){
if(!is.null(rv$imgPath1) && length(unique(rv$imgPath1)) == 1 &&
length(unique(rv$selectedFrame)) <= 1 &&
!is.null(rv$fileCol1) && rv$fileCol1 != ""){
if(grepl("\\.ome\\.zarr\\/", rv$imgPath1[1])) { # NGFF, use omeRarr
if(grepl("\\.ome\\.zarr", rv$imgPath1[1])) { # NGFF, use omeRarr
s3.client <- NULL
img.idx <- 1 # Assume object coordinates refer to highest resolution level
if(class(rv$imgRoot)[1] == "s3_bucket") { # Images are in a S3 bucket
......@@ -48,25 +48,28 @@ explore_image_server <-function(input, output, session, rv, parent_input){
}
## NGFF dimensions order is t,c,z,y,x
size <- as.list(omeRarr::get_image_dims(filePath1, image.idx = img.idx, s3.client))
## Set a dimension to NA to get everything in this dimension
slice <- list(t = NA, c = NA, z = NA, y = NA, x = NA)
# Some older files only specify dimensions > 1
if(is.null(size$z)) {size$z <- 1}
if(is.null(size$c)) {size$c <- 1}
if(is.null(size$t)) {size$t <- 1}
## Set a dimension to NULL to get everything in this dimension
slice <- list(t = NA, c = NA, z = NA, y = NULL, x = NULL)
if(!is.null(rv$roiFrame) && rv$roiFrame != "") {
## Figure out what the 3rd dimension is
if(size$z == 1 && size$t > 1 && size$c == 1) {
slice$t <- unique(rv$selectedFrame)
slice$z <- NA
slice$c <- NA
slice$z <- NULL
slice$c <- NULL
} else if(size$z > 1 && size$t == 1 && size$c == 1) {
slice$z <- unique(rv$selectedFrame)
slice$t <- NA
slice$c <- NA
slice$t <- NULL
slice$c <- NULL
} else if(size$z == 1 && size$t == 1 && size$c > 1) {
slice$c <- unique(rv$selectedFrame)
slice$z <- NA
slice$t <- NA
slice$z <- NULL
slice$t <- NULL
}
}
print(slice)
I <- tryCatch(
{ omeRarr::get_image(filePath1, image.idx = img.idx, slice = slice, s3.client = s3.client) },
error = function(e) {
......
......@@ -25,7 +25,7 @@ explore_image_server2 <-function(input, output, session, rv){
if(!is.null(rv$imgPath2) && length(unique(rv$imgPath2)) == 1 &&
length(unique(rv$selectedFrame)) <= 1 &&
!is.null(rv$fileCol2) && rv$fileCol2 != ""){
if(grepl("\\.ome\\.zarr\\/", rv$imgPath2[1])) { # NGFF, use omeRarr
if(grepl("\\.ome\\.zarr", rv$imgPath2[1])) { # NGFF, use omeRarr
s3.client <- NULL
img.idx <- 1 # Assume object coordinates refer to highest resolution level
if(class(rv$imgRoot)[1] == "s3_bucket") { # Images are in a S3 bucket
......@@ -44,22 +44,26 @@ explore_image_server2 <-function(input, output, session, rv){
}
## NGFF dimensions order is t,c,z,y,x
size <- as.list(omeRarr::get_image_dims(filePath1, image.idx = img.idx, s3.client))
# Some older files only specify dimensions > 1
if(is.null(size$z)) {size$z <- 1}
if(is.null(size$c)) {size$c <- 1}
if(is.null(size$t)) {size$t <- 1}
## Set a dimension to NA to get everything in this dimension
slice <- list(t = NA, c = NA, z = NA, y = NA, x = NA)
slice <- list(t = NA, c = NA, z = NA, y = NULL, x = NULL)
if(!is.null(rv$roiFrame) && rv$roiFrame != "") {
## Figure out what the 3rd dimension is
if(size$z == 1 && size$t > 1 && size$c == 1) {
slice$t <- unique(rv$selectedFrame)
slice$z <- NA
slice$c <- NA
slice$z <- NULL
slice$c <- NULL
} else if(size$z > 1 && size$t == 1 && size$c == 1) {
slice$z <- unique(rv$selectedFrame)
slice$t <- NA
slice$c <- NA
slice$t <- NULL
slice$c <- NULL
} else if(size$z == 1 && size$t == 1 && size$c > 1) {
slice$c <- unique(rv$selectedFrame)
slice$z <- NA
slice$t <- NA
slice$z <- NULL
slice$t <- NULL
}
}
I <- tryCatch(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment