dacapo.experiments.datasplits.datasets.arrays.concat_array
Attributes
Classes
This is a wrapper around other source_arrays that concatenates |
Module Contents
- dacapo.experiments.datasplits.datasets.arrays.concat_array.logger
- class dacapo.experiments.datasplits.datasets.arrays.concat_array.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.
- name
The name of the array.
- channels
The list of channel names.
- source_arrays
A dictionary mapping channel names to source arrays.
- default_array
An optional default array to use for channels that are not present in source_arrays.
- from_toml(cls, toml_path
str) -> ConcatArrayConfig: Load the ConcatArrayConfig from a TOML file
- to_toml(self, toml_path
str) -> None: Save the ConcatArrayConfig to a TOML file
- 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.
- name
- channels
- property source_arrays: Dict[str, dacapo.experiments.datasplits.datasets.arrays.array.Array]
Return the source arrays of the ConcatArray.
- Returns:
The source arrays of the ConcatArray.
- Return type:
Dict[str, Array]
- Raises:
AssertionError – If the source arrays are empty.
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.
- default_array
- property attrs
- Return the attributes of the ConcatArray as a dictionary.
- Returns:
The attributes of the ConcatArray.
- Return type:
Dict[str, Any]
- Raises:
AssertionError – If the source arrays have different attributes.
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.
- property source_array: dacapo.experiments.datasplits.datasets.arrays.array.Array
Return the source array of the ConcatArray.
- Returns:
The source array of the ConcatArray.
- Return type:
- Raises:
AssertionError – If the source array is None.
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.
- property axes
- Return the axes of the ConcatArray.
- Returns:
The axes of the ConcatArray.
- Return type:
str
- Raises:
AssertionError – If the source arrays have different axes.
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.
- property dims
- Return the dimensions of the ConcatArray.
- Returns:
The dimensions of the ConcatArray.
- Return type:
Tuple[int]
- Raises:
AssertionError – If the source arrays have different dimensions.
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.
- property voxel_size
- Return the voxel size of the ConcatArray.
- Returns:
The voxel size of the ConcatArray.
- Return type:
Tuple[float]
- Raises:
AssertionError – If the source arrays have different voxel sizes.
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.
- property roi
- Return the ROI of the ConcatArray.
- Returns:
The ROI of the ConcatArray.
- Return type:
Roi
- Raises:
AssertionError – If the source arrays have different ROIs.
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.
- property writable: bool
Return whether the ConcatArray is writable.
- Returns:
Whether the ConcatArray is writable.
- Return type:
bool
- Raises:
AssertionError – If the ConcatArray is writable.
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.
- property data
- Return the data of the ConcatArray.
- Returns:
The data of the ConcatArray.
- Return type:
np.ndarray
- Raises:
RuntimeError – If the ConcatArray is not writable.
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.
- property dtype
- Return the data type of the ConcatArray.
- Returns:
The data type of the ConcatArray.
- Return type:
np.dtype
- Raises:
AssertionError – If the source arrays have different data types.
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.
- property num_channels
- Return the number of channels of the ConcatArray.
- Returns:
The number of channels of the ConcatArray.
- Return type:
int
- Raises:
AssertionError – If the source arrays have different numbers of channels.
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.