neurots.generate.orientations¶
Module for handling the calculation of neurite orientations.
Functions
|
Compute the number of trunks to add between each pair of consecutive existing trunks. |
|
Compute points on a sphere from the given directions. |
|
Returns the unit vector that corresponds to the orientation of a point on the soma surface. |
|
Compute orientation from spherical angles. |
Generate spherical angles from a unit vector and a list of angles. |
|
|
Generate spherical angles from a list of NeuroM angles. |
Classes
|
Class to generate the tree orientations starting from the soma of the cell. |
|
Base class that automatically registers orientation modes. |
- class neurots.generate.orientations.OrientationManager(soma, parameters, distributions, context, rng)¶
Bases:
neurots.generate.orientations.OrientationManagerBase
Class to generate the tree orientations starting from the soma of the cell.
- Parameters
soma (Soma) – The soma on which the trees should be attached.
parameters (dict) – The parameters used to compute the orientations.
distributions (dict) – The distributions used to compute the orientations.
context (any) – An object containing contextual information.
rng (numpy.random.Generator) – The random number generator to use.
Note
All orientation mode dicts:
{ "mode": "use_predefined", "values": {"orientations": [or1, or2, ...]} } { "mode": "sample_pairwise_angles", "values": {} } { "mode": "sample_around_primary_orientation", "values": {"primary_orientation": [0, 1, 0]} }
- class neurots.generate.orientations.OrientationManagerBase(soma, parameters, distributions, context, rng)¶
Bases:
object
Base class that automatically registers orientation modes.
- Parameters
soma (Soma) – The soma on which the trees should be attached.
parameters (dict) – The parameters used to compute the orientations.
distributions (dict) – The distributions used to compute the orientations.
context (any) – An object containing contextual information.
rng (numpy.random.Generator) – The random number generator to use.
Note
To register an orientation mode, derive from this base class and create a method with the following signature:
def _mode_{name}(self, values_dict, tree_type)
- compute_tree_type_orientations(tree_type)¶
Computes the orientations for all tree types. It updates the _orientations dictionary.
Notes
Updating a data structure that is accessible by all orientation methods, allows to take into account existing orientations for calculating new ones.
- get_tree_type_orientations(tree_type)¶
Returns the orientations for the specific tree type.
- property mode_names¶
Returns the names of the available modes.
- neurots.generate.orientations.compute_interval_n_tree(soma, n_trees, rng=numpy.random)¶
Compute the number of trunks to add between each pair of consecutive existing trunks.
If points already exist in the soma, the algorithm is the following:
build the intervals between each pair of consecutive points.
compute the size of each interval.
randomly select the interval in which each new point will be added (the intervals are weighted by their sizes to ensure the new trunks are created isotropically).
count the number of new points in each interval.
return the intervals in which at least one point must be added.
If no point exists in the soma, the interval [0, 2pi] contains all the new trunks.
- Parameters
soma (Soma) – The soma on which the trunks should be added.
n_trees (int) – The number of trees that should be added.
rng (numpy.random.Generator) – The random number generator to use.
- Returns
The phi intervals and the number of trees in each of them.
- Return type
- neurots.generate.orientations.orientations_to_sphere_points(oris, sphere_center, sphere_radius)¶
Compute points on a sphere from the given directions.
- Parameters
oris (numpy.ndarray) – Normalized orientation vectors.
sphere_center (numpy.ndarray) – Center of sphere.
sphere_radius (float) – Radius of sphere.
- Returns
Points on the surface of the sphere corresponding to the given orientations.
- Return type
- neurots.generate.orientations.points_to_orientations(origin, points)¶
Returns the unit vector that corresponds to the orientation of a point on the soma surface.
- Parameters
origin (numpy.ndarray) – The origin of the vectors.
points (numpy.ndarray) – Points to calculate the vectors to.
- Returns
Normalized orientations from origin to points.
- Return type
- neurots.generate.orientations.spherical_angles_to_orientations(phis, thetas)¶
Compute orientation from spherical angles.
- Parameters
phis (numpy.ndarray) – Polar angles.
thetas (numpy.ndarray) – Azimuthal angles.
- Returns
The orientation vectors where each row correspnds to a phi-theta pair.
- Return type
- neurots.generate.orientations.trunk_absolute_orientation_to_spherical_angles(orientation, trunk_absolute_angles, z_angles)¶
Generate spherical angles from a unit vector and a list of angles.
- Parameters
- Returns
The phi and theta angles.
- Return type
- neurots.generate.orientations.trunk_to_spherical_angles(trunk_angles, z_angles, phi_interval=None)¶
Generate spherical angles from a list of NeuroM angles.
- Parameters
- Returns
The phi and theta angles.
- Return type