bsb.connectivity.geometric package¶
Submodules¶
bsb.connectivity.geometric.geometric_shapes module¶
- class bsb.connectivity.geometric.geometric_shapes.Cone(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
GeometricShapeA cone, described in cartesian coordinates.
- apex¶
The coordinates of the apex of the cone.
- check_inside(points: ndarray[float])[source]¶
Check if the points given in input are inside the geometric shape.
- Parameters:
points (numpy.ndarray) – A cloud of points.
- Returns:
A bool array with same length as points, containing whether the -ith point is inside the geometric shape or not.
- Return type:
- generate_point_cloud(npoints: int)[source]¶
Generate a point cloud made by npoints points.
- Parameters:
npoints (int) – The number of points to generate.
- Returns:
a (npoints x 3) numpy array.
- Return type:
- get_node_name()¶
- get_volume()[source]¶
Get the volume of the geometric shape.
- Returns:
The volume of the geometric shape.
- Return type:
- origin¶
The coordinates of the center of the cone’s base.
- radius¶
The radius of the base circle.
- rotate(r_versor: ndarray[float], angle: float)[source]¶
Rotate all the shapes around r_versor, which is a versor passing through the origin, by the specified angle.
- Parameters:
r_versor (numpy.ndarray[float]) – A versor specifying the rotation axis.
angle (float) – the rotation angle, in radians.
- translate(t_vector)[source]¶
Translate the geometric shape by the vector t_vector.
- Parameters:
t_vector (numpy.ndarray) – The displacement vector
- wireframe_points(nb_points_1=30, nb_points_2=30)[source]¶
Generate a wireframe to plot the geometric shape. If a sampling of points is needed (e.g. for sphere), the wireframe is based on a grid of shape (nb_points_1, nb_points_2).
- Parameters:
- Returns:
Coordinate components of the wireframe
- Return type:
- class bsb.connectivity.geometric.geometric_shapes.Cuboid(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
GeometricShapeA rectangular parallelepiped, described in cartesian coordinates.
- check_inside(points: ndarray[float])[source]¶
Check if the points given in input are inside the geometric shape.
- Parameters:
points (numpy.ndarray) – A cloud of points.
- Returns:
A bool array with same length as points, containing whether the -ith point is inside the geometric shape or not.
- Return type:
- generate_point_cloud(npoints: int)[source]¶
Generate a point cloud made by npoints points.
- Parameters:
npoints (int) – The number of points to generate.
- Returns:
a (npoints x 3) numpy array.
- Return type:
- get_node_name()¶
- get_volume()[source]¶
Get the volume of the geometric shape.
- Returns:
The volume of the geometric shape.
- Return type:
- origin¶
The coordinates of the center of the barycenter of the bottom rectangle.
- rotate(r_versor: ndarray[float], angle: float)[source]¶
Rotate all the shapes around r_versor, which is a versor passing through the origin, by the specified angle.
- Parameters:
r_versor (numpy.ndarray[float]) – A versor specifying the rotation axis.
angle (float) – the rotation angle, in radians.
- side_length_1¶
Length of one side of the base rectangle.
- side_length_2¶
Length of the other side of the base rectangle.
- top_center¶
The coordinates of the center of the barycenter of the top rectangle.
- translate(t_vector: ndarray[float])[source]¶
Translate the geometric shape by the vector t_vector.
- Parameters:
t_vector (numpy.ndarray) – The displacement vector
- class bsb.connectivity.geometric.geometric_shapes.Cylinder(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
GeometricShapeA cylinder, described in cartesian coordinates.
- check_inside(points: ndarray[float])[source]¶
Check if the points given in input are inside the geometric shape.
- Parameters:
points (numpy.ndarray) – A cloud of points.
- Returns:
A bool array with same length as points, containing whether the -ith point is inside the geometric shape or not.
- Return type:
- generate_point_cloud(npoints: int)[source]¶
Generate a point cloud made by npoints points.
- Parameters:
npoints (int) – The number of points to generate.
- Returns:
a (npoints x 3) numpy array.
- Return type:
- get_node_name()¶
- get_volume()[source]¶
Get the volume of the geometric shape.
- Returns:
The volume of the geometric shape.
- Return type:
- origin¶
The coordinates of the center of the bottom circle of the cylinder.
- radius¶
The radius of the base circle.
- rotate(r_versor: ndarray[float], angle: float)[source]¶
Rotate all the shapes around r_versor, which is a versor passing through the origin, by the specified angle.
- Parameters:
r_versor (numpy.ndarray[float]) – A versor specifying the rotation axis.
angle (float) – the rotation angle, in radians.
- top_center¶
The coordinates of the center of the top circle of the cylinder.
- translate(t_vector: ndarray[float])[source]¶
Translate the geometric shape by the vector t_vector.
- Parameters:
t_vector (numpy.ndarray) – The displacement vector
- wireframe_points(nb_points_1=30, nb_points_2=30)[source]¶
Generate a wireframe to plot the geometric shape. If a sampling of points is needed (e.g. for sphere), the wireframe is based on a grid of shape (nb_points_1, nb_points_2).
- Parameters:
- Returns:
Coordinate components of the wireframe
- Return type:
- class bsb.connectivity.geometric.geometric_shapes.Ellipsoid(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
GeometricShapeAn ellipsoid, described in cartesian coordinates.
- check_inside(points: ndarray[float])[source]¶
Check if the points given in input are inside the geometric shape.
- Parameters:
points (numpy.ndarray) – A cloud of points.
- Returns:
A bool array with same length as points, containing whether the -ith point is inside the geometric shape or not.
- Return type:
- generate_point_cloud(npoints: int)[source]¶
Generate a point cloud made by npoints points.
- Parameters:
npoints (int) – The number of points to generate.
- Returns:
a (npoints x 3) numpy array.
- Return type:
- get_node_name()¶
- get_volume()[source]¶
Get the volume of the geometric shape.
- Returns:
The volume of the geometric shape.
- Return type:
- lambdas¶
The length of the three semi-axes.
- origin¶
The coordinates of the center of the ellipsoid.
- rotate(r_versor: ndarray[float], angle: float)[source]¶
Rotate all the shapes around r_versor, which is a versor passing through the origin, by the specified angle.
- Parameters:
r_versor (numpy.ndarray[float]) – A versor specifying the rotation axis.
angle (float) – the rotation angle, in radians.
- surface_point(theta, phi)[source]¶
Convert polar coordinates into their 3D location on the ellipsoid surface.
- Parameters:
theta (float|numpy.ndarray[float]) – first polar coordinate in [0; 2*np.pi]
phi (float|numpy.ndarray[float]) – second polar coordinate in [0; np.pi]
- Returns:
surface coordinates
- Return type:
- translate(t_vector: ndarray)[source]¶
Translate the geometric shape by the vector t_vector.
- Parameters:
t_vector (numpy.ndarray) – The displacement vector
- v0¶
- v1¶
- v2¶
- wireframe_points(nb_points_1=30, nb_points_2=30)[source]¶
Generate a wireframe to plot the geometric shape. If a sampling of points is needed (e.g. for sphere), the wireframe is based on a grid of shape (nb_points_1, nb_points_2).
- Parameters:
- Returns:
Coordinate components of the wireframe
- Return type:
- class bsb.connectivity.geometric.geometric_shapes.GeometricShape(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
ABCBase class for geometric shapes.
- abstractmethod check_inside(points: ndarray[float]) ndarray[bool][source]¶
Check if the points given in input are inside the geometric shape.
- Parameters:
points (numpy.ndarray) – A cloud of points.
- Returns:
A bool array with same length as points, containing whether the -ith point is inside the geometric shape or not.
- Return type:
- check_mbox(points: ndarray[float])[source]¶
Check if the points given in input are inside the minimal bounding box.
- Parameters:
points (numpy.ndarray) – A cloud of points.
- Returns:
A bool np.ndarray specifying whether each point of the input array is inside the minimal bounding box or not.
- Return type:
- epsilon¶
Tolerance value to compare coordinates.
- abstractmethod generate_point_cloud(npoints: int)[source]¶
Generate a point cloud made by npoints points.
- Parameters:
npoints (int) – The number of points to generate.
- Returns:
a (npoints x 3) numpy array.
- Return type:
- get_node_name()¶
- abstractmethod get_volume()[source]¶
Get the volume of the geometric shape.
- Returns:
The volume of the geometric shape.
- Return type:
- abstractmethod rotate(r_versor: ndarray[float], angle: float)[source]¶
Rotate all the shapes around r_versor, which is a versor passing through the origin, by the specified angle.
- Parameters:
r_versor (numpy.ndarray[float]) – A versor specifying the rotation axis.
angle (float) – the rotation angle, in radians.
- abstractmethod translate(t_vector: ndarray[float])[source]¶
Translate the geometric shape by the vector t_vector.
- Parameters:
t_vector (numpy.ndarray) – The displacement vector
- type¶
Base implementation of all the different configuration attributes.
Call the factory function
attr()instead.
- abstractmethod wireframe_points(nb_points_1=30, nb_points_2=30)[source]¶
Generate a wireframe to plot the geometric shape. If a sampling of points is needed (e.g. for sphere), the wireframe is based on a grid of shape (nb_points_1, nb_points_2).
- Parameters:
- Returns:
Coordinate components of the wireframe
- Return type:
- class bsb.connectivity.geometric.geometric_shapes.Parallelepiped(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
GeometricShapeA generic parallelepiped, described by the vectors (following the right-hand orientation) of the sides in cartesian coordinates.
- check_inside(points: ndarray[float])[source]¶
Check if the points given in input are inside the geometric shape.
- Parameters:
points (numpy.ndarray) – A cloud of points.
- Returns:
A bool array with same length as points, containing whether the -ith point is inside the geometric shape or not.
- Return type:
- generate_point_cloud(npoints: int)[source]¶
Generate a point cloud made by npoints points.
- Parameters:
npoints (int) – The number of points to generate.
- Returns:
a (npoints x 3) numpy array.
- Return type:
- get_node_name()¶
- get_volume()[source]¶
Get the volume of the geometric shape.
- Returns:
The volume of the geometric shape.
- Return type:
- origin¶
The coordinates of the left-bottom edge.
- rotate(r_versor: ndarray[float], angle: float)[source]¶
Rotate all the shapes around r_versor, which is a versor passing through the origin, by the specified angle.
- Parameters:
r_versor (numpy.ndarray[float]) – A versor specifying the rotation axis.
angle (float) – the rotation angle, in radians.
- side_vector_1¶
The first vector identifying the parallelepiped (using the right-hand orientation: the thumb).
- side_vector_2¶
The second vector identifying the parallelepiped (using the right-hand orientation: the index).
- side_vector_3¶
The third vector identifying the parallelepiped (using the right-hand orientation: the middle finger).
- translate(t_vector: ndarray[float])[source]¶
Translate the geometric shape by the vector t_vector.
- Parameters:
t_vector (numpy.ndarray) – The displacement vector
- class bsb.connectivity.geometric.geometric_shapes.ShapesComposition(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
objectA collection of geometric shapes, which can be labelled to distinguish different parts of a neuron.
- add_shape(shape: GeometricShape, labels: list[str])[source]¶
Add a geometric shape to the collection.
- Parameters:
shape (GeometricShape) – A GeometricShape to add to the collection.
labels (list[str]) – A list of labels for the geometric shape to add.
- compute_n_points() list[int][source]¶
Compute the number of points to generate in a point cloud, using the dimension of the voxel specified in self._voxel_size.
- Returns:
The number of points to generate.
- Return type:
- filter_by_labels(labels: list[str]) ShapesComposition[source]¶
Filter the collection of shapes, returning only the ones corresponding to the given labels.
- Parameters:
- Returns:
A new ShapesComposition object containing only the shapes labelled as specified.
- Return type:
- find_mbb() tuple[ndarray[float], ndarray[float]][source]¶
Compute the minimal bounding box containing the collection of shapes.
- Returns:
The two corners individuating the minimal bounding box of the shapes collection.
- Return type:
- generate_point_cloud() ndarray[float] | None[source]¶
Generate a point cloud. The number of points to generate is determined automatically using the voxel size.
- Returns:
A numpy.ndarray containing the 3D points of the cloud. If there are no shapes in the collection, it returns None.
- Return type:
numpy.ndarray[float] | None
- generate_wireframe(nb_points_1=30, nb_points_2=30) tuple[list, list, list] | None[source]¶
Generate the wireframes of a collection of shapes. If a sampling of points is needed for certain shapes (e.g. for sphere), their wireframe is based on a grid of shape (nb_points_1, nb_points_2).
- Parameters:
- Returns:
The x,y,z coordinates of the wireframe of each shape.
- Return type:
tuple[list[numpy.ndarray[numpy.ndarray[float]]]] | None
- get_mbb_max()[source]¶
Returns the top corner of the minimum bounding box containing the collection of shapes.
- Returns:
The top corner individuating the minimal bounding box of the shapes collection.
- Return type:
- get_mbb_min()[source]¶
Returns the bottom corner of the minimum bounding box containing the collection of shapes.
- Returns:
The bottom corner individuating the minimal bounding box of the shapes collection.
- Return type:
- get_node_name()¶
- inside_mbox(points: ndarray[float]) ndarray[bool][source]¶
Check if the points given in input are inside the minimal bounding box of the collection.
- Parameters:
points (numpy.ndarray) – An array of 3D points.
- Returns:
A bool np.ndarray specifying whether each point of the input array is inside the minimal bounding box of the collection.
- Return type:
- inside_shapes(points: ndarray[float]) ndarray[bool] | None[source]¶
Check if the points given in input are inside at least in one of the shapes of the collection.
- Parameters:
points (numpy.ndarray) – An array of 3D points.
- Returns:
A bool numpy.ndarray specifying whether each point of the input array is inside the collection of shapes or not.
- Return type:
- labels¶
List of lists of labels associated to each geometric shape.
- shapes¶
List of GeometricShape that make up the neuron.
- translate(t_vec: ndarray[float])[source]¶
Translate all the shapes in the collection by the vector t_vec. It also automatically translate the minimal bounding box.
- Parameters:
t_vec (numpy.ndarray) – The displacement vector.
- voxel_size¶
Dimension of the side of a voxel, used to determine how many points must be generated to represent the geometric shape.
- class bsb.connectivity.geometric.geometric_shapes.Sphere(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
GeometricShapeA sphere, described in cartesian coordinates.
- check_inside(points: ndarray[float])[source]¶
Check if the points given in input are inside the geometric shape.
- Parameters:
points (numpy.ndarray) – A cloud of points.
- Returns:
A bool array with same length as points, containing whether the -ith point is inside the geometric shape or not.
- Return type:
- generate_point_cloud(npoints: int)[source]¶
Generate a point cloud made by npoints points.
- Parameters:
npoints (int) – The number of points to generate.
- Returns:
a (npoints x 3) numpy array.
- Return type:
- get_node_name()¶
- get_volume()[source]¶
Get the volume of the geometric shape.
- Returns:
The volume of the geometric shape.
- Return type:
- origin¶
The coordinates of the center of the sphere.
- radius¶
The radius of the sphere.
- rotate(r_versor: ndarray[float], angle: float)[source]¶
Rotate all the shapes around r_versor, which is a versor passing through the origin, by the specified angle.
- Parameters:
r_versor (numpy.ndarray[float]) – A versor specifying the rotation axis.
angle (float) – the rotation angle, in radians.
- surface_function(theta, phi)[source]¶
Convert polar coordinates into their 3D location on the sphere surface.
- Parameters:
theta (float|numpy.ndarray[float]) – first polar coordinate in [0; 2*np.pi]
phi (float|numpy.ndarray[float]) – second polar coordinate in [0; np.pi]
- Returns:
surface coordinates
- Return type:
- translate(t_vector: ndarray[float])[source]¶
Translate the geometric shape by the vector t_vector.
- Parameters:
t_vector (numpy.ndarray) – The displacement vector
- wireframe_points(nb_points_1=30, nb_points_2=30)[source]¶
Generate a wireframe to plot the geometric shape. If a sampling of points is needed (e.g. for sphere), the wireframe is based on a grid of shape (nb_points_1, nb_points_2).
- Parameters:
- Returns:
Coordinate components of the wireframe
- Return type:
- bsb.connectivity.geometric.geometric_shapes.inside_mbox(points: ndarray[float], mbb_min: ndarray[float], mbb_max: ndarray[float])[source]¶
Check if the points given in input are inside the minimal bounding box.
- Parameters:
points (numpy.ndarray) – An array of 3D points.
mbb_min (numpy.ndarray) – 3D point representing the lowest coordinate of the minimal bounding box.
mbb_max (numpy.ndarray) – 3D point representing the highest coordinate of the minimal bounding box.
- Returns:
A bool np.ndarray specifying whether each point of the input array is inside the minimal bounding box or not.
- Return type:
bsb.connectivity.geometric.morphology_shape_intersection¶
- class bsb.connectivity.geometric.morphology_shape_intersection.MorphologyToShapeIntersection(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
ConnectionStrategy- affinity¶
Ratio of apositions to keep over the total number of contact points.
- connect(pre, post)[source]¶
Central method of each connection strategy. Given a pair of
HemitypeCollection(one for each connection side), should connect cell population using the scaffold’s (available asself.scaffold)bsb.core.Scaffold.connect_cells()method.- Parameters:
presyn_collection (bsb.connectivity.strategy.HemitypeCollection) – presynaptic filtered cell population.
postsyn_collection (bsb.connectivity.strategy.HemitypeCollection) – postsynaptic filtered cell population.
- get_node_name()¶
- get_region_of_interest(chunk)[source]¶
Returns the list of chunks containing the potential postsynaptic neurons, based on a chunk containing the presynaptic neurons.
- Parameters:
chunk (bsb.storage._chunks.Chunk) – Presynaptic chunk
- Returns:
List of postsynaptic chunks
- Return type:
- pruning_ratio¶
Ratio of conections to keep over the total number of apositions.
bsb.connectivity.geometric.shape_morphology_intersection¶
- class bsb.connectivity.geometric.shape_morphology_intersection.ShapeToMorphologyIntersection(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
ConnectionStrategy- affinity¶
Ratio of apositions to keep over the total number of contact points.
- connect(pre, post)[source]¶
Central method of each connection strategy. Given a pair of
HemitypeCollection(one for each connection side), should connect cell population using the scaffold’s (available asself.scaffold)bsb.core.Scaffold.connect_cells()method.- Parameters:
presyn_collection (bsb.connectivity.strategy.HemitypeCollection) – presynaptic filtered cell population.
postsyn_collection (bsb.connectivity.strategy.HemitypeCollection) – postsynaptic filtered cell population.
- get_node_name()¶
- get_region_of_interest(chunk)[source]¶
Returns the list of chunks containing the potential postsynaptic neurons, based on a chunk containing the presynaptic neurons.
- Parameters:
chunk (bsb.storage._chunks.Chunk) – Presynaptic chunk
- Returns:
List of postsynaptic chunks
- Return type:
- pruning_ratio¶
Ratio of conections to keep over the total number of apositions.
bsb.connectivity.geometric.shape_shape_intersection¶
- class bsb.connectivity.geometric.shape_shape_intersection.ShapeHemitype(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
HemitypeClass representing a population of cells to connect with a ConnectionStrategy.
These cells’ morphology is implemented as a ShapesComposition.
- get_mbb(chunks, chunk_dimension)[source]¶
Get the list of minimal bounding box containing all cells in the ShapeHemitype.
- Parameters:
chunks (list[bsb.storage._chunks.Chunk]) – List of chunks containing the cell types (see bsb.connectivity.strategy.Hemitype.get_all_chunks)
chunk_dimension (float) – Size of a chunk
- Returns:
List of bounding boxes in the form [min_x, min_y, min_z, max_x, max_y, max_z] for each chunk containing cells.
- Return type:
list[numpy.ndarray[float, float, float, float, float, float]]
- get_node_name()¶
- shapes_composition¶
Composite shape representing the Hemitype.
- class bsb.connectivity.geometric.shape_shape_intersection.ShapeToShapeIntersection(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
ConnectionStrategy- affinity¶
Ratio of apositions to keep over the total number of contact points.
- connect(pre, post)[source]¶
Central method of each connection strategy. Given a pair of
HemitypeCollection(one for each connection side), should connect cell population using the scaffold’s (available asself.scaffold)bsb.core.Scaffold.connect_cells()method.- Parameters:
presyn_collection (bsb.connectivity.strategy.HemitypeCollection) – presynaptic filtered cell population.
postsyn_collection (bsb.connectivity.strategy.HemitypeCollection) – postsynaptic filtered cell population.
- get_node_name()¶
- get_region_of_interest(chunk)[source]¶
Returns the list of chunks containing the potential postsynaptic neurons, based on a chunk containing the presynaptic neurons.
- Parameters:
chunk (bsb.storage._chunks.Chunk) – Presynaptic chunk
- Returns:
List of postsynaptic chunks
- Return type:
- pruning_ratio¶
Ratio of conections to keep over the total number of apositions.