This function is useful for automatically cropping the images. It finds the edge points (min and max on both the X and Y axis) in pixels based on a particular image. This function takes advantage of the known design of Visium slides as documented at and That is, that for a regular Visium slide, the array row has a range from 0 to 77, the array col from 0 to 127, the capture area has a 6.5 mm edge length, the the fiducial frame area has an edge of 8 mm, and spot centers are about 100 um from each other.

  image_id = "lowres",
  visium_grid = list(row_min = 0, row_max = 77, col_min = 0, col_max = 127,
    fiducial_vs_capture_edge = (8 - 6.5) * 1000/2/100)



Defaults to the output of fetch_data(type = 'spe'). This is a SpatialExperiment-class object with the spot-level Visium data and information required for visualizing the histology. See fetch_data() for more details.


A character(1) specifying which sample to plot from colData(spe)$sample_id (formerly colData(spe)$sample_name).


A character(1) with the name of the image ID you want to use in the background.


A named list with the parameters known about the Visium grid. This can change for Visium HD vs regular Visium for example.


A named list with y_min, y_max, x_min, and x_max pixels from the selected image that can be used for cropping the image.

See also

Other Spatial cluster visualization functions: vis_clus_p(), vis_clus(), vis_grid_clus()


Louise Huuki-Myers and Leonardo Collado-Torres


if (enough_ram()) {
    ## Obtain the necessary data
    if (!exists("spe")) spe <- fetch_data("spe")

    ## Obtain the frame limits for one sample
    frame_limits(spe, sampleid = "151673")
#> 2023-09-05 20:30:50.967142 loading file /github/home/.cache/R/BiocFileCache/152d33414640_Human_DLPFC_Visium_processedData_sce_scran_spatialLIBD.Rdata%3Fdl%3D1
#> $y_min
#> [1] 64
#> $y_max
#> [1] 575
#> $x_min
#> [1] 62
#> $x_max
#> [1] 588