intake_io.io
Module Contents
Functions
|
Load image, autodetect source type. |
|
Save image, autodetect format. |
- intake_io.io.imload(uri: str, partition: Optional[Any] = None, metadata_only: bool = False, **kwargs) xarray.Dataset
Load image, autodetect source type.
- Parameters
uri (str) –
partition (Optional[Any]) – Load only a partition of the image
metadata_only (bool) – Load metadata only
kwargs –
Additional arguments passed to the source constructor. Notable fields supported by all subclasses of
intake_io.source.base.ImageSourceare:output_axis_order (Optional[str]) – Deviate from default “itczyx” output axis ordering, or None to use original axis ordering of the data
metadata (Optional[Dict[str, Any]]) – Add or overrule metadata fields, for instance:
metadata={ "axes": "tcxy", # specify input axis order "spacing": {"t": 0.3}, # overrule spacing "spacing_units": {"t": "ms"}, # overrule spacing unit "coords": {"c": ["nuclei", "actin"]} # use specific channel names }
- Returns
image
- Return type
- intake_io.io.imsave(image: Any, uri: str, compress: Optional[bool] = None, partition: Optional[str] = None, **kwargs)
Save image, autodetect format.
Format is chosen based on URI extension. Defaults to .zarr if no extension is given.
image is automatically split into multiple files if the output format doesn’t support saving it in a single file. For instance, TIF hyperstacks support single arrays with up to tzcyx axes. An
xarray.Datasetwith multiple variables (e.g. “image” and “segmentation”) and extra axes (e.g. multiple image arrays along the i-axis) is saved as multiple files according to the following pattern (axes are separated by., key and value are separated by_):/path/to/filename.var_image.i_00.tif /path/to/filename.var_image.i_01.tif ... /path/to/filename.var_segmentation.i_00.tif /path/to/filename.var_segmentation.i_01.tif ...
The indexes used in the file name are the actual
xarray.DataArraycoordinates along their respective axes, e.g. if our i coordinates are[3, 10]or["control", "treatment"]then we’ll get file names containing “i_03” or “i_treatment”. The data variable key (e.g. “var_segmentation” in the example above) is omitted from the output file name if image doesn’t have multiple data variables or if it isn’t anxarray.Dataset.The partition argument controls the partitioning scheme. By default, image is split only if needed, and into as few files as possible. In contrast, e.g.
partition="tyx"partitions the data into files containing only the given axes, in order (axes are reordered as needed), yielding e.g. the following file pattern:/path/to/filename.var_image.i_03.c_actin.tif /path/to/filename.var_image.i_03.c_nuclei.tif /path/to/filename.var_image.i_21.c_actin.tif /path/to/filename.var_image.i_21.c_nuclei.tif ... /path/to/filename.var_segmentation.i_03.c_actin.tif /path/to/filename.var_segmentation.i_03.c_nuclei.tif /path/to/filename.var_segmentation.i_21.c_actin.tif /path/to/filename.var_segmentation.i_21.c_nuclei.tif ...
See File patterns section of this documentation for help with loading these file patterns.
- Parameters
image (Any) –
uri (str) –
compress (Optional[bool]) – Whether or not to compress the data. Default value None defers decision to backend. Where applicable, compression algorithm and parameters are chosen as a trade-off of compatibility, compression ratio and I/O performance. If compression is requested but unsupported, the data is saved uncompressed and no exception is raised.
partition (Optional[str]) – Partition the data as needed into multiple files, each containing the given axes, in the given order. By default, as few files as possible are created.