dacapo.experiments.datasplits.datasets.arrays ============================================= .. py:module:: dacapo.experiments.datasplits.datasets.arrays Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/dacapo/experiments/datasplits/datasets/arrays/array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/array_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/binarize_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/binarize_array_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/concat_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/concat_array_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/constant_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/constant_array_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/crop_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/crop_array_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/dummy_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/dummy_array_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/dvid_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/dvid_array_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/intensity_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/intensity_array_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/logical_or_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/logical_or_array_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/merge_instances_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/merge_instances_array_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/missing_annotations_mask/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/missing_annotations_mask_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/numpy_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/ones_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/ones_array_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/resampled_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/resampled_array_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/sum_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/sum_array_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/tiff_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/tiff_array_config/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/zarr_array/index /autoapi/dacapo/experiments/datasplits/datasets/arrays/zarr_array_config/index Classes ------- .. autoapisummary:: dacapo.experiments.datasplits.datasets.arrays.Array dacapo.experiments.datasplits.datasets.arrays.ArrayConfig dacapo.experiments.datasplits.datasets.arrays.DummyArray dacapo.experiments.datasplits.datasets.arrays.DummyArrayConfig dacapo.experiments.datasplits.datasets.arrays.ZarrArray dacapo.experiments.datasplits.datasets.arrays.ZarrArrayConfig dacapo.experiments.datasplits.datasets.arrays.BinarizeArray dacapo.experiments.datasplits.datasets.arrays.BinarizeArrayConfig dacapo.experiments.datasplits.datasets.arrays.ResampledArray dacapo.experiments.datasplits.datasets.arrays.ResampledArrayConfig dacapo.experiments.datasplits.datasets.arrays.IntensitiesArray dacapo.experiments.datasplits.datasets.arrays.IntensitiesArrayConfig dacapo.experiments.datasplits.datasets.arrays.MissingAnnotationsMask dacapo.experiments.datasplits.datasets.arrays.MissingAnnotationsMaskConfig dacapo.experiments.datasplits.datasets.arrays.OnesArray dacapo.experiments.datasplits.datasets.arrays.OnesArrayConfig dacapo.experiments.datasplits.datasets.arrays.ConcatArray dacapo.experiments.datasplits.datasets.arrays.ConcatArrayConfig dacapo.experiments.datasplits.datasets.arrays.LogicalOrArray dacapo.experiments.datasplits.datasets.arrays.LogicalOrArrayConfig dacapo.experiments.datasplits.datasets.arrays.CropArray dacapo.experiments.datasplits.datasets.arrays.CropArrayConfig dacapo.experiments.datasplits.datasets.arrays.MergeInstancesArray dacapo.experiments.datasplits.datasets.arrays.MergeInstancesArrayConfig dacapo.experiments.datasplits.datasets.arrays.DVIDArray dacapo.experiments.datasplits.datasets.arrays.DVIDArrayConfig dacapo.experiments.datasplits.datasets.arrays.SumArray dacapo.experiments.datasplits.datasets.arrays.SumArrayConfig dacapo.experiments.datasplits.datasets.arrays.NumpyArray dacapo.experiments.datasplits.datasets.arrays.ConstantArray dacapo.experiments.datasplits.datasets.arrays.ConstantArrayConfig Package Contents ---------------- .. py:class:: Array An Array is a multi-dimensional array of data that can be read from and written to. It is defined by a region of interest (ROI) in world units, a voxel size, and a number of spatial dimensions. The data is stored in a numpy array, and can be accessed using numpy-like slicing syntax. The Array class is an abstract base class that defines the interface for all Array implementations. It provides a number of properties that must be implemented by subclasses, such as the ROI, voxel size, and data type of the array. It also provides a method for fetching data from the array, which is implemented by slicing the numpy array. The Array class also provides a method for checking if the array can be visualized in Neuroglancer, and a method for generating a Neuroglancer layer for the array. These methods are implemented by subclasses that support visualization in Neuroglancer. .. attribute:: attrs A dictionary of metadata attributes stored on this array. :type: Dict[str, Any] .. attribute:: axes The axes of this dataset as a string of characters, as they are indexed. Permitted characters are: * ``zyx`` for spatial dimensions * ``c`` for channels * ``s`` for samples :type: List[str] .. attribute:: dims The number of spatial dimensions. :type: int .. attribute:: voxel_size The size of a voxel in physical units. :type: Coordinate .. attribute:: roi The total ROI of this array, in world units. :type: Roi .. attribute:: dtype The dtype of this array, in numpy dtypes :type: Any .. attribute:: num_channels The number of channels provided by this dataset. Should return None if the channel dimension doesn't exist. :type: Optional[int] .. attribute:: data A numpy-like readable and writable view into this array. :type: np.ndarray .. attribute:: writable Can we write to this Array? :type: bool .. method:: __getitem__(self, roi Roi) -> np.ndarray: Get a numpy like readable and writable view into this array. .. method:: _can_neuroglance(self) -> bool Check if this array can be visualized in Neuroglancer. .. method:: _neuroglancer_layer(self) Generate a Neuroglancer layer for this array. .. method:: _slices(self, roi Roi) -> Iterable[slice]: Generate a list of slices for the given ROI. .. note:: This class is used to define the interface for all Array implementations. It provides a number of properties that must be implemented by subclasses, such as the ROI, voxel size, and data type of the array. It also provides a method for fetching data from the array, which is implemented by slicing the numpy array. The Array class also provides a method for checking if the array can be visualized in Neuroglancer, and a method for generating a Neuroglancer layer for the array. These methods are implemented by subclasses that support visualization in Neuroglancer. .. py:property:: attrs :type: Dict[str, Any] :abstractmethod: Return a dictionary of metadata attributes stored on this array. :returns: A dictionary of metadata attributes stored on this array. :rtype: Dict[str, Any] :raises NotImplementedError: This method must be implemented by the subclass. .. rubric:: Examples >>> array = Array() >>> array.attrs {} .. note:: This method must be implemented by the subclass. .. py:property:: axes :type: List[str] :abstractmethod: Returns the axes of this dataset as a string of charactes, as they are indexed. Permitted characters are: * ``zyx`` for spatial dimensions * ``c`` for channels * ``s`` for samples :returns: The axes of this dataset as a string of characters, as they are indexed. :rtype: List[str] :raises NotImplementedError: This method must be implemented by the subclass. .. rubric:: Examples >>> array = Array() >>> array.axes ['z', 'y', 'x'] .. note:: This method must be implemented by the subclass. .. py:property:: dims :type: int :abstractmethod: Returns the number of spatial dimensions. :returns: The number of spatial dimensions. :rtype: int :raises NotImplementedError: This method must be implemented by the subclass. .. rubric:: Examples >>> array = Array() >>> array.dims 3 .. note:: This method must be implemented by the subclass. .. py:property:: voxel_size :type: funlib.geometry.Coordinate :abstractmethod: The size of a voxel in physical units. :returns: The size of a voxel in physical units. :rtype: Coordinate :raises NotImplementedError: This method must be implemented by the subclass. .. rubric:: Examples >>> array = Array() >>> array.voxel_size Coordinate((1, 1, 1)) .. note:: This method must be implemented by the subclass. .. py:property:: roi :type: funlib.geometry.Roi :abstractmethod: The total ROI of this array, in world units. :returns: The total ROI of this array, in world units. :rtype: Roi :raises NotImplementedError: This method must be implemented by the subclass. .. rubric:: Examples >>> array = Array() >>> array.roi Roi(offset=Coordinate((0, 0, 0)), shape=Coordinate((100, 100, 100))) .. note:: This method must be implemented by the subclass. .. py:property:: dtype :type: Any :abstractmethod: The dtype of this array, in numpy dtypes :returns: The dtype of this array, in numpy dtypes. :rtype: Any :raises NotImplementedError: This method must be implemented by the subclass. .. rubric:: Examples >>> array = Array() >>> array.dtype np.dtype('uint8') .. note:: This method must be implemented by the subclass. .. py:property:: num_channels :type: Optional[int] :abstractmethod: The number of channels provided by this dataset. Should return None if the channel dimension doesn't exist. :returns: The number of channels provided by this dataset. :rtype: Optional[int] :raises NotImplementedError: This method must be implemented by the subclass. .. rubric:: Examples >>> array = Array() >>> array.num_channels 1 .. note:: This method must be implemented by the subclass. .. py:property:: data :type: numpy.ndarray :abstractmethod: Get a numpy like readable and writable view into this array. :returns: A numpy like readable and writable view into this array. :rtype: np.ndarray :raises NotImplementedError: This method must be implemented by the subclass. .. rubric:: Examples >>> array = Array() >>> array.data np.ndarray .. note:: This method must be implemented by the subclass. .. py:property:: writable :type: bool :abstractmethod: Can we write to this Array? :returns: Can we write to this Array? :rtype: bool :raises NotImplementedError: This method must be implemented by the subclass. .. rubric:: Examples >>> array = Array() >>> array.writable False .. note:: This method must be implemented by the subclass. .. py:class:: ArrayConfig Base class for array configurations. Each subclass of an `Array` should have a corresponding config class derived from `ArrayConfig`. This class should be used to store the configuration of the array. .. attribute:: name A unique name for this array. This will be saved so you and others can find and reuse this array. Keep it short and avoid special characters. :type: str .. method:: verify(self) -> Tuple[bool, str] This method is used to check whether this is a valid Array. .. note:: This class is used to create a base class for array configurations. Each subclass of an `Array` should have a corresponding config class derived from `ArrayConfig`. This class should be used to store the configuration of the array. .. py:attribute:: name :type: str .. py:method:: verify() -> Tuple[bool, str] Check whether this is a valid Array :returns: A tuple with the first element being a boolean indicating whether the array is valid and the second element being a string with a message explaining why the array is invalid :rtype: Tuple[bool, str] :raises NotImplementedError: This method is not implemented in this class .. rubric:: Examples >>> array_config = ArrayConfig(name="array_config") >>> array_config.verify() (True, "No validation for this Array") .. note:: This method is used to check whether this is a valid Array. .. py:class:: DummyArray(array_config) This is just a dummy array for testing. It has a shape of (100, 50, 50) and is filled with zeros. .. attribute:: array_config The config object for the array :type: ArrayConfig .. method:: __getitem__ Returns the intensities normalized to the range (0, 1) .. rubric:: Notes The array_config must be an ArrayConfig object. The min and max values are used to normalize the intensities. All intensities are converted to float32. .. py:property:: attrs Returns the attributes of the source array :returns: The attributes of the source array :rtype: dict :raises ValueError: If the attributes is not a dictionary .. rubric:: Examples >>> intensities_array.attrs {'resolution': (1.0, 1.0, 1.0), 'unit': 'micrometer'} .. py:property:: axes Returns the axes of the source array :returns: The axes of the source array :rtype: str :raises ValueError: If the axes is not a string .. rubric:: Examples >>> intensities_array.axes 'zyx' .. rubric:: Notes The axes are the same as the source array .. py:property:: dims Returns the number of dimensions of the source array :returns: The number of dimensions of the source array :rtype: int :raises ValueError: If the dims is not an integer .. rubric:: Examples >>> intensities_array.dims 3 .. rubric:: Notes The dims are the same as the source array .. py:property:: voxel_size Returns the voxel size of the source array :returns: The voxel size of the source array :rtype: Coordinate :raises ValueError: If the voxel size is not a Coordinate object .. rubric:: Examples >>> intensities_array.voxel_size Coordinate(x=1.0, y=1.0, z=1.0) .. rubric:: Notes The voxel size is the same as the source array .. py:property:: roi Returns the region of interest of the source array :returns: The region of interest of the source array :rtype: Roi :raises ValueError: If the roi is not a Roi object .. rubric:: Examples >>> intensities_array.roi Roi(offset=(0, 0, 0), shape=(100, 100, 100)) .. rubric:: Notes The roi is the same as the source array .. py:property:: writable :type: bool Returns whether the array is writable :returns: Whether the array is writable :rtype: bool .. rubric:: Examples >>> intensities_array.writable True .. rubric:: Notes The array is always writable .. py:property:: data Returns the data of the source array :returns: The data of the source array :rtype: np.ndarray :raises ValueError: If the data is not a numpy array .. rubric:: Examples >>> intensities_array.data array([[[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], .. rubric:: Notes The data is the same as the source array .. py:property:: dtype Returns the data type of the array :returns: The data type of the array :rtype: type :raises ValueError: If the data type is not a type .. rubric:: Examples >>> intensities_array.dtype numpy.float32 .. rubric:: Notes The data type is the same as the source array .. py:property:: num_channels Returns the number of channels in the source array :returns: The number of channels in the source array :rtype: int :raises ValueError: If the number of channels is not an integer .. rubric:: Examples >>> intensities_array.num_channels 1 .. rubric:: Notes The number of channels is the same as the source array .. py:class:: DummyArrayConfig This is just a dummy array config used for testing. None of the attributes have any particular meaning. It is used to test the ArrayConfig class. .. method:: to_array Returns the DummyArray object .. method:: verify Returns whether the DummyArrayConfig is valid .. rubric:: Notes The source_array_config must be an ArrayConfig object. .. py:attribute:: array_type .. py:method:: verify() -> Tuple[bool, str] Check whether this is a valid Array :returns: Whether the Array is valid and a message :rtype: Tuple[bool, str] :raises ValueError: If the source is not a tuple of strings .. rubric:: Examples >>> dummy_array_config = DummyArrayConfig(...) >>> dummy_array_config.verify() (False, "This is a DummyArrayConfig and is never valid") .. rubric:: Notes The source must be a tuple of strings. .. py:class:: ZarrArray(array_config) This is a zarr array. .. attribute:: name The name of the array. :type: str .. attribute:: file_name The file name of the array. :type: Path .. attribute:: dataset The dataset name. :type: str .. attribute:: _axes The axes of the array. :type: Optional[List[str]] .. attribute:: snap_to_grid The snap to grid. :type: Optional[Coordinate] .. method:: __init__(array_config) Initializes the array type 'raw' and name for the DummyDataset instance. .. method:: __str__() Returns the string representation of the ZarrArray. .. method:: __repr__() Returns the string representation of the ZarrArray. .. method:: attrs() Returns the attributes of the array. .. method:: axes() Returns the axes of the array. .. method:: dims() Returns the dimensions of the array. .. method:: _daisy_array() Returns the daisy array. .. method:: voxel_size() Returns the voxel size of the array. .. method:: roi() Returns the region of interest of the array. .. method:: writable() Returns the boolean value of the array. .. method:: dtype() Returns the data type of the array. .. method:: num_channels() Returns the number of channels of the array. .. method:: spatial_axes() Returns the spatial axes of the array. .. method:: data() Returns the data of the array. .. method:: __getitem__(roi) Returns the data of the array for the given region of interest. .. method:: __setitem__(roi, value) Sets the data of the array for the given region of interest. .. method:: create_from_array_identifier(array_identifier, axes, roi, num_channels, voxel_size, dtype, write_size=None, name=None, overwrite=False) Creates a new ZarrArray given an array identifier. .. method:: open_from_array_identifier(array_identifier, name="") Opens a new ZarrArray given an array identifier. .. method:: _can_neuroglance() Returns the boolean value of the array. .. method:: _neuroglancer_source() Returns the neuroglancer source of the array. .. method:: _neuroglancer_layer() Returns the neuroglancer layer of the array. .. method:: _transform_matrix() Returns the transform matrix of the array. .. method:: _output_dimensions() Returns the output dimensions of the array. .. method:: _source_name() Returns the source name of the array. .. method:: add_metadata(metadata) Adds metadata to the array. .. rubric:: Notes This class is used to create a zarr array. .. py:attribute:: name .. py:attribute:: file_name .. py:attribute:: dataset .. py:attribute:: snap_to_grid .. py:property:: mode .. py:property:: attrs Returns the attributes of the array. :param attrs: The attributes of the array. :type attrs: Any :returns: The attributes of the array. :rtype: Any :raises NotImplementedError: .. rubric:: Examples >>> attrs() .. rubric:: Notes This method is used to return the attributes of the array. .. py:property:: axes Returns the axes of the array. :param axes: The axes of the array. :type axes: List[str] :returns: The axes of the array. :rtype: List[str] :raises NotImplementedError: .. rubric:: Examples >>> axes() .. rubric:: Notes This method is used to return the axes of the array. .. py:property:: dims :type: int Returns the dimensions of the array. :param dims: The dimensions of the array. :type dims: int :returns: The dimensions of the array. :rtype: int :raises NotImplementedError: .. rubric:: Examples >>> dims() .. rubric:: Notes This method is used to return the dimensions of the array. .. py:method:: voxel_size() -> funlib.geometry.Coordinate Returns the voxel size of the array. :param voxel_size: The voxel size. :type voxel_size: Coordinate :returns: The voxel size of the array. :rtype: Coordinate :raises NotImplementedError: .. rubric:: Examples >>> voxel_size() .. rubric:: Notes This method is used to return the voxel size of the array. .. py:method:: roi() -> funlib.geometry.Roi Returns the region of interest of the array. :param roi: The region of interest. :type roi: Roi :returns: The region of interest of the array. :rtype: Roi :raises NotImplementedError: .. rubric:: Examples >>> roi() .. rubric:: Notes This method is used to return the region of interest of the array. .. py:property:: writable :type: bool Returns the boolean value of the array. :param writable: The boolean value of the array. :type writable: bool :returns: The boolean value of the array. :rtype: bool :raises NotImplementedError: .. rubric:: Examples >>> writable() .. rubric:: Notes This method is used to return the boolean value of the array. .. py:property:: dtype :type: Any Returns the data type of the array. :param dtype: The data type of the array. :type dtype: Any :returns: The data type of the array. :rtype: Any :raises NotImplementedError: .. rubric:: Examples >>> dtype() .. rubric:: Notes This method is used to return the data type of the array. .. py:property:: num_channels :type: Optional[int] Returns the number of channels of the array. :param num_channels: The number of channels of the array. :type num_channels: Optional[int] :returns: The number of channels of the array. :rtype: Optional[int] :raises NotImplementedError: .. rubric:: Examples >>> num_channels() .. rubric:: Notes This method is used to return the number of channels of the array. .. py:property:: spatial_axes :type: List[str] Returns the spatial axes of the array. :param spatial_axes: The spatial axes of the array. :type spatial_axes: List[str] :returns: The spatial axes of the array. :rtype: List[str] :raises NotImplementedError: .. rubric:: Examples >>> spatial_axes() .. rubric:: Notes This method is used to return the spatial axes of the array. .. py:property:: data :type: Any Returns the data of the array. :param data: The data of the array. :type data: Any :returns: The data of the array. :rtype: Any :raises NotImplementedError: .. rubric:: Examples >>> data() .. rubric:: Notes This method is used to return the data of the array. .. py:method:: create_from_array_identifier(array_identifier, axes, roi, num_channels, voxel_size, dtype, mode='a', write_size=None, name=None, overwrite=False) :classmethod: Create a new ZarrArray given an array identifier. It is assumed that this array_identifier points to a dataset that does not yet exist. :param array_identifier: The array identifier. :type array_identifier: ArrayIdentifier :param axes: The axes of the array. :type axes: List[str] :param roi: The region of interest. :type roi: Roi :param num_channels: The number of channels. :type num_channels: int :param voxel_size: The voxel size. :type voxel_size: Coordinate :param dtype: The data type. :type dtype: Any :param write_size: The write size. :type write_size: Optional[Coordinate] :param name: The name of the array. :type name: Optional[str] :param overwrite: The boolean value to overwrite the array. :type overwrite: bool :returns: The ZarrArray. :rtype: ZarrArray :raises NotImplementedError: .. rubric:: Examples >>> create_from_array_identifier(array_identifier, axes, roi, num_channels, voxel_size, dtype, write_size=None, name=None, overwrite=False) .. rubric:: Notes This method is used to create a new ZarrArray given an array identifier. .. py:method:: open_from_array_identifier(array_identifier, name='') :classmethod: Opens a new ZarrArray given an array identifier. :param array_identifier: The array identifier. :type array_identifier: ArrayIdentifier :param name: The name of the array. :type name: str :returns: The ZarrArray. :rtype: ZarrArray :raises NotImplementedError: .. rubric:: Examples >>> open_from_array_identifier(array_identifier, name="") .. rubric:: Notes This method is used to open a new ZarrArray given an array identifier. .. py:method:: add_metadata(metadata: Dict[str, Any]) -> None Adds metadata to the array. :param metadata: The metadata to add to the array. :type metadata: Dict[str, Any] :raises NotImplementedError: .. rubric:: Examples >>> add_metadata(metadata) .. rubric:: Notes This method is used to add metadata to the array. .. py:class:: ZarrArrayConfig This config class provides the necessary configuration for a zarr array. A zarr array is a container for large, multi-dimensional arrays. It is similar to HDF5, but is designed to work with large arrays that do not fit into memory. Zarr arrays can be stored on disk or in the cloud and can be accessed concurrently by multiple processes. Zarr arrays can be compressed and support chunked, N-dimensional arrays. .. attribute:: file_name Path The file name of the zarr container. .. attribute:: dataset str The name of your dataset. May include '/' characters for nested heirarchies .. attribute:: snap_to_grid Optional[Coordinate] If you need to make sure your ROI's align with a specific voxel_size .. attribute:: _axes Optional[List[str]] The axes of your data! .. method:: verify() -> Tuple[bool, str] Check whether this is a valid Array .. note:: This class is a subclass of ArrayConfig. .. py:attribute:: array_type .. py:attribute:: file_name :type: upath.UPath .. py:attribute:: dataset :type: str .. py:attribute:: snap_to_grid :type: Optional[funlib.geometry.Coordinate] .. py:attribute:: mode :type: Optional[str] .. py:method:: verify() -> Tuple[bool, str] Check whether this is a valid Array :returns: A tuple of a boolean and a string. The boolean indicates whether the Array is valid or not. The string provides a reason why the Array is not valid. :rtype: Tuple[bool, str] :raises NotImplementedError: This method is not implemented for this Array .. rubric:: Examples >>> zarr_array_config = ZarrArrayConfig( ... file_name=Path("data.zarr"), ... dataset="data", ... snap_to_grid=Coordinate(1, 1, 1), ... _axes=["x", "y", "z"] ... ) >>> zarr_array_config.verify() (True, 'No validation for this Array') .. note:: This method is not implemented for this Array .. py:class:: BinarizeArray(array_config) This is wrapper around a ZarrArray containing uint annotations. Because we often want to predict classes that are a combination of a set of labels we wrap a ZarrArray with the BinarizeArray and provide something like `groupings=[("mito", [3,4,5])]` where 4 corresponds to mito_mem (mitochondria membrane), 5 is mito_ribo (mitochondria ribosomes), and 3 is everything else that is part of a mitochondria. The BinarizeArray will simply combine labels 3,4,5 into a single binary channel for the class of "mito". We use a single channel per class because some classes may overlap. For example if you had `groupings=[("mito", [3,4,5]), ("membrane", [4, 8, 1])]` where 4 is mito_mem, 8 is er_mem (ER membrane), and 1 is pm (plasma membrane). Now you can have a binary classification for membrane or not which in some cases overlaps with the channel for mitochondria which includes the mito membrane. .. attribute:: name The name of the array. :type: str .. attribute:: source_array The source array to binarize. :type: Array .. attribute:: background The label to treat as background. :type: int .. attribute:: groupings A list of tuples where the first element is the name of the class and the second element is a list of labels that should be combined into a single binary channel. :type: List[Tuple[str, List[int]]] .. method:: __init__(self, array_config) This method initializes the BinarizeArray object. .. method:: __attrs_post_init__(self) This method is called after the instance has been initialized by the constructor. It is used to set the default_config to an instance of ArrayConfig if it is None. .. method:: __getitem__(self, roi Roi) -> np.ndarray: This method returns the binary channels for the given region of interest. .. method:: _can_neuroglance(self) This method returns True if the source array can be visualized in neuroglance. .. method:: _neuroglancer_source(self) This method returns the source array for neuroglancer. .. method:: _neuroglancer_layer(self) This method returns the neuroglancer layer for the source array. .. method:: _source_name(self) This method returns the name of the source array. .. note:: This class is used to create a BinarizeArray object which is a wrapper around a ZarrArray containing uint annotations. .. py:attribute:: name .. py:attribute:: background .. py:property:: attrs This method returns the attributes of the source array. :returns: The attributes of the source array. :rtype: Dict :raises ValueError: If the source array is not writable. .. rubric:: Examples >>> binarize_array.attrs .. note:: This method is used to return the attributes of the source array. .. py:property:: axes This method returns the axes of the source array. :returns: The axes of the source array. :rtype: List[str] :raises ValueError: If the source array is not writable. .. rubric:: Examples >>> binarize_array.axes .. note:: This method is used to return the axes of the source array. .. py:property:: dims :type: int This method returns the dimensions of the source array. :returns: The dimensions of the source array. :rtype: int :raises ValueError: If the source array is not writable. .. rubric:: Examples >>> binarize_array.dims .. note:: This method is used to return the dimensions of the source array. .. py:property:: voxel_size :type: funlib.geometry.Coordinate This method returns the voxel size of the source array. :returns: The voxel size of the source array. :rtype: Coordinate :raises ValueError: If the source array is not writable. .. rubric:: Examples >>> binarize_array.voxel_size .. note:: This method is used to return the voxel size of the source array. .. py:property:: roi :type: funlib.geometry.Roi This method returns the region of interest of the source array. :returns: The region of interest of the source array. :rtype: Roi :raises ValueError: If the source array is not writable. .. rubric:: Examples >>> binarize_array.roi .. note:: This method is used to return the region of interest of the source array. .. py:property:: writable :type: bool This method returns True if the source array is writable. :returns: True if the source array is writable. :rtype: bool :raises ValueError: If the source array is not writable. .. rubric:: Examples >>> binarize_array.writable .. note:: This method is used to return True if the source array is writable. .. py:property:: dtype This method returns the data type of the source array. :returns: The data type of the source array. :rtype: np.dtype :raises ValueError: If the source array is not writable. .. rubric:: Examples >>> binarize_array.dtype .. note:: This method is used to return the data type of the source array. .. py:property:: num_channels :type: int This method returns the number of channels in the source array. :returns: The number of channels in the source array. :rtype: int :raises ValueError: If the source array is not writable. .. rubric:: Examples >>> binarize_array.num_channels .. note:: This method is used to return the number of channels in the source array. .. py:property:: data This method returns the data of the source array. :returns: The data of the source array. :rtype: np.ndarray :raises ValueError: If the source array is not writable. .. rubric:: Examples >>> binarize_array.data .. note:: This method is used to return the data of the source array. .. py:property:: channels This method returns the channel names of the source array. :returns: The channel names of the source array. :rtype: Iterator[str] :raises ValueError: If the source array is not writable. .. rubric:: Examples >>> binarize_array.channels .. note:: This method is used to return the channel names of the source array. .. py:class:: BinarizeArrayConfig This config class provides the necessary configuration for turning an Annotated dataset into a multi class binary classification problem. Each class will be binarized into a separate channel. .. attribute:: source_array_config The Array from which to pull annotated data. Is expected to contain a volume with uint64 voxels and no channel dimension :type: ArrayConfig .. attribute:: groupings List of id groups with a symantic name. Each id group is a List of ids. Group i found in groupings[i] will be binarized and placed in channel i. An empty group will binarize all non background labels. :type: List[Tuple[str, List[int]]] .. attribute:: background The id considered background. Will never be binarized to 1, defaults to 0. :type: int .. note:: This class is used to create a BinarizeArray object which is used to turn an Annotated dataset into a multi class binary classification problem. Each class will be binarized into a separate channel. .. py:attribute:: array_type .. py:attribute:: source_array_config :type: dacapo.experiments.datasplits.datasets.arrays.array_config.ArrayConfig .. py:attribute:: groupings :type: List[Tuple[str, List[int]]] .. py:attribute:: background :type: int .. py:class:: ResampledArray(array_config) This is a zarr array that is a resampled version of another array. Resampling is done by rescaling the source array with the given upsample and downsample factors. The voxel size of the resampled array is the voxel size of the source array divided by the downsample factor and multiplied by the upsample factor. .. attribute:: name str The name of the array .. attribute:: source_array Array The source array .. attribute:: upsample Coordinate The upsample factor for each dimension .. attribute:: downsample Coordinate The downsample factor for each dimension .. attribute:: interp_order int The order of the interpolation used for resampling .. method:: attrs Dict Returns the attributes of the source array .. method:: axes str Returns the axes of the source array .. method:: dims int Returns the number of dimensions of the source array .. method:: voxel_size Coordinate Returns the voxel size of the resampled array .. method:: roi Roi Returns the region of interest of the resampled array .. method:: writable bool Returns whether the resampled array is writable .. method:: dtype np.dtype Returns the data type of the resampled array .. method:: num_channels int Returns the number of channels of the resampled array .. method:: data np.ndarray Returns the data of the resampled array .. method:: scale Tuple[float] Returns the scale of the resampled array .. method:: __getitem__(roi Roi) -> np.ndarray Returns the data of the resampled array within the given region of interest .. method:: _can_neuroglance() -> bool Returns whether the source array can be visualized with neuroglance .. method:: _neuroglancer_layer() -> Dict Returns the neuroglancer layer of the source array .. method:: _neuroglancer_source() -> Dict Returns the neuroglancer source of the source array .. method:: _source_name() -> str Returns the name of the source array .. note:: This class is a subclass of Array. .. py:attribute:: name .. py:attribute:: upsample .. py:attribute:: downsample .. py:attribute:: interp_order .. py:property:: attrs Returns the attributes of the source array. :returns: The attributes of the source array :rtype: Dict :raises ValueError: If the resampled array is not writable .. rubric:: Examples >>> resampled_array.attrs .. note:: This method returns the attributes of the source array. .. py:property:: axes Returns the axes of the source array. :returns: The axes of the source array :rtype: str :raises ValueError: If the resampled array is not writable .. rubric:: Examples >>> resampled_array.axes .. note:: This method returns the axes of the source array. .. py:property:: dims :type: int Returns the number of dimensions of the source array. :returns: The number of dimensions of the source array :rtype: int :raises ValueError: If the resampled array is not writable .. rubric:: Examples >>> resampled_array.dims .. note:: This method returns the number of dimensions of the source array. .. py:property:: voxel_size :type: funlib.geometry.Coordinate Returns the voxel size of the resampled array. :returns: The voxel size of the resampled array :rtype: Coordinate :raises ValueError: If the resampled array is not writable .. rubric:: Examples >>> resampled_array.voxel_size .. note:: This method returns the voxel size of the resampled array. .. py:property:: roi :type: funlib.geometry.Roi Returns the region of interest of the resampled array. :returns: The region of interest of the resampled array :rtype: Roi :raises ValueError: If the resampled array is not writable .. rubric:: Examples >>> resampled_array.roi .. note:: This method returns the region of interest of the resampled array. .. py:property:: writable :type: bool Returns whether the resampled array is writable. :returns: True if the resampled array is writable, False otherwise :rtype: bool :raises ValueError: If the resampled array is not writable .. rubric:: Examples >>> resampled_array.writable .. note:: This method returns whether the resampled array is writable. .. py:property:: dtype Returns the data type of the resampled array. :returns: The data type of the resampled array :rtype: np.dtype :raises ValueError: If the resampled array is not writable .. rubric:: Examples >>> resampled_array.dtype .. note:: This method returns the data type of the resampled array. .. py:property:: num_channels :type: int Returns the number of channels of the resampled array. :returns: The number of channels of the resampled array :rtype: int :raises ValueError: If the resampled array is not writable .. rubric:: Examples >>> resampled_array.num_channels .. note:: This method returns the number of channels of the resampled array. .. py:property:: data Returns the data of the resampled array. :returns: The data of the resampled array :rtype: np.ndarray :raises ValueError: If the resampled array is not writable .. rubric:: Examples >>> resampled_array.data .. note:: This method returns the data of the resampled array. .. py:property:: scale Returns the scale of the resampled array. :returns: The scale of the resampled array :rtype: Tuple[float] :raises ValueError: If the resampled array is not writable .. rubric:: Examples >>> resampled_array.scale .. note:: This method returns the scale of the resampled array. .. py:class:: ResampledArrayConfig A configuration for a ResampledArray. This array will up or down sample an array into the desired voxel size. .. attribute:: source_array_config The Array that you want to upsample or downsample. :type: ArrayConfig .. attribute:: upsample The amount by which to upsample! :type: Coordinate .. attribute:: downsample The amount by which to downsample! :type: Coordinate .. attribute:: interp_order The order of the interpolation! :type: bool .. method:: create_array Creates a ResampledArray from the configuration. .. note:: This class is meant to be used with the ArrayDataset class. .. py:attribute:: array_type .. py:attribute:: source_array_config :type: dacapo.experiments.datasplits.datasets.arrays.array_config.ArrayConfig .. py:attribute:: upsample :type: funlib.geometry.Coordinate .. py:attribute:: downsample :type: funlib.geometry.Coordinate .. py:attribute:: interp_order :type: bool .. py:class:: IntensitiesArray(array_config) This is wrapper another array that will normalize intensities to the range (0, 1) and convert to float32. Use this if you have your intensities stored as uint8 or similar and want your model to have floats as input. .. attribute:: array_config The config object for the array :type: ArrayConfig .. attribute:: min The minimum intensity value in the array :type: float .. attribute:: max The maximum intensity value in the array :type: float .. method:: __getitem__ Returns the intensities normalized to the range (0, 1) .. rubric:: Notes The array_config must be an ArrayConfig object. The min and max values are used to normalize the intensities. All intensities are converted to float32. .. py:attribute:: name .. py:property:: attrs Returns the attributes of the source array :returns: The attributes of the source array :rtype: dict :raises ValueError: If the attributes is not a dictionary .. rubric:: Examples >>> intensities_array.attrs {'resolution': (1.0, 1.0, 1.0), 'unit': 'micrometer'} .. rubric:: Notes The attributes are the same as the source array .. py:property:: axes Returns the axes of the source array :returns: The axes of the source array :rtype: str :raises ValueError: If the axes is not a string .. rubric:: Examples >>> intensities_array.axes 'zyx' .. rubric:: Notes The axes are the same as the source array .. py:property:: dims :type: int Returns the dimensions of the source array :returns: The dimensions of the source array :rtype: int :raises ValueError: If the dimensions is not an integer .. rubric:: Examples >>> intensities_array.dims 3 .. rubric:: Notes The dimensions are the same as the source array .. py:property:: voxel_size :type: funlib.geometry.Coordinate Returns the voxel size of the source array :returns: The voxel size of the source array :rtype: Coordinate :raises ValueError: If the voxel size is not a Coordinate object .. rubric:: Examples >>> intensities_array.voxel_size Coordinate(x=1.0, y=1.0, z=1.0) .. rubric:: Notes The voxel size is the same as the source array .. py:property:: roi :type: funlib.geometry.Roi Returns the region of interest of the source array :returns: The region of interest of the source array :rtype: Roi :raises ValueError: If the region of interest is not a Roi object .. rubric:: Examples >>> intensities_array.roi Roi(offset=(0, 0, 0), shape=(10, 20, 30)) .. rubric:: Notes The region of interest is the same as the source array .. py:property:: writable :type: bool Returns whether the array is writable :returns: Whether the array is writable :rtype: bool :raises ValueError: If the array is not writable .. rubric:: Examples >>> intensities_array.writable False .. rubric:: Notes The array is not writable because it is a virtual array created by modifying another array on demand. .. py:property:: dtype Returns the data type of the array :returns: The data type of the array :rtype: type :raises ValueError: If the data type is not a type .. rubric:: Examples >>> intensities_array.dtype numpy.float32 .. rubric:: Notes The data type is always float32 .. py:property:: num_channels :type: int Returns the number of channels in the source array :returns: The number of channels in the source array :rtype: int :raises ValueError: If the number of channels is not an integer .. rubric:: Examples >>> intensities_array.num_channels 3 .. rubric:: Notes The number of channels is the same as the source array .. py:property:: data Returns the data of the source array :returns: The data of the source array :rtype: np.ndarray :raises ValueError: If the data is not a numpy array .. rubric:: Examples >>> intensities_array.data array([[[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]], [[0.7, 0.8, 0.9], [1.0, 1.1, 1.2]]]) .. rubric:: Notes The data is the same as the source array .. py:class:: IntensitiesArrayConfig This config class provides the necessary configuration for turning an Annotated dataset into a multi class binary classification problem. It takes a source array and normalizes the intensities between 0 and 1. The source array is expected to contain a volume with uint64 voxels and no channel dimension. .. attribute:: source_array_config The Array from which to pull annotated data :type: ArrayConfig .. attribute:: min The minimum intensity in your data :type: float .. attribute:: max The maximum intensity in your data :type: float .. method:: to_array Returns the IntensitiesArray object .. rubric:: Notes The source_array_config must be an ArrayConfig object. .. py:attribute:: array_type .. py:attribute:: source_array_config :type: dacapo.experiments.datasplits.datasets.arrays.array_config.ArrayConfig .. py:attribute:: min :type: float .. py:attribute:: max :type: float .. py:class:: MissingAnnotationsMask(array_config) This is wrapper around a ZarrArray containing uint annotations. Complementary to the BinarizeArray class where we convert labels into individual channels for training, we may find crops where a specific label is present, but not annotated. In that case you might want to avoid training specific channels for specific training volumes. See package fibsem_tools for appropriate metadata format for indicating presence of labels in your ground truth. "https://github.com/janelia-cosem/fibsem-tools" .. attribute:: array_config A BinarizeArrayConfig object .. method:: __getitem__(roi Roi) -> np.ndarray: Returns a binary mask of the annotations that are present but not annotated. .. note:: This class is not meant to be used directly. It is used by the BinarizeArray class to mask out annotations that are present but not annotated. .. py:attribute:: name .. py:property:: axes Returns the axes of the source array :returns: Axes of the source array :rtype: list :raises ValueError: If the source array does not have a name .. rubric:: Examples >>> source_array = ZarrArray(ZarrArrayConfig(...)) >>> source_array.axes ['x', 'y', 'z'] .. rubric:: Notes This is a helper function for the BinarizeArray class .. py:property:: dims :type: int Returns the number of dimensions of the source array :returns: Number of dimensions of the source array :rtype: int :raises ValueError: If the source array does not have a name .. rubric:: Examples >>> source_array = ZarrArray(ZarrArrayConfig(...)) >>> source_array.dims 3 .. rubric:: Notes This is a helper function for the BinarizeArray class .. py:property:: voxel_size :type: funlib.geometry.Coordinate Returns the voxel size of the source array :returns: Voxel size of the source array :rtype: Coordinate :raises ValueError: If the source array does not have a name .. rubric:: Examples >>> source_array = ZarrArray(ZarrArrayConfig(...)) >>> source_array.voxel_size Coordinate(x=4, y=4, z=40) .. rubric:: Notes This is a helper function for the BinarizeArray class .. py:property:: roi :type: funlib.geometry.Roi Returns the region of interest of the source array :returns: Region of interest of the source array :rtype: Roi :raises ValueError: If the source array does not have a name .. rubric:: Examples >>> source_array = ZarrArray(ZarrArrayConfig(...)) >>> source_array.roi Roi(offset=(0, 0, 0), shape=(100, 100, 100)) .. rubric:: Notes This is a helper function for the BinarizeArray class .. py:property:: writable :type: bool Returns whether the source array is writable :returns: Whether the source array is writable :rtype: bool :raises ValueError: If the source array does not have a name .. rubric:: Examples >>> source_array = ZarrArray(ZarrArrayConfig(...)) >>> source_array.writable False .. rubric:: Notes This is a helper function for the BinarizeArray class .. py:property:: dtype Returns the data type of the source array :returns: Data type of the source array :rtype: np.dtype :raises ValueError: If the source array does not have a name .. rubric:: Examples >>> source_array = ZarrArray(ZarrArrayConfig(...)) >>> source_array.dtype np.uint8 .. rubric:: Notes This is a helper function for the BinarizeArray class .. py:property:: num_channels :type: int Returns the number of channels :returns: Number of channels :rtype: int :raises ValueError: If the source array does not have a name .. rubric:: Examples >>> source_array = ZarrArray(ZarrArrayConfig(...)) >>> source_array.num_channels 2 .. rubric:: Notes This is a helper function for the BinarizeArray class .. py:property:: data Returns the data of the source array :returns: Data of the source array :rtype: np.ndarray :raises ValueError: If the source array does not have a name .. rubric:: Examples >>> source_array = ZarrArray(ZarrArrayConfig(...)) >>> source_array.data np.ndarray(...) .. rubric:: Notes This is a helper function for the BinarizeArray class .. py:property:: attrs Returns the attributes of the source array :returns: Attributes of the source array :rtype: dict :raises ValueError: If the source array does not have a name .. rubric:: Examples >>> source_array = ZarrArray(ZarrArrayConfig(...)) >>> source_array.attrs {'name': 'source_array', 'resolution': [4, 4, 40]} .. rubric:: Notes This is a helper function for the BinarizeArray class .. py:property:: channels Returns the names of the channels :returns: Names of the channels :rtype: Generator[str] :raises ValueError: If the source array does not have a name .. rubric:: Examples >>> source_array = ZarrArray(ZarrArrayConfig(...)) >>> source_array.channels Generator['channel1', 'channel2', ...] .. rubric:: Notes This is a helper function for the BinarizeArray class .. py:class:: MissingAnnotationsMaskConfig This config class provides the necessary configuration for turning an Annotated dataset into a multi class binary classification problem .. attribute:: source_array_config ArrayConfig The Array from which to pull annotated data. Is expected to contain a volume with uint64 voxels and no channel dimension .. attribute:: groupings List[Tuple[str, List[int]]] List of id groups with a symantic name. Each id group is a List of ids. Group i found in groupings[i] will be binarized and placed in channel i. .. note:: The output array will have a channel dimension equal to the number of groups. Each channel will be a binary mask of the ids in the groupings list. .. py:attribute:: array_type .. py:attribute:: source_array_config :type: dacapo.experiments.datasplits.datasets.arrays.array_config.ArrayConfig .. py:attribute:: groupings :type: List[Tuple[str, List[int]]] .. py:class:: OnesArray(array_config) This is a wrapper around another `source_array` that simply provides ones with the same metadata as the `source_array`. This is useful for creating a mask array that is the same size as the original array, but with all values set to 1. .. attribute:: source_array The source array that this array is based on. .. method:: like Create a new OnesArray with the same metadata as another array. .. method:: attrs Get the attributes of the array. .. method:: axes Get the axes of the array. .. method:: dims Get the dimensions of the array. .. method:: voxel_size Get the voxel size of the array. .. method:: roi Get the region of interest of the array. .. method:: writable Check if the array is writable. .. method:: data Get the data of the array. .. method:: dtype Get the data type of the array. .. method:: num_channels Get the number of channels of the array. .. method:: __getitem__ Get a subarray of the array. .. note:: This class is not meant to be instantiated directly. Instead, use the `like` method to create a new OnesArray with the same metadata as another array. .. py:method:: like(array: dacapo.experiments.datasplits.datasets.arrays.array.Array) :classmethod: Create a new OnesArray with the same metadata as another array. :param array: The source array. :returns: The new OnesArray with the same metadata as the source array. :raises RuntimeError: If the source array is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import OnesArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = OnesArray.like(source_array) >>> ones_array.source_array NumpyArray(data=array([[[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]]), voxel_size=(1.0, 1.0, 1.0), roi=Roi((0, 0, 0), (10, 10, 10)), num_channels=1) .. rubric:: Notes This class is not meant to be instantiated directly. Instead, use the `like` method to create a new OnesArray with the same metadata as another array. .. py:property:: attrs Get the attributes of the array. :returns: An empty dictionary. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import OnesArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = OnesArray(source_array) >>> ones_array.attrs {} .. rubric:: Notes This method is used to get the attributes of the array. The attributes are stored as key-value pairs in a dictionary. This method returns an empty dictionary because the OnesArray does not have any attributes. .. py:property:: source_array :type: dacapo.experiments.datasplits.datasets.arrays.array.Array Get the source array that this array is based on. :returns: The source array. :raises RuntimeError: If the source array is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import OnesArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = OnesArray(source_array) >>> ones_array.source_array NumpyArray(data=array([[[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]]), voxel_size=(1.0, 1.0, 1.0), roi=Roi((0, 0, 0), (10, 10, 10)), num_channels=1) .. rubric:: Notes This method is used to get the source array that this array is based on. The source array is the array that the OnesArray is created from. This method returns the source array that was specified when the OnesArray was created. .. py:property:: axes Get the axes of the array. :returns: The axes of the array. :raises RuntimeError: If the axes are not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import OnesArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = OnesArray(source_array) >>> ones_array.axes 'zyx' .. rubric:: Notes This method is used to get the axes of the array. The axes are the order of the dimensions of the array. This method returns the axes of the array that was specified when the OnesArray was created. .. py:property:: dims Get the dimensions of the array. :returns: The dimensions of the array. :raises RuntimeError: If the dimensions are not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import OnesArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = OnesArray(source_array) >>> ones_array.dims (10, 10, 10) .. rubric:: Notes This method is used to get the dimensions of the array. The dimensions are the size of the array along each axis. This method returns the dimensions of the array that was specified when the OnesArray was created. .. py:property:: voxel_size Get the voxel size of the array. :returns: The voxel size of the array. :raises RuntimeError: If the voxel size is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import OnesArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = OnesArray(source_array) >>> ones_array.voxel_size (1.0, 1.0, 1.0) .. rubric:: Notes This method is used to get the voxel size of the array. The voxel size is the size of each voxel in the array. This method returns the voxel size of the array that was specified when the OnesArray was created. .. py:property:: roi Get the region of interest of the array. :returns: The region of interest of the array. :raises RuntimeError: If the region of interest is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import OnesArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> from funlib.geometry import Roi >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = OnesArray(source_array) >>> ones_array.roi Roi((0, 0, 0), (10, 10, 10)) .. rubric:: Notes This method is used to get the region of interest of the array. The region of interest is the region of the array that contains the data. This method returns the region of interest of the array that was specified when the OnesArray was created. .. py:property:: writable :type: bool Check if the array is writable. :returns: False. :raises RuntimeError: If the writability of the array is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import OnesArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = OnesArray(source_array) >>> ones_array.writable False .. rubric:: Notes This method is used to check if the array is writable. An array is writable if it can be modified in place. This method returns False because the OnesArray is read-only and cannot be modified. .. py:property:: data Get the data of the array. :returns: The data of the array. :raises RuntimeError: If the data is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import OnesArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = OnesArray(source_array) >>> ones_array.data array([[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]]) .. rubric:: Notes This method is used to get the data of the array. The data is the values that are stored in the array. This method returns a subarray of the array with all values set to 1. .. py:property:: dtype Get the data type of the array. :returns: The data type of the array. :raises RuntimeError: If the data type is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import OnesArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = OnesArray(source_array) >>> ones_array.dtype .. rubric:: Notes This method is used to get the data type of the array. The data type is the type of the values that are stored in the array. This method returns the data type of the array that was specified when the OnesArray was created. .. py:property:: num_channels Get the number of channels of the array. :returns: The number of channels of the array. :raises RuntimeError: If the number of channels is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import OnesArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = OnesArray(source_array) >>> ones_array.num_channels 1 .. rubric:: Notes This method is used to get the number of channels of the array. The number of channels is the number of values that are stored at each voxel in the array. This method returns the number of channels of the array that was specified when the OnesArray was created. .. py:class:: OnesArrayConfig This array read data from the source array and then return a np.ones_like() version. This is useful for creating a mask array from a source array. For example, if you have a 2D array of data and you want to create a mask array that is the same shape as the data array, you can use this class to create the mask array. .. attribute:: source_array_config The source array that you want to copy and fill with ones. .. method:: create_array Create the array. .. note:: This class is a subclass of ArrayConfig. .. py:attribute:: array_type .. py:attribute:: source_array_config :type: dacapo.experiments.datasplits.datasets.arrays.array_config.ArrayConfig .. py:class:: ConcatArray(array_config) This is a wrapper around other `source_arrays` that concatenates them along the channel dimension. The `source_arrays` are expected to have the same shape and ROI, but can have different data types. .. attribute:: name The name of the array. .. attribute:: channels The list of channel names. .. attribute:: source_arrays A dictionary mapping channel names to source arrays. .. attribute:: default_array An optional default array to use for channels that are not present in `source_arrays`. .. method:: from_toml(cls, toml_path str) -> ConcatArrayConfig: Load the ConcatArrayConfig from a TOML file .. method:: to_toml(self, toml_path str) -> None: Save the ConcatArrayConfig to a TOML file .. method:: create_array(self) -> ConcatArray Create the ConcatArray from the config .. note:: This class is a subclass of Array and inherits all its attributes and methods. The only difference is that the array_type is ConcatArray. .. py:attribute:: name .. py:attribute:: channels .. py:property:: source_arrays :type: Dict[str, dacapo.experiments.datasplits.datasets.arrays.array.Array] Return the source arrays of the ConcatArray. :returns: The source arrays of the ConcatArray. :rtype: Dict[str, Array] :raises AssertionError: If the source arrays are empty. .. rubric:: Examples >>> config = ConcatArrayConfig( ... name="my_concat_array", ... channels=["A", "B"], ... source_array_configs={ ... "A": ArrayConfig(...), ... "B": ArrayConfig(...), ... }, ... default_config=ArrayConfig(...), ... ) >>> array = ConcatArray(config) >>> array.source_arrays {'A': Array(...), 'B': Array(...)} .. note:: The `source_arrays` are expected to have the same shape and ROI. .. py:attribute:: default_array .. py:property:: attrs Return the attributes of the ConcatArray as a dictionary. :returns: The attributes of the ConcatArray. :rtype: Dict[str, Any] :raises AssertionError: If the source arrays have different attributes. .. rubric:: Examples >>> config = ConcatArrayConfig( ... name="my_concat_array", ... channels=["A", "B"], ... source_array_configs={ ... "A": ArrayConfig(...), ... "B": ArrayConfig(...), ... }, ... default_config=ArrayConfig(...), ... ) >>> array = ConcatArray(config) >>> array.attrs {'axes': 'cxyz', 'roi': Roi(...), 'voxel_size': (1, 1, 1)} .. note:: The `source_arrays` are expected to have the same attributes. .. py:property:: source_array :type: dacapo.experiments.datasplits.datasets.arrays.array.Array Return the source array of the ConcatArray. :returns: The source array of the ConcatArray. :rtype: Array :raises AssertionError: If the source array is None. .. rubric:: Examples >>> config = ConcatArrayConfig( ... name="my_concat_array", ... channels=["A", "B"], ... source_array_configs={ ... "A": ArrayConfig(...), ... "B": ArrayConfig(...), ... }, ... default_config=ArrayConfig(...), ... ) >>> array = ConcatArray(config) >>> array.source_array Array(...) .. note:: The `source_array` is expected to have the same shape and ROI. .. py:property:: axes Return the axes of the ConcatArray. :returns: The axes of the ConcatArray. :rtype: str :raises AssertionError: If the source arrays have different axes. .. rubric:: Examples >>> config = ConcatArrayConfig( ... name="my_concat_array", ... channels=["A", "B"], ... source_array_configs={ ... "A": ArrayConfig(...), ... "B": ArrayConfig(...), ... }, ... default_config=ArrayConfig(...), ... ) >>> array = ConcatArray(config) >>> array.axes 'cxyz' .. note:: The `source_arrays` are expected to have the same axes. .. py:property:: dims Return the dimensions of the ConcatArray. :returns: The dimensions of the ConcatArray. :rtype: Tuple[int] :raises AssertionError: If the source arrays have different dimensions. .. rubric:: Examples >>> config = ConcatArrayConfig( ... name="my_concat_array", ... channels=["A", "B"], ... source_array_configs={ ... "A": ArrayConfig(...), ... "B": ArrayConfig(...), ... }, ... default_config=ArrayConfig(...), ... ) >>> array = ConcatArray(config) >>> array.dims (2, 100, 100, 100) .. note:: The `source_arrays` are expected to have the same dimensions. .. py:property:: voxel_size Return the voxel size of the ConcatArray. :returns: The voxel size of the ConcatArray. :rtype: Tuple[float] :raises AssertionError: If the source arrays have different voxel sizes. .. rubric:: Examples >>> config = ConcatArrayConfig( ... name="my_concat_array", ... channels=["A", "B"], ... source_array_configs={ ... "A": ArrayConfig(...), ... "B": ArrayConfig(...), ... }, ... default_config=ArrayConfig(...), ... ) >>> array = ConcatArray(config) >>> array.voxel_size (1, 1, 1) .. note:: The `source_arrays` are expected to have the same voxel size. .. py:property:: roi Return the ROI of the ConcatArray. :returns: The ROI of the ConcatArray. :rtype: Roi :raises AssertionError: If the source arrays have different ROIs. .. rubric:: Examples >>> config = ConcatArrayConfig( ... name="my_concat_array", ... channels=["A", "B"], ... source_array_configs={ ... "A": ArrayConfig(...), ... "B": ArrayConfig(...), ... }, ... default_config=ArrayConfig(...), ... ) >>> array = ConcatArray(config) >>> array.roi Roi(...) .. note:: The `source_arrays` are expected to have the same ROI. .. py:property:: writable :type: bool Return whether the ConcatArray is writable. :returns: Whether the ConcatArray is writable. :rtype: bool :raises AssertionError: If the ConcatArray is writable. .. rubric:: Examples >>> config = ConcatArrayConfig( ... name="my_concat_array", ... channels=["A", "B"], ... source_array_configs={ ... "A": ArrayConfig(...), ... "B": ArrayConfig(...), ... }, ... default_config=ArrayConfig(...), ... ) >>> array = ConcatArray(config) >>> array.writable False .. note:: The ConcatArray is not writable. .. py:property:: data Return the data of the ConcatArray. :returns: The data of the ConcatArray. :rtype: np.ndarray :raises RuntimeError: If the ConcatArray is not writable. .. rubric:: Examples >>> config = ConcatArrayConfig( ... name="my_concat_array", ... channels=["A", "B"], ... source_array_configs={ ... "A": ArrayConfig(...), ... "B": ArrayConfig(...), ... }, ... default_config=ArrayConfig(...), ... ) >>> array = ConcatArray(config) >>> array.data np.ndarray(...) .. note:: The ConcatArray is not writable. .. py:property:: dtype Return the data type of the ConcatArray. :returns: The data type of the ConcatArray. :rtype: np.dtype :raises AssertionError: If the source arrays have different data types. .. rubric:: Examples >>> config = ConcatArrayConfig( ... name="my_concat_array", ... channels=["A", "B"], ... source_array_configs={ ... "A": ArrayConfig(...), ... "B": ArrayConfig(...), ... }, ... default_config=ArrayConfig(...), ... ) >>> array = ConcatArray(config) >>> array.dtype np.float32 .. note:: The `source_arrays` are expected to have the same data type. .. py:property:: num_channels Return the number of channels of the ConcatArray. :returns: The number of channels of the ConcatArray. :rtype: int :raises AssertionError: If the source arrays have different numbers of channels. .. rubric:: Examples >>> config = ConcatArrayConfig( ... name="my_concat_array", ... channels=["A", "B"], ... source_array_configs={ ... "A": ArrayConfig(...), ... "B": ArrayConfig(...), ... }, ... default_config=ArrayConfig(...), ... ) >>> array = ConcatArray(config) >>> array.num_channels 2 .. note:: The `source_arrays` are expected to have the same number of channels. .. py:class:: ConcatArrayConfig This array read data from the source array and then return a np.ones_like() version of the data. .. attribute:: channels An ordering for the source_arrays. :type: List[str] .. attribute:: source_array_configs A mapping from channels to array_configs. If a channel has no ArrayConfig it will be filled with zeros :type: Dict[str, ArrayConfig] .. attribute:: default_config An optional array providing the default array per channel. If not provided, missing channels will simply be filled with 0s :type: Optional[ArrayConfig] .. method:: __attrs_post_init__(self) This method is called after the instance has been initialized by the constructor. It is used to set the default_config to an instance of ArrayConfig if it is None. .. method:: get_array(self, source_arrays Dict[str, np.ndarray]) -> np.ndarray: This method reads data from the source array and then return a np.ones_like() version of the data. .. note:: This class is used to create a ConcatArray object which is used to read data from the source array and then return a np.ones_like() version of the data. The source array is a dictionary with the key being the channel and the value being the array. .. py:attribute:: array_type .. py:attribute:: channels :type: List[str] .. py:attribute:: source_array_configs :type: Dict[str, dacapo.experiments.datasplits.datasets.arrays.array_config.ArrayConfig] .. py:attribute:: default_config :type: Optional[dacapo.experiments.datasplits.datasets.arrays.array_config.ArrayConfig] .. py:class:: LogicalOrArray(array_config) Array that computes the logical OR of the instances in a list of source arrays. .. attribute:: name str The name of the array .. attribute:: source_array Array The source array from which to take the logical OR .. method:: axes () -> List[str] Get the axes of the array .. method:: dims () -> int Get the number of dimensions of the array .. method:: voxel_size () -> Coordinate Get the voxel size of the array .. method:: roi () -> Roi Get the region of interest of the array .. method:: writable () -> bool Get whether the array is writable .. method:: dtype () -> type Get the data type of the array .. method:: num_channels () -> int Get the number of channels in the array .. method:: data () -> np.ndarray Get the data of the array .. method:: attrs () -> dict Get the attributes of the array .. method:: __getitem__ (roi: Roi) -> np.ndarray Get the data of the array in the region of interest .. method:: _can_neuroglance () -> bool Get whether the array can be visualized in neuroglance .. method:: _neuroglancer_source () -> dict Get the neuroglancer source of the array .. method:: _neuroglancer_layer () -> Tuple[neuroglancer.Layer, dict] Get the neuroglancer layer of the array .. method:: _source_name () -> str Get the name of the source array .. rubric:: Notes The LogicalOrArray class is used to create a LogicalOrArray. The LogicalOrArray class is a subclass of the Array class. .. py:attribute:: name .. py:property:: axes Get the axes of the array :returns: The axes of the array :rtype: List[str] :raises ValueError: If the array is not writable .. rubric:: Examples >>> array_config = MergeInstancesArrayConfig( ... name="logical_or", ... source_array_configs=[ ... ArrayConfig( ... name="mask1", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask1", ... mask_id=1, ... ), ... ), ... ArrayConfig( ... name="mask2", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask2", ... mask_id=2, ... ), ... ), ... ], ... ) >>> array = array_config.create_array() >>> array.axes ['x', 'y', 'z'] .. rubric:: Notes The axes method is used to get the axes of the array. The axes are the dimensions of the array. .. py:property:: dims :type: int Get the number of dimensions of the array :returns: The number of dimensions of the array :rtype: int :raises ValueError: If the array is not writable .. rubric:: Examples >>> array_config = MergeInstancesArrayConfig( ... name="logical_or", ... source_array_configs=[ ... ArrayConfig( ... name="mask1", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask1", ... mask_id=1, ... ), ... ), ... ArrayConfig( ... name="mask2", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask2", ... mask_id=2, ... ), ... ), ... ], ... ) >>> array = array_config.create_array() >>> array.dims 3 .. rubric:: Notes The dims method is used to get the number of dimensions of the array. The number of dimensions is the number of axes of the array. .. py:property:: voxel_size :type: funlib.geometry.Coordinate Get the voxel size of the array :returns: The voxel size of the array :rtype: Coordinate :raises ValueError: If the array is not writable .. rubric:: Examples >>> array_config = MergeInstancesArrayConfig( ... name="logical_or", ... source_array_configs=[ ... ArrayConfig( ... name="mask1", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask1", ... mask_id=1, ... ), ... ), ... ArrayConfig( ... name="mask2", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask2", ... mask_id=2, ... ), ... ), ... ], ... ) >>> array = array_config.create_array() >>> array.voxel_size Coordinate(x=1.0, y=1.0, z=1.0) .. rubric:: Notes The voxel_size method is used to get the voxel size of the array. The voxel size is the size of a voxel in the array. .. py:property:: roi :type: funlib.geometry.Roi Get the region of interest of the array :returns: The region of interest of the array :rtype: Roi :raises ValueError: If the array is not writable .. rubric:: Examples >>> array_config = MergeInstancesArrayConfig( ... name="logical_or", ... source_array_configs=[ ... ArrayConfig( ... name="mask1", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask1", ... mask_id=1, ... ), ... ), ... ArrayConfig( ... name="mask2", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask2", ... mask_id=2, ... ), ... ), ... ], ... ) >>> array = array_config.create_array() >>> array.roi Roi(offset=(0, 0, 0), shape=(10, 10, 10)) .. rubric:: Notes The roi method is used to get the region of interest of the array. The region of interest is the shape and offset of the array. .. py:property:: writable :type: bool Get whether the array is writable :returns: Whether the array is writable :rtype: bool :raises ValueError: If the array is not writable .. rubric:: Examples >>> array_config = MergeInstancesArrayConfig( ... name="logical_or", ... source_array_configs=[ ... ArrayConfig( ... name="mask1", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask1", ... mask_id=1, ... ), ... ), ... ArrayConfig( ... name="mask2", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask2", ... mask_id=2, ... ), ... ), ... ], ... ) >>> array = array_config.create_array() >>> array.writable False .. rubric:: Notes The writable method is used to get whether the array is writable. An array is writable if it can be modified. .. py:property:: dtype Get the data type of the array :returns: The data type of the array :rtype: type :raises ValueError: If the array is not writable .. rubric:: Examples >>> array_config = MergeInstancesArrayConfig( ... name="logical_or", ... source_array_configs=[ ... ArrayConfig( ... name="mask1", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask1", ... mask_id=1, ... ), ... ), ... ArrayConfig( ... name="mask2", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask2", ... mask_id=2, ... ), ... ), ... ], ... ) >>> array = array_config.create_array() >>> array.dtype .. rubric:: Notes The dtype method is used to get the data type of the array. The data type is the type of the data in the array. .. py:property:: num_channels Get the number of channels in the array :returns: The number of channels in the array :rtype: int :raises ValueError: If the array is not writable .. rubric:: Examples >>> array_config = MergeInstancesArrayConfig( ... name="logical_or", ... source_array_configs=[ ... ArrayConfig( ... name="mask1", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask1", ... mask_id=1, ... ), ... ), ... ArrayConfig( ... name="mask2", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask2", ... mask_id=2, ... ), ... ), ... ], ... ) >>> array = array_config.create_array() >>> array.num_channels 1 .. rubric:: Notes The num_channels method is used to get the number of channels in the array. The number of channels is the number of channels in the array. .. py:property:: data Get the data of the array :returns: The data of the array :rtype: np.ndarray :raises ValueError: If the array is not writable .. rubric:: Examples >>> array_config = MergeInstancesArrayConfig( ... name="logical_or", ... source_array_configs=[ ... ArrayConfig( ... name="mask1", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask1", ... mask_id=1, ... ), ... ), ... ArrayConfig( ... name="mask2", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask2", ... mask_id=2, ... ), ... ), ... ], ... ) >>> array = array_config.create_array() >>> array.data array([[[1, 1, 1, ..., 1, 1, 1], [1, 1, 1, ..., 1, 1, 1], [1, 1, 1, ..., 1, 1, 1], ..., [1, 1, 1, ..., 1, 1, 1], [1, 1, 1, ..., 1, 1, 1], [1, 1, 1, ..., 1, 1, 1]]], dtype=uint8) .. rubric:: Notes The data method is used to get the data of the array. The data is the content of the array. .. py:property:: attrs Get the attributes of the array :returns: The attributes of the array :rtype: dict :raises ValueError: If the array is not writable .. rubric:: Examples >>> array_config = MergeInstancesArrayConfig( ... name="logical_or", ... source_array_configs=[ ... ArrayConfig( ... name="mask1", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask1", ... mask_id=1, ... ), ... ), ... ArrayConfig( ... name="mask2", ... array_type=MaskArray, ... source_array_config=MaskArrayConfig( ... name="mask2", ... mask_id=2, ... ), ... ), ... ], ... ) >>> array = array_config.create_array() >>> array.attrs {'name': 'logical_or'} .. rubric:: Notes The attrs method is used to get the attributes of the array. The attributes are the metadata of the array. .. py:class:: LogicalOrArrayConfig This config class takes a source array and performs a logical or over the channels. Good for union multiple masks. .. attribute:: source_array_config The Array of masks from which to take the union :type: ArrayConfig .. method:: to_array Returns the LogicalOrArray object .. rubric:: Notes The source_array_config must be an ArrayConfig object. .. py:attribute:: array_type .. py:attribute:: source_array_config :type: dacapo.experiments.datasplits.datasets.arrays.array_config.ArrayConfig .. py:class:: CropArray(array_config) Used to crop a larger array to a smaller array. This is useful when you want to work with a subset of a larger array, but don't want to copy the data. The crop is done on demand, so the data is not copied until you actually access it. .. attribute:: name The name of the array. .. attribute:: source_array The array to crop. .. attribute:: crop_roi The region of interest to crop to. .. method:: attrs Returns the attributes of the source array. .. method:: axes Returns the axes of the source array. .. method:: dims Returns the number of dimensions of the source array. .. method:: voxel_size Returns the voxel size of the source array. .. method:: roi Returns the region of interest of the source array. .. method:: writable Returns whether the array is writable. .. method:: dtype Returns the data type of the source array. .. method:: num_channels Returns the number of channels of the source array. .. method:: data Returns the data of the source array. .. method:: channels Returns the channels of the source array. .. method:: __getitem__(roi) Returns the data of the source array within the region of interest. .. method:: _can_neuroglance() Returns whether the source array can be viewed in Neuroglancer. .. method:: _neuroglancer_source() Returns the source of the source array for Neuroglancer. .. method:: _neuroglancer_layer() Returns the layer of the source array for Neuroglancer. .. method:: _source_name() Returns the name of the source array. .. note:: This class is a subclass of Array. .. py:attribute:: name .. py:attribute:: crop_roi .. py:property:: attrs Returns the attributes of the source array. :returns: The attributes of the source array. :raises ValueError: If the region of interest to crop to is not within the .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig >>> from dacapo.experiments.datasplits.datasets.arrays import CropArray >>> from funlib.geometry import Roi >>> import numpy as np >>> array_config = ArrayConfig( ... name='array', ... source_array_config=source_array_config, ... roi=Roi((0, 0, 0), (10, 10, 10)) ... ) >>> crop_array = CropArray(array_config) >>> crop_array.attrs {} .. note:: The attributes are empty because the source array is not modified. .. py:property:: axes Returns the axes of the source array. :returns: The axes of the source array. :raises ValueError: If the region of interest to crop to is not within the .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig >>> from dacapo.experiments.datasplits.datasets.arrays import CropArray >>> from funlib.geometry import Roi >>> import numpy as np >>> array_config = ArrayConfig( ... name='array', ... source_array_config=source_array_config, ... roi=Roi((0, 0, 0), (10, 10, 10)) ... ) >>> crop_array = CropArray(array_config) >>> crop_array.axes 'zyx' .. note:: The axes are 'zyx' because the source array is not modified. .. py:property:: dims :type: int Returns the number of dimensions of the source array. :returns: The number of dimensions of the source array. :raises ValueError: If the region of interest to crop to is not within the region of interest of the source array. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig >>> from dacapo.experiments.datasplits.datasets.arrays import CropArray >>> from funlib.geometry import Roi >>> import numpy as np >>> array_config = ArrayConfig( ... name='array', ... source_array_config=source_array_config, ... roi=Roi((0, 0, 0), (10, 10, 10)) ... ) >>> crop_array = CropArray(array_config) >>> crop_array.dims 3 .. note:: The number of dimensions is 3 because the source array is not modified. .. py:property:: voxel_size :type: funlib.geometry.Coordinate Returns the voxel size of the source array. :returns: The voxel size of the source array. :raises ValueError: If the region of interest to crop to is not within the region of interest of the source array. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig >>> from dacapo.experiments.datasplits.datasets.arrays import CropArray >>> from funlib.geometry import Roi >>> import numpy as np >>> array_config = ArrayConfig( ... name='array', ... source_array_config=source_array_config, ... roi=Roi((0, 0, 0), (10, 10, 10)) ... ) >>> crop_array = CropArray(array_config) >>> crop_array.voxel_size Coordinate(x=1.0, y=1.0, z=1.0) .. note:: The voxel size is (1.0, 1.0, 1.0) because the source array is not modified. .. py:property:: roi :type: funlib.geometry.Roi Returns the region of interest of the source array. :returns: The region of interest of the source array. :raises ValueError: If the region of interest to crop to is not within the region of interest of the source array. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig >>> from dacapo.experiments.datasplits.datasets.arrays import CropArray >>> from funlib.geometry import Roi >>> import numpy as np >>> array_config = ArrayConfig( ... name='array', ... source_array_config=source_array_config, ... roi=Roi((0, 0, 0), (10, 10, 10)) ... ) >>> crop_array = CropArray(array_config) >>> crop_array.roi Roi(offset=(0, 0, 0), shape=(10, 10, 10)) .. note:: The region of interest is (0, 0, 0) with shape (10, 10, 10) because the source array is not modified. .. py:property:: writable :type: bool Returns whether the array is writable. :returns: False :raises ValueError: If the region of interest to crop to is not within the region of interest of the source array. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig >>> from dacapo.experiments.datasplits.datasets.arrays import CropArray >>> from funlib.geometry import Roi >>> import numpy as np >>> array_config = ArrayConfig( ... name='array', ... source_array_config=source_array_config, ... roi=Roi((0, 0, 0), (10, 10, 10)) ... ) >>> crop_array = CropArray(array_config) >>> crop_array.writable False .. note:: The array is not writable because it is a virtual array created by modifying another array on demand. .. py:property:: dtype Returns the data type of the source array. :returns: The data type of the source array. :raises ValueError: If the region of interest to crop to is not within the region of interest of the source array. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig >>> from dacapo.experiments.datasplits.datasets.arrays import CropArray >>> from funlib.geometry import Roi >>> import numpy as np >>> array_config = ArrayConfig( ... name='array', ... source_array_config=source_array_config, ... roi=Roi((0, 0, 0), (10, 10, 10)) ... ) >>> crop_array = CropArray(array_config) >>> crop_array.dtype numpy.dtype('uint8') .. note:: The data type is uint8 because the source array is not modified. .. py:property:: num_channels :type: int Returns the number of channels of the source array. :returns: The number of channels of the source array. :raises ValueError: If the region of interest to crop to is not within the region of interest of the source array. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig >>> from dacapo.experiments.datasplits.datasets.arrays import CropArray >>> from funlib.geometry import Roi >>> import numpy as np >>> array_config = ArrayConfig( ... name='array', ... source_array_config=source_array_config, ... roi=Roi((0, 0, 0), (10, 10, 10)) ... ) >>> crop_array = CropArray(array_config) >>> crop_array.num_channels 1 .. note:: The number of channels is 1 because the source array is not modified. .. py:property:: data Returns the data of the source array. :returns: The data of the source array. :raises ValueError: If the region of interest to crop to is not within the region of interest of the source array. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig >>> from dacapo.experiments.datasplits.datasets.arrays import CropArray >>> from funlib.geometry import Roi >>> import numpy as np >>> array_config = ArrayConfig( ... name='array', ... source_array_config=source_array_config, ... roi=Roi((0, 0, 0), (10, 10, 10)) ... ) >>> crop_array = CropArray(array_config) >>> crop_array.data array([[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], [[0, 0, 0, 0, 0, 0, 0, 0, 0 .. py:property:: channels Returns the channels of the source array. :returns: The channels of the source array. :raises ValueError: If the region of interest to crop to is not within the region of interest of the source array. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig >>> from dacapo.experiments.datasplits.datasets.arrays import CropArray >>> from funlib.geometry import Roi >>> import numpy as np >>> array_config = ArrayConfig( ... name='array', ... source_array_config=source_array_config, ... roi=Roi((0, 0, 0), (10, 10, 10)) ... ) >>> crop_array = CropArray(array_config) >>> crop_array.channels 1 .. note:: The channels is 1 because the source array is not modified. .. py:class:: CropArrayConfig This config class provides the necessary configuration for cropping an Array to a smaller ROI. Especially useful for validation volumes that may be too large for quick evaluation. The ROI is specified in the config. The cropped Array will have the same dtype as the source Array. .. attribute:: source_array_config The Array to crop :type: ArrayConfig .. attribute:: roi The ROI for cropping :type: Roi .. method:: from_toml(cls, toml_path str) -> CropArrayConfig: Load the CropArrayConfig from a TOML file .. method:: to_toml(self, toml_path str) -> None: Save the CropArrayConfig to a TOML file .. method:: create_array(self) -> CropArray Create the CropArray from the config .. note:: This class is a subclass of ArrayConfig and inherits all its attributes and methods. The only difference is that the array_type is CropArray. .. py:attribute:: array_type .. py:attribute:: source_array_config :type: dacapo.experiments.datasplits.datasets.arrays.array_config.ArrayConfig .. py:attribute:: roi :type: funlib.geometry.Roi .. py:class:: MergeInstancesArray(array_config) This array merges multiple source arrays into a single array by summing them. This is useful for merging instance segmentation arrays into a single array. NeuoGlancer will display each instance as a different color. .. attribute:: name str The name of the array .. attribute:: source_array_configs List[ArrayConfig] A list of source arrays to merge .. method:: __getitem__(roi Roi) -> np.ndarray Returns a numpy array with the requested region of interest .. method:: _can_neuroglance() -> bool Returns True if the array can be visualized in neuroglancer .. method:: _neuroglancer_source() -> str Returns the source name for the array in neuroglancer .. method:: _neuroglancer_layer() -> Tuple[neuroglancer.SegmentationLayer, Dict[str, Any]] Returns a neuroglancer layer and its configuration .. method:: _source_name() -> str Returns the source name for the array .. note:: This array is not writable Source arrays must have the same shape. .. py:attribute:: name .. py:property:: axes Returns the axes of the array :returns: The axes of the array :rtype: List[str] :raises ValueError: If the source arrays have different shapes .. rubric:: Example ```python from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArray from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayType from funlib.geometry import Coordinate, Roi array_config = MergeInstancesArrayConfig( name="array", source_array_configs=[ ArrayConfig( name="array1", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array1.h5", ), ArrayConfig( name="array2", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array2.h5", ), ], ) array = MergeInstancesArray(array_config) axes = array.axes ``` .. note:: This example shows how to get the axes of the array .. py:property:: dims :type: int Returns the number of dimensions of the array :returns: The number of dimensions of the array :rtype: int :raises ValueError: If the source arrays have different shapes .. rubric:: Example ```python from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArray from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayType from funlib.geometry import Coordinate, Roi array_config = MergeInstancesArrayConfig( name="array", source_array_configs=[ ArrayConfig( name="array1", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array1.h5", ), ArrayConfig( name="array2", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array2.h5", ), ], ) array = MergeInstancesArray(array_config) dims = array.dims ``` .. note:: This example shows how to get the number of dimensions of the array .. py:property:: voxel_size :type: funlib.geometry.Coordinate Returns the voxel size of the array :returns: The voxel size of the array :rtype: Coordinate :raises ValueError: If the source arrays have different shapes .. rubric:: Example ```python from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArray from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayType from funlib.geometry import Coordinate, Roi array_config = MergeInstancesArrayConfig( name="array", source_array_configs=[ ArrayConfig( name="array1", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array1.h5", ), ArrayConfig( name="array2", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array2.h5", ), ], ) array = MergeInstancesArray(array_config) voxel_size = array.voxel_size ``` .. note:: This example shows how to get the voxel size of the array .. py:property:: roi :type: funlib.geometry.Roi Returns the region of interest of the array :returns: The region of interest of the array :rtype: Roi :raises ValueError: If the source arrays have different shapes .. rubric:: Example ```python from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArray from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayType from funlib.geometry import Coordinate, Roi array_config = MergeInstancesArrayConfig( name="array", source_array_configs=[ ArrayConfig( name="array1", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array1.h5", ), ArrayConfig( name="array2", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array2.h5", ), ], ) array = MergeInstancesArray(array_config) roi = array.roi ``` .. note:: This example shows how to get the region of interest of the array .. py:property:: writable :type: bool Returns True if the array is writable, False otherwise :returns: True if the array is writable, False otherwise :rtype: bool :raises ValueError: If the source arrays have different shapes .. rubric:: Example ```python from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArray from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayType from funlib.geometry import Coordinate, Roi array_config = MergeInstancesArrayConfig( name="array", source_array_configs=[ ArrayConfig( name="array1", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array1.h5", ), ArrayConfig( name="array2", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array2.h5", ), ], ) array = MergeInstancesArray(array_config) writable = array.writable ``` .. note:: This example shows how to check if the array is writable .. py:property:: dtype Returns the data type of the array :returns: The data type of the array :rtype: np.dtype :raises ValueError: If the source arrays have different shapes .. rubric:: Example ```python from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArray from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayType from funlib.geometry import Coordinate, Roi array_config = MergeInstancesArrayConfig( name="array", source_array_configs=[ ArrayConfig( name="array1", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array1.h5", ), ArrayConfig( name="array2", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array2.h5", ), ], ) array = MergeInstancesArray(array_config) dtype = array.dtype ``` .. note:: This example shows how to get the data type of the array .. py:property:: num_channels Returns the number of channels of the array :returns: The number of channels of the array :rtype: int :raises ValueError: If the source arrays have different shapes .. rubric:: Example ```python from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArray from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayType from funlib.geometry import Coordinate, Roi array_config = MergeInstancesArrayConfig( name="array", source_array_configs=[ ArrayConfig( name="array1", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array1.h5", ), ArrayConfig( name="array2", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array2.h5", ), ], ) array = MergeInstancesArray(array_config) num_channels = array.num_channels ``` .. note:: This example shows how to get the number of channels of the array .. py:property:: data Returns the data of the array :returns: The data of the array :rtype: np.ndarray :raises ValueError: If the source arrays have different shapes .. rubric:: Example ```python from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArray from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayType from funlib.geometry import Coordinate, Roi array_config = MergeInstancesArrayConfig( name="array", source_array_configs=[ ArrayConfig( name="array1", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array1.h5", ), ArrayConfig( name="array2", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array2.h5", ), ], ) array = MergeInstancesArray(array_config) data = array.data ``` .. note:: This example shows how to get the data of the array .. py:property:: attrs Returns the attributes of the array :returns: The attributes of the array :rtype: Dict[str, Any] :raises ValueError: If the source arrays have different shapes .. rubric:: Example ```python from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArray from dacapo.experiments.datasplits.datasets.arrays import MergeInstancesArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayConfig from dacapo.experiments.datasplits.datasets.arrays import ArrayType from funlib.geometry import Coordinate, Roi array_config = MergeInstancesArrayConfig( name="array", source_array_configs=[ ArrayConfig( name="array1", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array1.h5", ), ArrayConfig( name="array2", array_type=ArrayType.INSTANCE_SEGMENTATION, path="path/to/array2.h5", ), ], ) array = MergeInstancesArray(array_config) attributes = array.attrs ``` .. note:: This example shows how to get the attributes of the array .. py:class:: MergeInstancesArrayConfig Configuration for an array that merges instances from multiple arrays into a single array. The instances are merged by taking the union of the instances in the source arrays. .. attribute:: source_array_configs List[ArrayConfig] The Array of masks from which to take the union .. method:: create_array () -> MergeInstancesArray Create a MergeInstancesArray instance from the configuration .. rubric:: Notes The MergeInstancesArrayConfig class is used to create a MergeInstancesArray .. py:attribute:: array_type .. py:attribute:: source_array_configs :type: List[dacapo.experiments.datasplits.datasets.arrays.array_config.ArrayConfig] .. py:class:: DVIDArray(array_config) This is a DVID array. It is a wrapper around a DVID array that provides the necessary methods to interact with the array. It is used to fetch data from a DVID server. The source is a tuple of three strings: the server, the UUID, and the data name. DVID: data management system for terabyte-sized 3D images .. attribute:: name The name of the array :type: str .. attribute:: source The source of the array :type: tuple[str, str, str] .. method:: __getitem__ Returns the data from the array for a given region of interest .. rubric:: Notes The source is a tuple of three strings: the server, the UUID, and the data name. .. py:attribute:: name :type: str .. py:attribute:: source :type: tuple[str, str, str] .. py:method:: attrs() Returns the attributes of the DVID array :returns: The attributes of the DVID array :rtype: dict :raises ValueError: If the attributes is not a dictionary .. rubric:: Examples >>> dvid_array.attrs {'Extended': {'VoxelSize': (1.0, 1.0, 1.0), 'Values': [{'DataType': 'uint64'}]}, 'Extents': {'MinPoint': (0, 0, 0), 'MaxPoint': (100, 100, 100)}} .. rubric:: Notes The attributes are the same as the source array .. py:property:: axes Returns the axes of the DVID array :returns: The axes of the DVID array :rtype: str :raises ValueError: If the axes is not a string .. rubric:: Examples >>> dvid_array.axes 'zyx' .. rubric:: Notes The axes are the same as the source array .. py:property:: dims :type: int Returns the dimensions of the DVID array :returns: The dimensions of the DVID array :rtype: int :raises ValueError: If the dimensions is not an integer .. rubric:: Examples >>> dvid_array.dims 3 .. rubric:: Notes The dimensions are the same as the source array .. py:method:: voxel_size() -> funlib.geometry.Coordinate Returns the voxel size of the DVID array :returns: The voxel size of the DVID array :rtype: Coordinate :raises ValueError: If the voxel size is not a Coordinate object .. rubric:: Examples >>> dvid_array.voxel_size Coordinate(x=1.0, y=1.0, z=1.0) .. rubric:: Notes The voxel size is the same as the source array .. py:method:: roi() -> funlib.geometry.Roi Returns the region of interest of the DVID array :returns: The region of interest of the DVID array :rtype: Roi :raises ValueError: If the region of interest is not a Roi object .. rubric:: Examples >>> dvid_array.roi Roi(...) .. rubric:: Notes The region of interest is the same as the source array .. py:property:: writable :type: bool Returns whether the DVID array is writable :returns: Whether the DVID array is writable :rtype: bool :raises ValueError: If the writable is not a boolean .. rubric:: Examples >>> dvid_array.writable False .. rubric:: Notes The writable is the same as the source array .. py:property:: dtype :type: Any Returns the data type of the DVID array :returns: The data type of the DVID array :rtype: type :raises ValueError: If the data type is not a type .. rubric:: Examples >>> dvid_array.dtype numpy.uint64 .. rubric:: Notes The data type is the same as the source array .. py:property:: num_channels :type: Optional[int] Returns the number of channels of the DVID array :returns: The number of channels of the DVID array :rtype: int :raises ValueError: If the number of channels is not an integer .. rubric:: Examples >>> dvid_array.num_channels 1 .. rubric:: Notes The number of channels is the same as the source array .. py:property:: spatial_axes :type: List[str] Returns the spatial axes of the DVID array :returns: The spatial axes of the DVID array :rtype: List[str] :raises ValueError: If the spatial axes is not a list .. rubric:: Examples >>> dvid_array.spatial_axes ['z', 'y', 'x'] .. rubric:: Notes The spatial axes are the same as the source array .. py:property:: data :type: Any :abstractmethod: Returns the number of channels of the DVID array :returns: The number of channels of the DVID array :rtype: int :raises ValueError: If the number of channels is not an integer .. rubric:: Examples >>> dvid_array.num_channels 1 .. rubric:: Notes The number of channels is the same as the source array .. py:method:: add_metadata(metadata: Dict[str, Any]) -> None :abstractmethod: Adds metadata to the DVID array :param metadata: The metadata to add to the DVID array :type metadata: dict :returns: None :raises ValueError: If the metadata is not a dictionary .. rubric:: Examples >>> dvid_array.add_metadata({'description': 'This is a DVID array'}) .. rubric:: Notes The metadata is added to the source array .. py:class:: DVIDArrayConfig This config class provides the necessary configuration for a DVID array. It takes a source string and returns the DVIDArray object. .. attribute:: source The source strings :type: Tuple[str, str, str] .. method:: to_array Returns the DVIDArray object .. rubric:: Notes The source must be a tuple of strings. .. py:attribute:: array_type .. py:attribute:: source :type: Tuple[str, str, str] .. py:method:: verify() -> Tuple[bool, str] Check whether this is a valid Array :returns: Whether the Array is valid and a message :rtype: Tuple[bool, str] :raises ValueError: If the source is not a tuple of strings .. rubric:: Examples >>> dvid_array_config = DVIDArrayConfig(...) >>> dvid_array_config.verify() (True, "No validation for this Array") .. rubric:: Notes The source must be a tuple of strings. .. py:class:: SumArray(array_config) This class provides a sum array. This array is a virtual array that is created by summing multiple source arrays. The source arrays must have the same shape and ROI. .. attribute:: name str The name of the array. .. attribute:: _source_arrays List[Array] The source arrays to sum. .. attribute:: _source_array Array The first source array. .. method:: __getitem__(roi Roi) -> np.ndarray Get the data for the given region of interest. .. method:: _can_neuroglance() -> bool Check if neuroglance can be used. .. method:: _neuroglancer_source() -> Dict Return the source for neuroglance. .. method:: _neuroglancer_layer() -> Tuple[neuroglancer.SegmentationLayer, Dict] Return the neuroglancer layer. .. method:: _source_name() -> str Return the source name. .. note:: This class is a subclass of Array. .. py:attribute:: name .. py:property:: axes The axes of the array. :returns: The axes of the array. :rtype: List[str] :raises ValueError: Cannot get a writable view of this array because it is a virtual array created by modifying another array on demand. .. rubric:: Examples >>> sum_array.axes ['x', 'y', 'z'] .. note:: This class is a subclass of Array. .. py:property:: dims :type: int The number of dimensions of the array. :returns: The number of dimensions of the array. :rtype: int :raises ValueError: Cannot get a writable view of this array because it is a virtual array created by modifying another array on demand. .. rubric:: Examples >>> sum_array.dims 3 .. note:: This class is a subclass of Array. .. py:property:: voxel_size :type: funlib.geometry.Coordinate The size of each voxel in each dimension. :returns: The size of each voxel in each dimension. :rtype: Coordinate :raises ValueError: Cannot get a writable view of this array because it is a virtual array created by modifying another array on demand. .. rubric:: Examples >>> sum_array.voxel_size Coordinate([1, 1, 1]) .. note:: This class is a subclass of Array. .. py:property:: roi :type: funlib.geometry.Roi The region of interest of the array. :param roi: Roi The region of interest. :returns: The region of interest. :rtype: Roi :raises ValueError: Cannot get a writable view of this array because it is a virtual array created by modifying another array on demand. .. rubric:: Examples >>> sum_array.roi Roi(Coordinate([0, 0, 0]), Coordinate([100, 100, 100])) .. note:: This class is a subclass of Array. .. py:property:: writable :type: bool Check if the array is writable. :param writable: bool Check if the array is writable. :returns: True if the array is writable, otherwise False. :rtype: bool :raises ValueError: Cannot get a writable view of this array because it is a virtual array created by modifying another array on demand. .. rubric:: Examples >>> sum_array.writable False .. note:: This class is a subclass of Array. .. py:property:: dtype The data type of the array. :param dtype: np.uint8 The data type of the array. :returns: The data type of the array. :rtype: np.uint8 :raises ValueError: Cannot get a writable view of this array because it is a virtual array created by modifying another array on demand. .. rubric:: Examples >>> sum_array.dtype np.uint8 .. note:: This class is a subclass of Array. .. py:property:: num_channels The number of channels in the array. :param num_channels: Optional[int] The number of channels in the array. :returns: The number of channels in the array. :rtype: Optional[int] :raises ValueError: Cannot get a writable view of this array because it is a virtual array created by modifying another array on demand. .. rubric:: Examples >>> sum_array.num_channels None .. note:: This class is a subclass of Array. .. py:property:: data Get the data of the array. :param data: np.ndarray The data of the array. :returns: The data of the array. :rtype: np.ndarray :raises ValueError: Cannot get a writable view of this array because it is a virtual array created by modifying another array on demand. .. rubric:: Examples >>> sum_array.data np.array([[[0, 0], [0, 0]], [[0, 0], [0, 0]]]) .. note:: This class is a subclass of Array. .. py:property:: attrs Return the attributes of the array. :param attrs: Dict The attributes of the array. :returns: The attributes of the array. :rtype: Dict :raises ValueError: Cannot get a writable view of this array because it is a virtual array created by modifying another array on demand. .. rubric:: Examples >>> sum_array.attrs {} .. note:: This class is a subclass of Array. .. py:class:: SumArrayConfig This config class provides the necessary configuration for a sum array. .. attribute:: source_array_configs List[ArrayConfig] The Array of masks from which to take the union .. note:: This class is a subclass of ArrayConfig. .. py:attribute:: array_type .. py:attribute:: source_array_configs :type: List[dacapo.experiments.datasplits.datasets.arrays.array_config.ArrayConfig] .. py:class:: NumpyArray(array_config) This is just a wrapper for a numpy array to make it fit the DaCapo Array interface. .. attribute:: data The numpy array. .. attribute:: dtype The data type of the numpy array. .. attribute:: roi The region of interest of the numpy array. .. attribute:: voxel_size The voxel size of the numpy array. .. attribute:: axes The axes of the numpy array. .. method:: from_gp_array Create a NumpyArray from a Gunpowder Array. .. method:: from_np_array Create a NumpyArray from a numpy array. .. note:: This class is a subclass of Array. .. py:property:: attrs Returns the attributes of the array. :returns: The attributes of the array. :rtype: dict :raises ValueError: If the array does not have attributes. .. rubric:: Examples >>> array = NumpyArray.from_np_array(np.zeros((2, 3, 4)), Roi((0, 0, 0), (2, 3, 4)), Coordinate((1, 1, 1)), ["z", "y", "x"]) >>> array.attrs {} .. note:: This method is a property. It returns the attributes of the array. .. py:method:: from_gp_array(array: gunpowder.Array) :classmethod: Create a NumpyArray from a Gunpowder Array. :param array: The Gunpowder Array. :type array: gp.Array :returns: The NumpyArray. :rtype: NumpyArray :raises ValueError: If the array does not have a data type. .. rubric:: Examples >>> array = gp.Array(data=np.zeros((2, 3, 4)), spec=gp.ArraySpec(roi=Roi((0, 0, 0), (2, 3, 4)), voxel_size=Coordinate((1, 1, 1)))) >>> array = NumpyArray.from_gp_array(array) >>> array.data array([[[0., 0., 0., 0.], [0., 0., 0., 0.], [0., 0., 0., 0.]], [[0., 0., 0., 0.], [0., 0., 0., 0.], [0., 0., 0., 0.]]]) .. note:: This method creates a NumpyArray from a Gunpowder Array. .. py:method:: from_np_array(array: numpy.ndarray, roi, voxel_size, axes) :classmethod: Create a NumpyArray from a numpy array. :param array: The numpy array. :type array: np.ndarray :param roi: The region of interest of the array. :type roi: Roi :param voxel_size: The voxel size of the array. :type voxel_size: Coordinate :param axes: The axes of the array. :type axes: List[str] :returns: The NumpyArray. :rtype: NumpyArray :raises ValueError: If the array does not have a data type. .. rubric:: Examples >>> array = NumpyArray.from_np_array(np.zeros((2, 3, 4)), Roi((0, 0, 0), (2, 3, 4)), Coordinate((1, 1, 1)), ["z", "y", "x"]) >>> array.data array([[[0., 0., 0., 0.], [0., 0., 0., 0.], [0., 0., 0., 0.]], [[0., 0., 0., 0.], [0., 0., 0., 0.], [0., 0., 0., 0.]]]) .. note:: This method creates a NumpyArray from a numpy array. .. py:property:: axes Returns the axes of the array. :returns: The axes of the array. :rtype: List[str] :raises ValueError: If the array does not have axes. .. rubric:: Examples >>> array = NumpyArray.from_np_array(np.zeros((2, 3, 4)), Roi((0, 0, 0), (2, 3, 4)), Coordinate((1, 1, 1)), ["z", "y", "x"]) >>> array.axes ['z', 'y', 'x'] .. note:: This method is a property. It returns the axes of the array. .. py:property:: dims Returns the number of dimensions of the array. :returns: The number of dimensions of the array. :rtype: int :raises ValueError: If the array does not have a dimension. .. rubric:: Examples >>> array = NumpyArray.from_np_array(np.zeros((2, 3, 4)), Roi((0, 0, 0), (2, 3, 4)), Coordinate((1, 1, 1)), ["z", "y", "x"]) >>> array.dims 3 .. note:: This method is a property. It returns the number of dimensions of the array. .. py:property:: voxel_size Returns the voxel size of the array. :returns: The voxel size of the array. :rtype: Coordinate .. rubric:: Examples >>> array = NumpyArray.from_np_array(np.zeros((2, 3, 4)), Roi((0, 0, 0), (2, 3, 4)), Coordinate((1, 1, 1)), ["z", "y", "x"]) >>> array.voxel_size Coordinate((1, 1, 1)) .. note:: This method is a property. It returns the voxel size of the array. .. py:property:: roi Returns the region of interest of the array. :returns: The region of interest of the array. :rtype: Roi .. rubric:: Examples >>> array = NumpyArray.from_np_array(np.zeros((2, 3, 4)), Roi((0, 0, 0), (2, 3, 4)), Coordinate((1, 1, 1)), ["z", "y", "x"]) >>> array.roi Roi((0, 0, 0), (2, 3, 4)) .. note:: This method is a property. It returns the region of interest of the array. .. py:property:: writable :type: bool Returns whether the array is writable. :returns: Whether the array is writable. :rtype: bool :raises ValueError: If the array is not writable. .. rubric:: Examples >>> array = NumpyArray.from_np_array(np.zeros((2, 3, 4)), Roi((0, 0, 0), (2, 3, 4)), Coordinate((1, 1, 1)), ["z", "y", "x"]) >>> array.writable True .. note:: This method is a property. It returns whether the array is writable. .. py:property:: data Returns the numpy array. :returns: The numpy array. :rtype: np.ndarray .. rubric:: Examples >>> array = NumpyArray.from_np_array(np.zeros((2, 3, 4)), Roi((0, 0, 0), (2, 3, 4)), Coordinate((1, 1, 1)), ["z", "y", "x"]) >>> array.data array([[[0., 0., 0., 0.], [0., 0., 0., 0.], [0., 0., 0., 0.]], [[0., 0., 0., 0.], [0., 0., 0., 0.], [0., 0., 0., 0.]]]) .. note:: This method is a property. It returns the numpy array. .. py:property:: dtype Returns the data type of the array. :returns: The data type of the array. :rtype: np.dtype :raises ValueError: If the array does not have a data type. .. rubric:: Examples >>> array = NumpyArray.from_np_array(np.zeros((2, 3, 4)), Roi((0, 0, 0), (2, 3, 4)), Coordinate((1, 1, 1)), ["z", "y", "x"]) >>> array.dtype dtype('float64') .. note:: This method is a property. It returns the data type of the array. .. py:property:: num_channels Returns the number of channels in the array. :returns: The number of channels in the array. :rtype: int :raises ValueError: If the array does not have a channel dimension. .. rubric:: Examples >>> array = NumpyArray.from_np_array(np.zeros((1, 2, 3, 4)), Roi((0, 0, 0), (1, 2, 3)), Coordinate((1, 1, 1)), ["b", "c", "z", "y", "x"]) >>> array.num_channels 1 >>> array = NumpyArray.from_np_array(np.zeros((2, 3, 4)), Roi((0, 0, 0), (2, 3, 4)), Coordinate((1, 1, 1)), ["z", "y", "x"]) >>> array.num_channels Traceback (most recent call last): ... ValueError: Array does not have a channel dimension. .. note:: This method is a property. It returns the number of channels in the array. .. py:class:: ConstantArray(array_config) This is a wrapper around another `source_array` that simply provides constant value with the same metadata as the `source_array`. This is useful for creating a mask array that is the same size as the original array, but with all values set to 1. .. attribute:: source_array The source array that this array is based on. .. method:: like Create a new ConstantArray with the same metadata as another array. .. method:: attrs Get the attributes of the array. .. method:: axes Get the axes of the array. .. method:: dims Get the dimensions of the array. .. method:: voxel_size Get the voxel size of the array. .. method:: roi Get the region of interest of the array. .. method:: writable Check if the array is writable. .. method:: data Get the data of the array. .. method:: dtype Get the data type of the array. .. method:: num_channels Get the number of channels of the array. .. method:: __getitem__ Get a subarray of the array. .. note:: This class is not meant to be instantiated directly. Instead, use the `like` method to create a new ConstantArray with the same metadata as another array. .. py:method:: like(array: dacapo.experiments.datasplits.datasets.arrays.array.Array) :classmethod: Create a new ConstantArray with the same metadata as another array. :param array: The source array. :returns: The new ConstantArray with the same metadata as the source array. :raises RuntimeError: If the source array is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ConstantArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = ConstantArray.like(source_array) >>> ones_array.source_array NumpyArray(data=array([[[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]]), voxel_size=(1.0, 1.0, 1.0), roi=Roi((0, 0, 0), (10, 10, 10)), num_channels=1) .. rubric:: Notes This class is not meant to be instantiated directly. Instead, use the `like` method to create a new ConstantArray with the same metadata as another array. .. py:property:: attrs Get the attributes of the array. :returns: An empty dictionary. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ConstantArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = ConstantArray(source_array) >>> ones_array.attrs {} .. rubric:: Notes This method is used to get the attributes of the array. The attributes are stored as key-value pairs in a dictionary. This method returns an empty dictionary because the ConstantArray does not have any attributes. .. py:property:: source_array :type: dacapo.experiments.datasplits.datasets.arrays.array.Array Get the source array that this array is based on. :returns: The source array. :raises RuntimeError: If the source array is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ConstantArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = ConstantArray(source_array) >>> ones_array.source_array NumpyArray(data=array([[[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]]), voxel_size=(1.0, 1.0, 1.0), roi=Roi((0, 0, 0), (10, 10, 10)), num_channels=1) .. rubric:: Notes This method is used to get the source array that this array is based on. The source array is the array that the ConstantArray is created from. This method returns the source array that was specified when the ConstantArray was created. .. py:property:: axes Get the axes of the array. :returns: The axes of the array. :raises RuntimeError: If the axes are not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ConstantArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = ConstantArray(source_array) >>> ones_array.axes 'zyx' .. rubric:: Notes This method is used to get the axes of the array. The axes are the order of the dimensions of the array. This method returns the axes of the array that was specified when the ConstantArray was created. .. py:property:: dims Get the dimensions of the array. :returns: The dimensions of the array. :raises RuntimeError: If the dimensions are not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ConstantArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = ConstantArray(source_array) >>> ones_array.dims (10, 10, 10) .. rubric:: Notes This method is used to get the dimensions of the array. The dimensions are the size of the array along each axis. This method returns the dimensions of the array that was specified when the ConstantArray was created. .. py:property:: voxel_size Get the voxel size of the array. :returns: The voxel size of the array. :raises RuntimeError: If the voxel size is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ConstantArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = ConstantArray(source_array) >>> ones_array.voxel_size (1.0, 1.0, 1.0) .. rubric:: Notes This method is used to get the voxel size of the array. The voxel size is the size of each voxel in the array. This method returns the voxel size of the array that was specified when the ConstantArray was created. .. py:property:: roi Get the region of interest of the array. :returns: The region of interest of the array. :raises RuntimeError: If the region of interest is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ConstantArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> from funlib.geometry import Roi >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = ConstantArray(source_array) >>> ones_array.roi Roi((0, 0, 0), (10, 10, 10)) .. rubric:: Notes This method is used to get the region of interest of the array. The region of interest is the region of the array that contains the data. This method returns the region of interest of the array that was specified when the ConstantArray was created. .. py:property:: writable :type: bool Check if the array is writable. :returns: False. :raises RuntimeError: If the writability of the array is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ConstantArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = ConstantArray(source_array) >>> ones_array.writable False .. rubric:: Notes This method is used to check if the array is writable. An array is writable if it can be modified in place. This method returns False because the ConstantArray is read-only and cannot be modified. .. py:property:: data Get the data of the array. :returns: The data of the array. :raises RuntimeError: If the data is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ConstantArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = ConstantArray(source_array) >>> ones_array.data array([[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]]) .. rubric:: Notes This method is used to get the data of the array. The data is the values that are stored in the array. This method returns a subarray of the array with all values set to 1. .. py:property:: dtype Get the data type of the array. :returns: The data type of the array. :raises RuntimeError: If the data type is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ConstantArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = ConstantArray(source_array) >>> ones_array.dtype .. rubric:: Notes This method is used to get the data type of the array. The data type is the type of the values that are stored in the array. This method returns the data type of the array that was specified when the ConstantArray was created. .. py:property:: num_channels Get the number of channels of the array. :returns: The number of channels of the array. :raises RuntimeError: If the number of channels is not specified. .. rubric:: Examples >>> from dacapo.experiments.datasplits.datasets.arrays import ConstantArray >>> from dacapo.experiments.datasplits.datasets.arrays import NumpyArray >>> import numpy as np >>> source_array = NumpyArray(np.zeros((10, 10, 10))) >>> ones_array = ConstantArray(source_array) >>> ones_array.num_channels 1 .. rubric:: Notes This method is used to get the number of channels of the array. The number of channels is the number of values that are stored at each voxel in the array. This method returns the number of channels of the array that was specified when the ConstantArray was created. .. py:class:: ConstantArrayConfig This array read data from the source array and then return a np.ones_like() version. This is useful for creating a mask array from a source array. For example, if you have a 2D array of data and you want to create a mask array that is the same shape as the data array, you can use this class to create the mask array. .. attribute:: source_array_config The source array that you want to copy and fill with ones. .. method:: create_array Create the array. .. note:: This class is a subclass of ArrayConfig. .. py:attribute:: array_type .. py:attribute:: source_array_config :type: dacapo.experiments.datasplits.datasets.arrays.array_config.ArrayConfig .. py:attribute:: constant :type: int