Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better docstring raster model #716

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions src/spatialdata/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,21 @@ def parse(
3D) labels. If you have a 2D image with shape yx, you can use :func:`numpy.expand_dims` (or an equivalent
function) to add a channel dimension.
dims
Dimensions of the data.
Dimensions of the data (e.g. ['c', 'y', 'x'] for 2D image data). If the data is a :class:`xarray.DataArray`,
the dimensions can also be inferred from the data. If the dimensions are not in the order (c)(z)yx, the data
will be transposed to match the order.
transformations
Transformations to apply to the data.
Dictionary of transformations to apply to the data. The key is the name of the target coordinate system,
the value is the transformation to apply. By default, a single `Identity` transformation mapping to the
`"global"` coordinate system is applied.
scale_factors
Scale factors to apply for multiscale.
If not None, a :class:`xarray.DataArray` is returned.
Scale factors to apply to construct a multiscale image (:class:`datatree.DataTree`).
If `None`, a :class:`xarray.DataArray` is returned instead.
Importantly, each scale factor is relative to the previous scale factor. For example, if the scale factors
are `[2, 2, 2]`, the returned multiscale image will have 4 scales. The original image and then the 2x, 4x
and 8x downsampled images.
method
Method to use for multiscale.
Method to use for multiscale downsampling. Please refer to :class:`multiscale_spatial_image.to_multiscale`.
chunks
Chunks to use for dask array.
kwargs
Expand All @@ -132,8 +139,18 @@ def parse(

Returns
-------
:class:`xarray.DataArray` or
:class:`datatree.DataTree`.
:class:`xarray.DataArray` or :class:`datatree.DataTree`

Notes
-----
**RGB images**

If you have an image with 3 or 4 channels and you want to interpret it as an RGB or RGB(A) image, you can use
the `c_coords` argument to specify the channel coordinates as `["r", "g", "b"]` or `["r", "g", "b", "a"]`.

You can also pass the `rgb` argument to `kwargs` to automatically set the `c_coords` to `["r", "g", "b"]`.
Please refer to :func:`to_spatial_image` for more information. Note: if you set `rgb=None` in `kwargs`, 3-4
channel images will be interpreted automatically as RGB(A) images.
"""
if transformations:
transformations = transformations.copy()
Expand Down
Loading