spatiomic.data ============== .. py:module:: spatiomic.data .. autoapi-nested-parse:: Expose i/o functions from the data submodule. Classes ------- .. autoapisummary:: spatiomic.data.read spatiomic.data.subsample Functions --------- .. autoapisummary:: spatiomic.data.anndata_from_array spatiomic.data.subset Package Contents ---------------- .. py:function:: anndata_from_array(data, channel_names, clusters = None, cluster_key = 'clusters', spatial_weights = None) Create an AnnData object from an image data array. :param data: The image data array. :type data: NDArray :param channel_names: The channel names. :type channel_names: List[str] :param clusters: The clusters. Defaults to None. :type clusters: Optional[NDArray], optional :param cluster_key: The cluster key. Defaults to "clusters". :type cluster_key: str, optional :param spatial_weights: The spatial weights. Defaults to None. :type spatial_weights: Optional[W], optional :returns: The AnnData object :rtype: AnnData .. py:class:: read A class to read in microscopy files. .. py:method:: get_czi_image_channels(image, image_shape, ubyte = True) :staticmethod: Get the channels of an .czi image. :param image: The read CziFile of an image. :type image: NDArray :param image_shape: The shape of the CziFile. Example format of the image shape: [('B', 1), ('H', 1), ('T', 1), ('C', 3), ('Z', 1), ('Y', 2048), ('X', 2048)] :type image_shape: List[Tuple[str, int]] :param ubyte: Whether to interpret the data as np.uint8.. Defaults to True. :type ubyte: bool, optional :returns: An array containing the channels of the .czi file :rtype: NDArray .. py:method:: read_czi(file_path, input_dimension_order = 'XYC') :classmethod: Read a single czi file on a given path and returns it. :param file_path: Location of the file to be read. :type file_path: str :returns: An array containing the channels of the .czi file :rtype: NDArray .. py:method:: read_lif(file_path, image_idx = 0) :staticmethod: Read a single lif file on a given path and returns it. :param file_path: Location of the file to be read. :type file_path: str :returns: An array containing the channels of the .lif file :rtype: NDArray .. py:method:: read_tiff(file_path, input_dimension_order = 'XYC', precision = 'float32') :staticmethod: Read a single tiff file on a given path and returns it. :param file_path: Location of the file to be read. :type file_path: str :param input_dimension_order: The dimension order of the channels in the tiff file. Defaults to "XYC". :type input_dimension_order: str, optional :param precision: The precision of the data in the tiff file. Defaults to "float32". :type precision: Literal["float32", "float64"], optional :returns: An array containing the channels of the .tiff file in XYC dimension order. :rtype: NDArray .. py:method:: split_multi_image_lif(file_path, save_folder, save_prefix) :staticmethod: Read a lif file with multiple images and save every image in a defined folder. :param file_path: [description] :type file_path: str :param save_folder: [description] :type save_folder: str :param save_prefix: [description] :type save_prefix: str .. py:class:: subsample A class to subsample image data. .. py:method:: fit_transform(data, method = 'fraction', fraction = 0.1, count = 100000, *args, **kwargs) :staticmethod: Create a random subsample of some image data pixels, preserving channel dimensionality. :param data: Image data to take the subsample from. :type data: NDArray :param method: The method to use. Defaults to "fraction". :type method: Literal["fraction", "count"], optional :param fraction: The fraction of pixels to take when using the "fraction" method. When this results in a non-integer number of pixels, the number of pixels is rounded down. Defaults to 0.1. :type fraction: float, optional :param count: The number of pixels to take. Defaults to 10000 when using the "count" method. Defaults to 100,000. :type count: int, optional :param seed: The seed to use for random number generation. Defaults to None. :type seed: Optional[int], optional :returns: A flattened, random subsample of the pixels in the provided image data. :rtype: NDArray .. py:function:: subset(data, channel_names_data, channel_names_subset) Subset the data with the given channel names to the subset channel names in the given order. :param data: The image data, channel-last. :type data: NDArray :param channel_names_data: The channel names of the data. :type channel_names_data: List[str] :param channel_names_subset: The channel names to include in the subset. :type channel_names_subset: List[str] :returns: The subsetted data, with channel ordered according to the subset channel names. :rtype: NDArray