dacapo.experiments.datasplits.datasets.arrays.array
Classes
An Array is a multi-dimensional array of data that can be read from and written to. It is |
Module Contents
- class dacapo.experiments.datasplits.datasets.arrays.array.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.
- attrs
A dictionary of metadata attributes stored on this array.
- Type:
Dict[str, Any]
- axes
The axes of this dataset as a string of characters, as they are indexed. Permitted characters are:
zyxfor spatial dimensionscfor channelssfor samples
- Type:
List[str]
- dims
The number of spatial dimensions.
- Type:
int
- voxel_size
The size of a voxel in physical units.
- Type:
Coordinate
- roi
The total ROI of this array, in world units.
- Type:
Roi
- dtype
The dtype of this array, in numpy dtypes
- Type:
Any
- num_channels
The number of channels provided by this dataset. Should return None if the channel dimension doesn’t exist.
- Type:
Optional[int]
- data
A numpy-like readable and writable view into this array.
- Type:
np.ndarray
- writable
Can we write to this Array?
- Type:
bool
- __getitem__(self, roi
Roi) -> np.ndarray: Get a numpy like readable and writable view into this array.
- _can_neuroglance(self) bool
Check if this array can be visualized in Neuroglancer.
- _neuroglancer_layer(self)
Generate a Neuroglancer layer for this array.
- _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.
- property attrs: Dict[str, Any]
- Abstractmethod:
Return a dictionary of metadata attributes stored on this array.
- Returns:
A dictionary of metadata attributes stored on this array.
- Return type:
Dict[str, Any]
- Raises:
NotImplementedError – This method must be implemented by the subclass.
Examples
>>> array = Array() >>> array.attrs {}
Note
This method must be implemented by the subclass.
- property axes: List[str]
- Abstractmethod:
Returns the axes of this dataset as a string of charactes, as they are indexed. Permitted characters are:
zyxfor spatial dimensionscfor channelssfor samples
- Returns:
The axes of this dataset as a string of characters, as they are indexed.
- Return type:
List[str]
- Raises:
NotImplementedError – This method must be implemented by the subclass.
Examples
>>> array = Array() >>> array.axes ['z', 'y', 'x']
Note
This method must be implemented by the subclass.
- property dims: int
- Abstractmethod:
Returns the number of spatial dimensions.
- Returns:
The number of spatial dimensions.
- Return type:
int
- Raises:
NotImplementedError – This method must be implemented by the subclass.
Examples
>>> array = Array() >>> array.dims 3
Note
This method must be implemented by the subclass.
- property voxel_size: funlib.geometry.Coordinate
- Abstractmethod:
The size of a voxel in physical units.
- Returns:
The size of a voxel in physical units.
- Return type:
Coordinate
- Raises:
NotImplementedError – This method must be implemented by the subclass.
Examples
>>> array = Array() >>> array.voxel_size Coordinate((1, 1, 1))
Note
This method must be implemented by the subclass.
- property roi: funlib.geometry.Roi
- Abstractmethod:
The total ROI of this array, in world units.
- Returns:
The total ROI of this array, in world units.
- Return type:
Roi
- Raises:
NotImplementedError – This method must be implemented by the subclass.
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.
- property dtype: Any
- Abstractmethod:
The dtype of this array, in numpy dtypes
- Returns:
The dtype of this array, in numpy dtypes.
- Return type:
Any
- Raises:
NotImplementedError – This method must be implemented by the subclass.
Examples
>>> array = Array() >>> array.dtype np.dtype('uint8')
Note
This method must be implemented by the subclass.
- property num_channels: int | None
- 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.
- Return type:
Optional[int]
- Raises:
NotImplementedError – This method must be implemented by the subclass.
Examples
>>> array = Array() >>> array.num_channels 1
Note
This method must be implemented by the subclass.
- property data: 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.
- Return type:
np.ndarray
- Raises:
NotImplementedError – This method must be implemented by the subclass.
Examples
>>> array = Array() >>> array.data np.ndarray
Note
This method must be implemented by the subclass.
- property writable: bool
- Abstractmethod:
Can we write to this Array?
- Returns:
Can we write to this Array?
- Return type:
bool
- Raises:
NotImplementedError – This method must be implemented by the subclass.
Examples
>>> array = Array() >>> array.writable False
Note
This method must be implemented by the subclass.