API#

SpatialData#

The SpatialData class.

SpatialData([images, labels, points, ...])

The SpatialData object.

Operations#

Operations on SpatialData objects.

bounding_box_query(element, axes, ...[, ...])

Query a SpatialData object or SpatialElement within a bounding box.

polygon_query(element, polygon, ...[, ...])

Query a SpatialData object or a SpatialElement by a polygon or multipolygon.

get_values(value_key[, element, sdata, ...])

Get the values from the element, from any location: df columns, obs or var columns (table).

get_extent(e[, coordinate_system, exact, ...])

Get the extent (bounding box) of a SpatialData object or a SpatialElement.

get_centroids(e[, coordinate_system])

Get the centroids of the geometries contained in a SpatialElement, as a new Points element.

join_spatialelement_table([sdata, ...])

Join SpatialElement(s) and table together in SQL like manner.

match_element_to_table(sdata, element_name, ...)

Filter the elements and make the indices match those in the table.

get_centroids(e[, coordinate_system])

Get the centroids of the geometries contained in a SpatialElement, as a new Points element.

match_table_to_element(sdata, element_name)

Filter the table and reorders the rows to match the instances (rows/labels) of the specified SpatialElement.

concatenate(sdatas[, region_key, ...])

Concatenate a list of spatial data objects.

transform(data[, transformation, ...])

Transform a SpatialElement using the transformation to a coordinate system, and returns the transformed element.

rasterize(data, axes, min_coordinate, ...[, ...])

Rasterize a SpatialData object or a SpatialElement (image, labels, points, shapes).

to_circles(data)

Convert a set of geometries (2D/3D labels, 2D shapes) to approximated circles/spheres.

aggregate(values, by[, values_sdata, ...])

Aggregate values by given region.

Operations Utilities#

unpad_raster(raster)

Remove padding from a raster type that was eventually added by the rotation component of a transformation.

are_extents_equal(extent0, extent1[, atol])

Check if two data extents, as returned by get_extent() are equal up to approximation errors.

deepcopy(element)

Deepcopy a SpatialData or SpatialElement object.

Models#

The elements (building-blocks) that consitute SpatialData.

Image2DModel(*args, **kwargs)

Image3DModel(*args, **kwargs)

Labels2DModel(*args, **kwargs)

Labels3DModel(*args, **kwargs)

ShapesModel()

PointsModel()

TableModel()

Models Utilities#

get_model(e)

Get the model for the given element.

SpatialElement

alias of Union[SpatialImage, MultiscaleSpatialImage, GeoDataFrame, DataFrame]

get_axes_names(e)

Get the dimensions of a SpatialElement.

get_spatial_axes(axes)

Get the spatial axes of interest.

points_geopandas_to_dask_dataframe(gdf[, ...])

Convert a GeoDataFrame which represents 2D or 3D points to a Dask DataFrame that passes the schema validation.

points_dask_dataframe_to_geopandas(points[, ...])

Convert a Dask DataFrame to a GeoDataFrame.

get_channels(data)

Get channels from data.

Transformations#

The transformations that can be defined between elements and coordinate systems in SpatialData.

BaseTransformation()

Base class for all transformations.

Identity()

MapAxis(map_axis)

Translation(translation, axes)

Scale(scale, axes)

Affine(matrix, input_axes, output_axes)

Sequence(transformations)

Transformations Utilities#

get_transformation(element[, ...])

Get the transformation/s of an element.

set_transformation(element, transformation)

Set a transformation/s to an element, in-memory or to disk.

remove_transformation(element[, ...])

Remove a transformation/s from an element, in-memory or from disk.

get_transformation_between_coordinate_systems(...)

Get the transformation to map a coordinate system (intrinsic or extrinsic) to another one.

get_transformation_between_landmarks(...)

Get a similarity transformation between two lists of (n >= 3) landmarks.

align_elements_using_landmarks(...[, ...])

Maps a moving object into a reference object using two lists of (n >= 3) landmarks.

remove_transformations_to_coordinate_system(...)

Remove (inplace) all transformations to a specific coordinate system from all the elements of a SpatialData object.

DataLoader#

ImageTilesDataset

Input/Output#

read_zarr(store[, selection])

Read a SpatialData dataset from a zarr store (on-disk or remote).

save_transformations(sdata)

Save all the transformations of a SpatialData object to disk.

get_dask_backing_files(element)

Get the backing files that appear in the Dask computational graph of an element/any element of a SpatialData object.

Testing utilities#

assert_spatial_data_objects_are_identical(...)

Compare two SpatialData objects and assert that they are identical.

assert_elements_are_identical(element0, element1)

Compare two elements (two SpatialElements or two tables) and assert that they are identical.

assert_elements_dict_are_identical(...[, ...])

Compare two dictionaries of elements and assert that they are identical (except for the order of the keys).