smurf.prepare_dataframe_image¶
- smurf.prepare_dataframe_image(df_path, img_path, image_format='HE', row_number=3350, col_nuber=3350)¶
Prepares the spatial data object by mapping tissue image data to spot positions.
This function reads the high-resolution tissue image and the corresponding spot position data from a Parquet file. It calculates pixel boundaries for each spot and creates a spatial object that maps the image to the tissue spots. The spatial object can be used for downstream analysis, such as extracting spot-specific image data or overlaying spatial expression data on the image.
- Parameters:
df_path (str) – The file path to the Parquet file containing spot position data. e.g., ‘square_002um/spatial/tissue_positions.parquet’. The DataFrame should contain columns like ‘pxl_row_in_fullres’, ‘pxl_col_in_fullres’, ‘array_row’, ‘array_col’, and ‘in_tissue’.
img_path (str) – The file path to the full-resolution image. e.g., ‘Visium_HD_Mouse_Small_Intestine_tissue_image.btf’.
image_format (str, optional) – The format of the image. Must be either ‘HE’ or ‘DAPI’. Defaults to ‘HE’.
row_number (int, optional) – The number of rows in the spot array (used for calculating average spot sizes). Defaults to 3350.
col_number (int, optional) – The number of columns in the spot array (used for calculating average spot sizes). Defaults to 3350.
- Returns:
A spatial_object containing the image array, DataFrame with spot data, adjusted spot boundaries, and other spatial mappings necessary for spatial analysis.
- Return type: