bsb.topology package#
Submodules#
bsb.topology.partition module#
Module for the Partition configuration nodes and its dependencies.
- class bsb.topology.partition.AllenStructure(*args, _parent=None, _key=None, **kwargs)[source]#
Bases:
NrrdVoxels
Partition based on the Allen Institute for Brain Science mouse brain region ontology, later referred as Allen Mouse Brain Region Hierarchy (AMBRH)
- get_node_name()#
- classmethod get_structure_idset(find)[source]#
Return the set of IDs that make up the requested Allen structure.
- classmethod get_structure_mask(find)[source]#
Returns the mask data delineated by the Allen structure.
- Parameters:
find (Union[str, int]) – Acronym, Name or ID of the Allen structure.
- Returns:
A boolean of the mask filtered based on the Allen structure.
- Return type:
Callable[numpy.ndarray]
- classmethod get_structure_mask_condition(find)[source]#
Return a lambda that when applied to the mask data, returns a mask that delineates the Allen structure.
- Parameters:
find (Union[str, int]) – Acronym, Name or ID of the Allen structure.
- Returns:
Masking lambda
- Return type:
Callable[numpy.ndarray]
- mask_only#
Flag to indicate no voxel data needs to be stored
- mask_source#
Path to the NRRD file containing the volumetric annotation data of the Partition.
- struct_id#
Id of the region to filter within the annotation volume according to the AMBRH. If struct_id is set, then struct_name should not be set.
- struct_name#
Name or acronym of the region to filter within the annotation volume according to the AMBRH. If struct_name is set, then struct_id should not be set.
- voxel_size#
Size of each voxel.
- class bsb.topology.partition.Layer(*args, _parent=None, _key=None, **kwargs)[source]#
Bases:
Rhomboid
- axis#
Base implementation of all the different configuration attributes. Call the factory function
attr()
instead.
- get_layout(hint)[source]#
Given a Layout as hint to begin from, create a Layout object that describes how this partition would like to be laid out.
- Parameters:
hint (bsb.topology._layout.Layout) – The layout space that this partition should place itself in.
- Returns:
The layout describing the space this partition takes up.
- Return type:
- get_node_name()#
- stack_index#
Base implementation of all the different configuration attributes. Call the factory function
attr()
instead.
- class bsb.topology.partition.NrrdVoxels(*args, _parent=None, _key=None, **kwargs)[source]#
Bases:
Voxels
Voxel partition whose voxelset is loaded from an NRRD file. By default it includes all the nonzero voxels in the file, but other masking conditions can be specified. Additionally, data can be associated to each voxel by inclusion of (multiple) source NRRD files.
- get_mask()[source]#
Get the mask to apply on the sources’ data of the partition.
- Returns:
A tuple of arrays, one for each dimension of the mask, containing the indices of the non-zero elements in that dimension.
- get_node_name()#
- get_voxelset()[source]#
Creates a VoxelSet of the sources of the Partition that matches its mask.
- Returns:
VoxelSet of the Partition sources.
- keys#
List of names to assign to each source of the Partition.
- mask_only#
Flag to indicate no voxel data needs to be stored
- mask_source#
Path to the NRRD file containing the volumetric annotation data of the Partition.
- mask_value#
Integer value to filter in mask_source (if it is set, otherwise sources/source) to create a mask of the voxel set(s) used as input.
- source#
Path to the NRRD file containing volumetric data to associate with the partition. If source is set, then sources should not be set.
- sources#
List of paths to NRRD files containing volumetric data to associate with the Partition. If sources is set, then source should not be set.
- sparse#
Boolean flag to expect a sparse or dense mask. If the mask selects most voxels, use
dense
, otherwise usesparse
.
- strict#
Boolean flag to check the sources and the mask sizes. When the flag is True, sources and mask should have exactly the same sizes; otherwise, sources sizes should be greater than mask sizes.
- voxel_size#
Size of each voxel.
- class bsb.topology.partition.Partition(*args, _parent=None, _key=None, **kwargs)[source]#
Bases:
ABC
- abstract chunk_to_voxels(chunk)[source]#
Voxelize the partition’s occupation in this chunk. Required to fill the partition with cells by the placement module.
- Parameters:
chunk (bsb.storage.Chunk) – The chunk to calculate voxels for.
- Returns:
The set of voxels that together make up the shape of this partition in this chunk.
- Return type:
- property data#
- abstract get_layout(hint)[source]#
Given a Layout as hint to begin from, create a Layout object that describes how this partition would like to be laid out.
- Parameters:
hint (bsb.topology._layout.Layout) – The layout space that this partition should place itself in.
- Returns:
The layout describing the space this partition takes up.
- Return type:
- get_node_name()#
- name#
Base implementation of all the different configuration attributes. Call the factory function
attr()
instead.
- abstract rotate(rotation)[source]#
Rotate the partition by the given rotation object.
- Parameters:
rotation (scipy.spatial.transform.Rotation) – Rotation object.
- Raises:
exceptions.LayoutError
if the rotation needs to be rejected.
- abstract scale(factors)[source]#
Scale up/down the partition according to the given factors.
- Parameters:
factors (numpy.ndarray) – Scaling factors, XYZ.
- Raises:
exceptions.LayoutError
if the scaling needs to be rejected.
- abstract surface(chunk=None)[source]#
Calculate the surface of the partition in μm^2.
- Parameters:
chunk (bsb.storage.Chunk) – If given, limit the surface of the partition inside of the chunk.
- Returns:
Surface of the partition (in the chunk)
- Return type:
- abstract to_chunks(chunk_size)[source]#
Calculate all the chunks this partition occupies when cut into
chunk_sized
pieces.- Parameters:
chunk_size (numpy.ndarray) – Size per chunk (in μm). The slicing always starts at [0, 0, 0].
- Returns:
Chunks occupied by this partition
- Return type:
List[bsb.storage.Chunk]
- abstract translate(offset)[source]#
Translate the partition by the given offset.
- Parameters:
offset (numpy.ndarray) – Offset, XYZ.
- Raises:
exceptions.LayoutError
if the translation needs to be rejected.
- type#
Base implementation of all the different configuration attributes. Call the factory function
attr()
instead.
- abstract volume(chunk=None)[source]#
Calculate the volume of the partition in μm^3.
- Parameters:
chunk (bsb.storage.Chunk) – If given, limit the volume of the partition inside of the chunk.
- Returns:
Volume of the partition (in the chunk)
- Return type:
- class bsb.topology.partition.Rhomboid(*args, _parent=None, _key=None, **kwargs)[source]#
Bases:
Partition
- can_move#
Base implementation of all the different configuration attributes. Call the factory function
attr()
instead.
- can_rotate#
Base implementation of all the different configuration attributes. Call the factory function
attr()
instead.
- can_scale#
Base implementation of all the different configuration attributes. Call the factory function
attr()
instead.
- chunk_to_voxels(chunk)[source]#
Return an approximation of this partition intersected with a chunk as a list of voxels.
Default implementation creates a parallellepepid intersection between the LDC, MDC and chunk data.
- dimensions#
Base implementation of all the different configuration attributes. Call the factory function
attr()
instead.
- get_dependencies()[source]#
Return other partitions or regions that need to be laid out before this.
- get_layout(hint)[source]#
Given a Layout as hint to begin from, create a Layout object that describes how this partition would like to be laid out.
- Parameters:
hint (bsb.topology._layout.Layout) – The layout space that this partition should place itself in.
- Returns:
The layout describing the space this partition takes up.
- Return type:
- get_node_name()#
- property ldc#
- property mdc#
- orientation#
Base implementation of all the different configuration attributes. Call the factory function
attr()
instead.
- origin#
Base implementation of all the different configuration attributes. Call the factory function
attr()
instead.
- rotate(rot)[source]#
Rotate the partition by the given rotation object.
- Parameters:
rotation (scipy.spatial.transform.Rotation) – Rotation object.
- Raises:
exceptions.LayoutError
if the rotation needs to be rejected.
- scale(factors)[source]#
Scale up/down the partition according to the given factors.
- Parameters:
factors (numpy.ndarray) – Scaling factors, XYZ.
- Raises:
exceptions.LayoutError
if the scaling needs to be rejected.
- surface(chunk=None)[source]#
Calculate the surface of the partition in μm^2.
- Parameters:
chunk (bsb.storage.Chunk) – If given, limit the surface of the partition inside of the chunk.
- Returns:
Surface of the partition (in the chunk)
- Return type:
- to_chunks(chunk_size)[source]#
Calculate all the chunks this partition occupies when cut into
chunk_sized
pieces.- Parameters:
chunk_size (numpy.ndarray) – Size per chunk (in μm). The slicing always starts at [0, 0, 0].
- Returns:
Chunks occupied by this partition
- Return type:
List[bsb.storage.Chunk]
- translate(translation)[source]#
Translate the partition by the given offset.
- Parameters:
offset (numpy.ndarray) – Offset, XYZ.
- Raises:
exceptions.LayoutError
if the translation needs to be rejected.
- volume(chunk=None)[source]#
Calculate the volume of the partition in μm^3.
- Parameters:
chunk (bsb.storage.Chunk) – If given, limit the volume of the partition inside of the chunk.
- Returns:
Volume of the partition (in the chunk)
- Return type:
- class bsb.topology.partition.Voxels(*args, _parent=None, _key=None, **kwargs)[source]#
-
Partition based on a set of voxels.
- chunk_to_voxels(chunk)[source]#
Voxelize the partition’s occupation in this chunk. Required to fill the partition with cells by the placement module.
- Parameters:
chunk (bsb.storage.Chunk) – The chunk to calculate voxels for.
- Returns:
The set of voxels that together make up the shape of this partition in this chunk.
- Return type:
- get_layout(hint)[source]#
Given a Layout as hint to begin from, create a Layout object that describes how this partition would like to be laid out.
- Parameters:
hint (bsb.topology._layout.Layout) – The layout space that this partition should place itself in.
- Returns:
The layout describing the space this partition takes up.
- Return type:
- get_node_name()#
- rotate(rotation)[source]#
Rotate the partition by the given rotation object.
- Parameters:
rotation (scipy.spatial.transform.Rotation) – Rotation object.
- Raises:
exceptions.LayoutError
if the rotation needs to be rejected.
- scale(factor)[source]#
Scale up/down the partition according to the given factors.
- Parameters:
factors (numpy.ndarray) – Scaling factors, XYZ.
- Raises:
exceptions.LayoutError
if the scaling needs to be rejected.
- surface(chunk=None)[source]#
Calculate the surface of the partition in μm^2.
- Parameters:
chunk (bsb.storage.Chunk) – If given, limit the surface of the partition inside of the chunk.
- Returns:
Surface of the partition (in the chunk)
- Return type:
- to_chunks(chunk_size)[source]#
Calculate all the chunks this partition occupies when cut into
chunk_sized
pieces.- Parameters:
chunk_size (numpy.ndarray) – Size per chunk (in μm). The slicing always starts at [0, 0, 0].
- Returns:
Chunks occupied by this partition
- Return type:
List[bsb.storage.Chunk]
- translate(offset)[source]#
Translate the partition by the given offset.
- Parameters:
offset (numpy.ndarray) – Offset, XYZ.
- Raises:
exceptions.LayoutError
if the translation needs to be rejected.
- volume(chunk=None)[source]#
Calculate the volume of the partition in μm^3.
- Parameters:
chunk (bsb.storage.Chunk) – If given, limit the volume of the partition inside of the chunk.
- Returns:
Volume of the partition (in the chunk)
- Return type:
- property voxelset#
bsb.topology.region module#
Module for the Region types.
- class bsb.topology.region.Region(*args, _parent=None, _key=None, **kwargs)[source]#
Bases:
ABC
Base region.
When arranging will simply call arrange/layout on its children but won’t cause any changes itself.
- children#
- property data#
- get_node_name()#
- class bsb.topology.region.RegionGroup(*args, _parent=None, _key=None, **kwargs)[source]#
Bases:
Region
- get_node_name()#
- class bsb.topology.region.Stack(*args, _parent=None, _key=None, **kwargs)[source]#
Bases:
RegionGroup
Stack components on top of each other based on their
stack_index
and adjust its own height accordingly.- axis#
Base implementation of all the different configuration attributes. Call the factory function
attr()
instead.
- get_node_name()#
Module contents#
Topology module
- bsb.topology.create_topology(regions, ldc, mdc)[source]#
Create a topology from group of regions. Will check for root regions, if there’s not exactly 1 root region a
RegionGroup
will be created as new root.- Parameters:
regions (Iterable) – Any iterable of regions.
ldc – Least dominant corner of the topology. Forms the suggested outer bounds of the topology together with the mdc.
mdc – Most dominant corner of the topology. Forms the suggested outer bounds of the topology together with the mdc.
- bsb.topology.get_partitions(regions)[source]#
Get all of the partitions belonging to the group of regions and their subregions.
- Parameters:
regions (Iterable) – Any iterable of regions.