dacapo.experiments.datasplits.datasets.arrays.merge_instances_array =================================================================== .. py:module:: dacapo.experiments.datasplits.datasets.arrays.merge_instances_array Classes ------- .. autoapisummary:: dacapo.experiments.datasplits.datasets.arrays.merge_instances_array.MergeInstancesArray Module Contents --------------- .. 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