### Install latest release of spatialdata-io Source: https://github.com/scverse/spatialdata-io/blob/main/docs/index.md Installs the latest stable version of the spatialdata-io package from PyPI. This is the recommended method for most users. ```bash pip install spatialdata-io ``` -------------------------------- ### Install development version of spatialdata-io Source: https://github.com/scverse/spatialdata-io/blob/main/docs/index.md Installs the latest development version of spatialdata-io directly from its GitHub repository. This is useful for users who want to test the newest features or contribute to the project. ```bash pip install git+https://github.com/scverse/spatialdata-io.git@main ``` -------------------------------- ### Install spatialdata-io via pip Source: https://github.com/scverse/spatialdata-io/blob/main/README.md Commands to install the spatialdata-io package from PyPI or the latest development version from GitHub. Requires Python 3.8 or newer. ```bash pip install spatialdata-io ``` ```bash pip install git+https://github.com/scverse/spatialdata-io.git@main ``` -------------------------------- ### Load and annotate seqfish dataset Source: https://github.com/scverse/spatialdata-io/blob/main/docs/generated/spatialdata_io.seqfish.md This example demonstrates how to load a seqfish dataset from a directory and update the annotation target of the table from cell labels to cell boundaries. It concludes by saving the processed SpatialData object to a Zarr store. ```python from spatialdata_io import seqfish # Load the dataset sdata = seqfish("path/to/raw/data") # Update annotation target to cell boundaries sdata["table_Roi1"].obs["region"] = "Roi1_Boundaries" sdata.set_table_annotates_spatialelement( table_name="table_Roi1", region="Roi1_Boundaries", region_key="region", instance_key="instance_id" ) # Save the result sdata.write("path/to/data.zarr") ``` -------------------------------- ### GET /spatialdata_io/curio Source: https://github.com/scverse/spatialdata-io/blob/main/docs/generated/spatialdata_io.curio.md Reads a Curio formatted dataset from the specified directory path and returns a SpatialData object. ```APIDOC ## GET /spatialdata_io/curio ### Description Reads a Curio formatted dataset. The function automatically infers the dataset_id from the provided path and loads associated h5ad, txt, and csv files. ### Method GET ### Endpoint /spatialdata_io/curio ### Parameters #### Query Parameters - **path** (str | Path) - Required - Path to the directory containing the Curio data files. ### Request Example { "path": "/data/curio_dataset_01" } ### Response #### Success Response (200) - **SpatialData** (Object) - A SpatialData object containing the loaded counts, metadata, and spatial features. #### Response Example { "status": "success", "data": "SpatialData object initialized" } ``` -------------------------------- ### Python Reader Function Signature for spatialdata-io Source: https://github.com/scverse/spatialdata-io/blob/main/docs/contributing.md Defines the expected signature for a reader function in spatialdata-io. It takes a path to the raw data and optional arguments, returning a SpatialData object. This structure ensures consistency across different data readers. ```python from pathlib import Path from spatialdata import SpatialData def technology(path: str | Path, ...) -> SpatialData: # `sdata` is constructed return sdata ``` -------------------------------- ### Write and Read Data to Zarr with SpatialData-IO (Python) Source: https://github.com/scverse/spatialdata-io/blob/main/docs/index.md This Python code snippet demonstrates how to parse data using a spatialdata-io reader, write it to Zarr format, and then read it back. This process is crucial for enabling the performance advantages of the SpatialData Zarr format for visualization. ```python from spatialdata_io import xenium from spatialdata import read_zarr sdata = xenium("raw_data") sdata.write("data.zarr") sdata = read_zarr("sdata.zarr") ``` -------------------------------- ### Read 10x Genomics Visium HD Data with spatialdata-io Source: https://context7.com/scverse/spatialdata-io/llms.txt Loads 10x Genomics Visium HD data, supporting multiple bin sizes, cell segmentation, and nucleus segmentation. Allows specifying which bin sizes to load, whether to use filtered counts, and how to represent bins (squares or circles). Includes options for loading microscopy images and annotating tables. ```python from spatialdata_io import visium_hd # Basic usage - loads all bin sizes sdata = visium_hd("path/to/visium_hd_output/") # Load specific bin sizes only sdata = visium_hd( "path/to/visium_hd_output/", dataset_id="sample_001", bin_size=[2, 8, 16], # Load 2um, 8um, 16um bins filtered_counts_file=True, # Use filtered (not raw) counts bins_as_squares=True, # Represent bins as squares load_all_images=True, # Include CytAssist image fullres_image_file="microscope_image.btf", # Full-res microscopy image annotate_table_by_labels=False, # Annotate by shapes (not labels) load_nucleus_segmentations=True, # Load nucleus segmentation data ) ``` -------------------------------- ### spatialdata_io.experimental.to_legacy_anndata Source: https://github.com/scverse/spatialdata-io/blob/main/docs/generated/spatialdata_io.experimental.to_legacy_anndata.md Converts a SpatialData object to a legacy spatial AnnData object, useful for compatibility with packages like Scanpy and older versions of Squidpy. Images can optionally be included. ```APIDOC ## spatialdata_io.experimental.to_legacy_anndata ### Description Converts a SpatialData object to a (legacy) spatial AnnData object. This is useful for using packages expecting spatial information in AnnData, for example Scanpy and older versions of Squidpy. Using this format for any new package is not recommended. This function by default ignores images (recommended); setting the `include_images` parameter to `True` will include a downscaled version of the images in the output AnnData object. ### Method `spatialdata_io.experimental.to_legacy_anndata` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **sdata** (`SpatialData`) – Required - SpatialData object. * **coordinate_system** (`str` | `None`) – Optional - The coordinate system to consider. The AnnData object will be populated with the data transformed to this coordinate system. * **table_name** (`str` | `None`) – Optional - The name of the table in the SpatialData object to consider. If None and the SpatialData object has only one table, that table will be used. * **include_images** (`bool`) – Optional - If True, includes downscaled versions of the images in the output AnnData object. It is recommended to handle the full resolution images separately and keep them in the SpatialData object. ### Request Example ```python import spatialdata import spatialdata_io # Assuming sdata is a loaded SpatialData object sdata = spatialdata.SpatialData(...) # Convert to legacy AnnData, excluding images legacy_adata = spatialdata_io.experimental.to_legacy_anndata(sdata) # Convert to legacy AnnData, including images legacy_adata_with_images = spatialdata_io.experimental.to_legacy_anndata(sdata, include_images=True) ``` ### Response #### Success Response (200) * **AnnData** (`AnnData`) - The legacy spatial AnnData object. #### Response Example ```python # Example of a returned AnnData object structure (simplified) # adata.obs # adata.var # adata.obsm['spatial'] # adata.uns['spatial'] ``` ``` -------------------------------- ### spatialdata_io.visium Source: https://github.com/scverse/spatialdata-io/blob/main/docs/generated/spatialdata_io.visium.md Reads 10x Genomics Visium formatted datasets, including counts, images, and spatial information. ```APIDOC ## spatialdata_io.visium ### Description Reads *10x Genomics* Visium formatted dataset. This function reads counts, metadata, and image files associated with Visium data. ### Method `spatialdata_io.visium` ### Endpoint N/A (This is a Python function, not a REST endpoint) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters * **path** (`str` | `Path`) - Required - Path to the directory containing the data. * **dataset_id** (`str` | `None`) - Optional - Dataset identifier to name the constructed `SpatialData` elements. The reader will try to infer it from the counts file name. If the file name does not contain the dataset id, it needs to be provided. * **counts_file** (`str`) - Optional - Name of the counts file, defaults to `'filtered_feature_bc_matrix.h5'`; a common alternative is `'raw_feature_bc_matrix.h5'`. Also, use when the file names are not following the standard SpaceRanger conventions. * **fullres_image_file** (`str` | `Path` | `None`) - Optional - Path to the full-resolution image. * **tissue_positions_file** (`str` | `Path` | `None`) - Optional - Path to the tissue positions file. * **scalefactors_file** (`str` | `Path` | `None`) - Optional - Path to the scalefactors file. * **var_names_make_unique** (`bool`) - Optional - If `True`, call `.var_names_make_unique()` on each `AnnData` table. Defaults to `True`. * **imread_kwargs** (`Mapping[str, Any]`) - Optional - Keyword arguments passed to `dask_image.imread.imread()`. Defaults to an empty mapping. * **image_models_kwargs** (`Mapping[str, Any]`) - Optional - Keyword arguments passed to `spatialdata.models.Image2DModel`. Defaults to an empty mapping. ### Request Example ```python import spatialdata_io # Example usage: sdata = spatialdata_io.visium(path="/path/to/visium/data/") ``` ### Response #### Success Response (Return Type) * **SpatialData** (`spatialdata.SpatialData`) - The function returns a `SpatialData` object containing the loaded dataset. #### Response Example ```python # The returned object is a SpatialData object, which is a complex data structure. # Example of accessing elements (conceptual): # print(sdata.tables['counts']) # print(sdata.images['hires']) ``` ### SEE ALSO * [Space Ranger output](https://support.10xgenomics.com/spatial-gene-expression/software/pipelines/latest/output/overview) ``` -------------------------------- ### Load 10x Genomics Visium HD dataset Source: https://github.com/scverse/spatialdata-io/blob/main/docs/generated/spatialdata_io.visium_hd.md Reads a Visium HD formatted dataset from a specified directory. It returns a SpatialData object containing the transcriptomic counts, images, and optional segmentation data. ```python import spatialdata_io sdata = spatialdata_io.visium_hd( path="/path/to/visium_hd_data", dataset_id="my_sample", filtered_counts_file=True, bin_size=8, bins_as_squares=True ) ``` -------------------------------- ### Change Annotation Target for Xenium Data (Python) Source: https://github.com/scverse/spatialdata-io/blob/main/docs/generated/spatialdata_io.xenium.md This snippet shows how to load Xenium data, change the annotation target from cell circles to cell labels, and save the modified data. It uses the `spatialdata_io.xenium` function and `sdata.set_table_annotates_spatialelement` method. Ensure the paths for input and output are correctly specified. ```python from spatialdata_io import xenium sdata = xenium("path/to/raw/data", cells_as_circles=True) sdata["table"].obs["region"] = "cell_labels" sdata.set_table_annotates_spatialelement( table_name="table", region="cell_labels", region_key="region", instance_key="cell_labels" ) sdata.write("path/to/data.zarr") ``` -------------------------------- ### Read image files with chunking and pyramid control Source: https://context7.com/scverse/spatialdata-io/llms.txt Reads image files, such as TIFFs, with fine-grained control over chunking and pyramid generation. It supports memory-mapped reading for large TIFFs and allows custom chunk sizes and scale factors for pyramid building, optimizing performance and memory usage. ```python from spatialdata_io import image # Read with custom chunking image_element = image( "path/to/large_image.tif", data_axes=("c", "y", "x"), coordinate_system="global", use_tiff_memmap=True, # Memory-mapped reading for large TIFFs chunks={"c": 1, "y": 4096, "x": 4096}, # Custom chunk sizes scale_factors=[2, 2, 2, 2], # Build image pyramid ) ``` -------------------------------- ### Read 10x Genomics Visium Data with spatialdata-io Source: https://context7.com/scverse/spatialdata-io/llms.txt Loads standard 10x Genomics Visium spatial gene expression data, including spot coordinates, count matrices, and tissue images. Supports automatic inference of dataset IDs and custom file specifications. The loaded data includes multiple coordinate systems for different image resolutions. ```python from spatialdata_io import visium # Basic usage with automatic dataset ID inference sdata = visium("path/to/visium_output/") # Specify custom options sdata = visium( "path/to/visium_output/", dataset_id="my_sample", # Custom element naming counts_file="filtered_feature_bc_matrix.h5", # Default counts file fullres_image_file="tissue_image.tif", # Optional full-res image tissue_positions_file=None, # Auto-detected scalefactors_file=None, # Auto-detected ) # Access elements spots = sdata.shapes["my_sample"] # Spot locations as circles table = sdata.tables["table"] # Gene expression matrix hires = sdata.images["my_sample_hires_image"] # High-res tissue image lowres = sdata.images["my_sample_lowres_image"] # Low-res tissue image # Coordinates are provided in multiple coordinate systems print(sdata.coordinate_systems) # ['my_sample', 'my_sample_downscaled_hires', 'my_sample_downscaled_lowres'] ``` -------------------------------- ### Read Image or GeoJSON Files with generic reader Source: https://context7.com/scverse/spatialdata-io/llms.txt Automatically detects file type and reads images (.tif, .tiff, .png, .jpg, .jpeg) or shapes (.geojson). For images, it's required to specify the data axes (e.g., ('c', 'y', 'x')) and optionally a coordinate system. ```python from spatialdata_io import generic # Read an image file image_element = generic( "path/to/image.tif", data_axes=("c", "y", "x"), # Required for images coordinate_system="global", # Optional, defaults to "global" ) ``` -------------------------------- ### Read 10x Genomics Visium dataset with Python Source: https://github.com/scverse/spatialdata-io/blob/main/docs/generated/spatialdata_io.visium.md This function reads a Visium dataset from a specified directory path. It automatically detects standard file names like 'filtered_feature_bc_matrix.h5' and 'tissue_positions.csv' to construct a SpatialData object. ```python import spatialdata_io # Read a Visium dataset from a directory sdata = spatialdata_io.visium(path="/path/to/visium_data", dataset_id="sample_01") # Access the resulting SpatialData object print(sdata) ``` -------------------------------- ### Read 10x Genomics Xenium Data with spatialdata-io Source: https://context7.com/scverse/spatialdata-io/llms.txt Loads 10x Genomics Xenium spatial transcriptomics data, including morphology images, cell/nucleus boundaries, transcripts, and gene expression. Supports automatic version detection and various loading options. The loaded data can be written to Zarr format for efficient storage and visualization. ```python from spatialdata_io import xenium from spatialdata import read_zarr # Basic usage - load all components sdata = xenium("path/to/xenium_output/") # Load with specific options sdata = xenium( "path/to/xenium_output/", cells_boundaries=True, # Load cell boundary polygons nucleus_boundaries=True, # Load nucleus boundary polygons cells_as_circles=False, # Represent cells as polygons (not circles) cells_labels=True, # Load rasterized cell labels nucleus_labels=True, # Load rasterized nucleus labels transcripts=True, # Load transcript locations morphology_mip=True, # Load MIP image (versions < 2.0) morphology_focus=True, # Load focus image aligned_images=True, # Load additional H&E/IF images cells_table=True, # Load cell annotations table gex_only=True, # Load only Gene Expression features ) # Write to Zarr for efficient visualization sdata.write("xenium_data.zarr") sdata = read_zarr("xenium_data.zarr") # Access loaded elements print(sdata.images) # Morphology images print(sdata.shapes) # Cell/nucleus boundaries print(sdata.points) # Transcript locations print(sdata.tables) # Gene expression matrix # Change table annotation target from circles to labels sdata["table"].obs["region"] = "cell_labels" sdata.set_table_annotates_spatialelement( table_name="table", region="cell_labels", region_key="region", instance_key="cell_labels" ) ``` -------------------------------- ### Convert legacy AnnData to SpatialData Source: https://context7.com/scverse/spatialdata-io/llms.txt Converts legacy AnnData objects, typically from Scanpy or Squidpy, into the SpatialData format. This function facilitates the migration of existing spatial datasets to the newer SpatialData structure, preserving images, spot locations, and annotations. ```python from spatialdata_io.experimental import from_legacy_anndata import scanpy as sc # Load legacy spatial AnnData adata = sc.read_h5ad("legacy_spatial_data.h5ad") # Convert to SpatialData sdata = from_legacy_anndata(adata, rgb=True) # Access converted elements print(sdata.images) # Converted hires/lowres images print(sdata.shapes) # Spot locations from obsm['spatial'] print(sdata.tables) # Original AnnData with region annotations ``` -------------------------------- ### Read Mcmicro Output to SpatialData (Python) Source: https://github.com/scverse/spatialdata-io/blob/main/docs/generated/spatialdata_io.mcmicro.md Reads Mcmicro output into a SpatialData object. Accepts path to the dataset and optional keyword arguments for image reading and model processing. Returns a SpatialData object. ```python from spatialdata_io import mcmicro # Example usage: sdata = mcmicro(path="/path/to/mcmicro/output") # With custom arguments: sdata = mcmicro( path="/path/to/mcmicro/output", imread_kwargs={"scale_factors": [1, 2, 4]}, image_models_kwargs={"segmentation_key": "cell_masks"} ) ``` -------------------------------- ### spatialdata_io.geojson Source: https://github.com/scverse/spatialdata-io/blob/main/docs/generated/spatialdata_io.geojson.md Reads a GeoJSON file and converts it into a GeoDataFrame spatial element. ```APIDOC ## GET spatialdata_io.geojson ### Description Reads a GeoJSON file and returns a parsed GeoDataFrame spatial element for use within the spatialdata ecosystem. ### Method GET ### Endpoint spatialdata_io.geojson(input, coordinate_system) ### Parameters #### Path Parameters - **input** (str) - Required - The file path or URL to the GeoJSON file. - **coordinate_system** (str) - Required - The coordinate system identifier to assign to the spatial element. ### Request Example spatialdata_io.geojson(input="path/to/data.geojson", coordinate_system="epsg:4326") ### Response #### Success Response (200) - **GeoDataFrame** (object) - A geopandas GeoDataFrame containing the parsed spatial features. #### Response Example { "type": "GeoDataFrame", "data": "..." } ``` -------------------------------- ### Read Vizgen MERSCOPE Data with spatialdata-io Source: https://context7.com/scverse/spatialdata-io/llms.txt Reads MERSCOPE data, supporting multiple z-layers and optional Vizgen Post-processing Tool (VPT) outputs. This function can load transcript locations, cell boundaries, cell expression tables, and mosaic images. It also allows specifying z-layers, region names, slide names, and choosing a backend for lower RAM usage. ```python from spatialdata_io import merscope # Basic usage sdata = merscope("path/to/merscope_output/") # Load with specific z-layers and VPT outputs sdata = merscope( "path/to/merscope_output/", z_layers=[0, 3, 6], # Load specific z-layers (default: 3) region_name="region_0", # Custom region name slide_name="slide_001", # Custom slide name vpt_outputs="path/to/vpt/", # Use VPT segmentation results transcripts=True, # Load transcript locations cells_boundaries=True, # Load cell boundary polygons cells_table=True, # Load cell expression table mosaic_images=True, # Load mosaic images backend="rioxarray", # Use rioxarray for lower RAM usage ) # Or use VPT outputs with explicit file paths sdata = merscope( "path/to/merscope_output/", vpt_outputs={ "counts": "path/to/cell_by_gene.csv", "obs": "path/to/cell_metadata.csv", "boundaries": "path/to/cell_boundaries.parquet", }, ) # Access elements transcripts = sdata.points["slide_001_region_0_transcripts"] boundaries = sdata.shapes["slide_001_region_0_polygons"] z3_image = sdata.images["slide_001_region_0_z3"] ``` -------------------------------- ### Read Akoya CODEX/PhenoCycler Data with spatialdata-io Source: https://context7.com/scverse/spatialdata-io/llms.txt Reads CODEX formatted datasets from .fcs or .csv files, with optional support for .tif images. This function allows loading cell marker intensities and cell locations. Images are loaded if a corresponding .tif file is present in the output directory. ```python from spatialdata_io import codex # Load from FCS file (default) sdata = codex("path/to/codex_output/", fcs=True) # Load from CSV file sdata = codex("path/to/codex_output/", fcs=False) # Access elements table = sdata.tables["table"] # Cell marker intensities shapes = list(sdata.shapes.values())[0] # Cell locations as points # Images are loaded if .tif file is present if sdata.images: image = sdata.images["images"] ``` -------------------------------- ### Read Xenium aligned image Source: https://github.com/scverse/spatialdata-io/blob/main/docs/api.md Reads an image aligned to a Xenium dataset. It accepts the path to the image and an optional alignment file to ensure proper spatial registration. ```python from spatialdata_io import xenium_aligned_image image = xenium_aligned_image(image_path="path/to/image.tif", alignment_file="path/to/alignment.json") ``` -------------------------------- ### Read Xenium Explorer polygon selections Source: https://context7.com/scverse/spatialdata-io/llms.txt Reads polygon selections exported from the Xenium Explorer software, supporting both single selections and multiple selections from a single file. It allows specifying pixel size and whether to return a single Polygon object or a list of polygons, enabling spatial queries and analysis. ```python from spatialdata_io import xenium_explorer_selection from spatialdata import bounding_box_query # Read single selection polygon = xenium_explorer_selection( "path/to/selection.csv", pixel_size=0.2125, # Xenium default pixel size return_list=False, # Return single Polygon ) # Read multiple selections from one file polygons = xenium_explorer_selection( "path/to/selections.csv", return_list=True, # Always return list ) # Use polygon for spatial queries subset = bounding_box_query(sdata, polygon.bounds) ``` -------------------------------- ### Read Stereo-seq Data with spatialdata-io Source: https://github.com/scverse/spatialdata-io/blob/main/docs/generated/spatialdata_io.stereoseq.md Reads Stereo-seq formatted datasets from a given path. This function can optionally read associated TIFF files and binary data, and allows for customization of image reading and model creation through keyword arguments. ```python import spatialdata_io # Example usage: sdata = spatialdata_io.stereoseq( path="/path/to/your/stereoseq/data", dataset_id="my_dataset", read_square_bin=True, optional_tif=True, imread_kwargs={"scale_factors": [1, 2, 4]}, image_models_kwargs={"chunk_size": [256, 256]} ) ``` -------------------------------- ### Read aligned images for Xenium datasets Source: https://context7.com/scverse/spatialdata-io/llms.txt Reads additional H&E or IF images aligned to a Xenium dataset, optionally using an alignment file. It allows specifying image dimensions, RGBA format, and custom channel names, facilitating the integration of complementary imaging data. ```python from spatialdata_io import xenium_aligned_image # Read aligned H&E image he_image = xenium_aligned_image( "path/to/he_image.ome.tif", alignment_file="path/to/alignment.csv", # Optional dims=("c", "y", "x"), # Optional, auto-detected rgba=False, # Set True for RGBA images c_coords=["r", "g", "b"], # Custom channel names ) # Add to existing SpatialData sdata.images["he_aligned"] = he_image ``` -------------------------------- ### Read MCMICRO Pipeline Outputs with spatialdata-io Source: https://context7.com/scverse/spatialdata-io/llms.txt Reads MCMICRO output data, which is a multiplex imaging analysis pipeline. This function provides a straightforward way to load the processed data from the MCMICRO analysis. ```python from spatialdata_io import mcmicro sdata = mcmicro("path/to/mcmicro_output/") ``` -------------------------------- ### Read MERSCOPE data with spatialdata_io Source: https://github.com/scverse/spatialdata-io/blob/main/docs/generated/spatialdata_io.merscope.md This function reads various MERSCOPE data files from a specified directory path and returns a SpatialData object. It supports optional configuration for VPT outputs, z-layer selection, and backend image processing engines. ```python import spatialdata_io # Basic usage to load MERSCOPE data sdata = spatialdata_io.merscope(path="/path/to/merscope/data") # Advanced usage with specific parameters sdata_custom = spatialdata_io.merscope( path="/path/to/merscope/data", z_layers=[2, 3, 4], backend="dask_image", transcripts=True, cells_boundaries=True ) ``` -------------------------------- ### Convert SpatialData to legacy AnnData Source: https://context7.com/scverse/spatialdata-io/llms.txt Converts SpatialData objects back to the legacy AnnData format, ensuring compatibility with older tools and pipelines. This function allows users to export data for use with legacy Scanpy/Squidpy workflows, including downscaled images and spatial coordinates. ```python from spatialdata_io.experimental import to_legacy_anndata # Convert SpatialData to legacy format adata = to_legacy_anndata( sdata, coordinate_system="global", # Coordinate system to use table_name="table", # Which table to convert include_images=True, # Include downscaled images ) # adata now has legacy spatial structure: # - adata.uns['spatial'][dataset_id]['images']['hires'] # - adata.uns['spatial'][dataset_id]['images']['lowres'] # - adata.uns['spatial'][dataset_id]['scalefactors'] # - adata.obsm['spatial'] - coordinates matching hires image # Save for use with legacy tools adata.write_h5ad("legacy_format.h5ad") ``` -------------------------------- ### spatialdata_io.codex Source: https://github.com/scverse/spatialdata-io/blob/main/docs/generated/spatialdata_io.codex.md Reads CODEX formatted datasets, including FCS counts and TIFF images. ```APIDOC ## spatialdata_io.codex ### Description Reads CODEX formatted datasets. This function expects specific file naming conventions for counts and images. ### Method `spatialdata_io.codex` (This is a Python function, not a direct HTTP API endpoint) ### Endpoint N/A (Python function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```python import spatialdata_io from pathlib import Path # Example usage: # Assuming 'path/to/your/codex_data' contains files like 'dataset_id_counts.fcs' and 'dataset_id_image.tif' data = spatialdata_io.codex(path='path/to/your/codex_data', fcs=True) ``` ### Response #### Success Response (Return Type) - **SpatialData** (`spatialdata.SpatialData`) - A SpatialData object containing the processed data. #### Response Example ```json { "example": "spatialdata.SpatialData object" } ``` ### SEE ALSO - [CODEX output](https://help.codex.bio/codex/processor/technical-notes/expected-output) ``` -------------------------------- ### Read Steinbock Pipeline Outputs with spatialdata-io Source: https://context7.com/scverse/spatialdata-io/llms.txt Reads Steinbock output data, typically generated from imaging mass cytometry analysis. This function allows specifying the kind of labels to load, such as 'deepcell' or 'cellprofiler' segmentation results. ```python from spatialdata_io import steinbock sdata = steinbock( "path/to/steinbock_output/", labels_kind="deepcell", # or "cellprofiler" ) ``` -------------------------------- ### Read NanoString CosMx Data with spatialdata-io Source: https://context7.com/scverse/spatialdata-io/llms.txt Reads CosMx Spatial Molecular Imager data, including images, labels, transcripts, and cell metadata across multiple fields of view. The data is organized by field of view (FOV), with images and labels including per-FOV transformations to global coordinates. Cell tables provide both local and global coordinates. ```python from spatialdata_io import cosmx # Load CosMx dataset sdata = cosmx( "path/to/cosmx_output/", dataset_id="experiment_001", # Auto-inferred if not provided transcripts=True, # Load transcript locations ) # Data is organized by field of view (FOV) # Images and labels include per-FOV transformations to global coordinates print(sdata.images.keys()) # ['1_image', '2_image', '3_image', ...] print(sdata.labels.keys()) # ['1_labels', '2_labels', '3_labels', ...] # Each element has transformations to both local FOV and global coordinates image = sdata.images["1_image"] print(image.attrs) # Contains transformations dict # Access cell table with both local and global coordinates table = sdata.tables["table"] print(table.obsm["spatial"]) # Local coordinates print(table.obsm["global"]) # Global coordinates ```