Skip to content

Commit

Permalink
changes to affine image loading
Browse files Browse the repository at this point in the history
  • Loading branch information
jiajic committed Nov 14, 2024
1 parent 2eb0db1 commit 0b325c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## bug fixes
- fix cell metadata desyncing after `joinGiottoObjects()`
- fix `readExprMatrix()` when IDs are numerical barcodes
- fix `giottoAffineImage` not being detected during `saveGiotto()` image export step.
- fix `giottoAffineImage` `reconnect()` method

## enhancements
Expand Down
17 changes: 9 additions & 8 deletions R/save_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' @param overwrite Overwrite existing folders
#' @param export_image logical. Write out an image of the format specified by
#' `image_filetype` when saving a `giottoLargeImage`.
#' Future image loads will point to this new file.
#' Future image loads and reconnects will point to this new file.
#' @param image_filetype the image filetype to use, see
#' \code{\link[terra]{writeRaster}}. Default is "PNG". For TIFF outputs, try
#' "COG"
Expand Down Expand Up @@ -371,13 +371,8 @@ loadGiotto <- function(path_to_folder,
)

if (isTRUE(reconnect_giottoImage)) {
if (!is.null(list_images(gobject))) {
if (list_images(gobject)[img_type == "image", .N] > 0) {
gobject <- reconnectGiottoImage(gobject,
reconnect_type = "image"
)
}
}
imglist <- lapply(gobject[["images"]], reconnect)
gobject <- setGiotto(gobject, imglist, verbose = FALSE)
}


Expand Down Expand Up @@ -693,6 +688,10 @@ loadGiotto <- function(path_to_folder,
}


# the actual reconnection step is done through reconnect() after this step now
# .update_giotto_image() <- this is NEEDED for legacy structure support
# raster reload <- not needed
# filepath update <- now done after this, but useful for legacy saves
.load_giotto_images <- function(gobject, path_to_folder, verbose = NULL) {
vmsg(.v = verbose, "4. read Giotto image information")
vmsg(
Expand Down Expand Up @@ -727,6 +726,8 @@ loadGiotto <- function(path_to_folder,
spatRaster <- terra::rast(load_img)

gobject@images[[img]]@raster_object <- spatRaster
# file path updating now happens during export, but keep this in for
# legacy saved object support
gobject@images[[img]]@file_path <- load_img
gobject@images[[img]] <- .update_giotto_image(gobject@images[[img]])
gobject@images[[img]] <- initialize(gobject@images[[img]])
Expand Down

0 comments on commit 0b325c5

Please sign in to comment.