neurots.generate.orientations

Module for handling the calculation of neurite orientations.

Functions

compute_interval_n_tree(soma, n_trees[, rng])

Compute the number of trunks to add between each pair of consecutive existing trunks.

orientations_to_sphere_points(oris, ...)

Compute points on a sphere from the given directions.

points_to_orientations(origin, points)

Returns the unit vector that corresponds to the orientation of a point on the soma surface.

spherical_angles_to_orientations(phis, thetas)

Compute orientation from spherical angles.

trunk_absolute_orientation_to_spherical_angles(...)

Generate spherical angles from a unit vector and a list of angles.

trunk_to_spherical_angles(trunk_angles, z_angles)

Generate spherical angles from a list of NeuroM angles.

Classes

OrientationManager(soma, parameters, ...)

Class to generate the tree orientations starting from the soma of the cell.

OrientationManagerBase(soma, parameters, ...)

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

tuple[numpy.ndarray[float], numpy.ndarray[int]]

neurots.generate.orientations.orientations_to_sphere_points(oris, sphere_center, sphere_radius)

Compute points on a sphere from the given directions.

Parameters
Returns

Points on the surface of the sphere corresponding to the given orientations.

Return type

numpy.ndarray

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
Returns

Normalized orientations from origin to points.

Return type

numpy.ndarray

neurots.generate.orientations.spherical_angles_to_orientations(phis, thetas)

Compute orientation from spherical angles.

Parameters
Returns

The orientation vectors where each row correspnds to a phi-theta pair.

Return type

numpy.ndarray

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
  • orientation (list[float]) – The orientation vector.

  • trunk_absolute_angles (list[float]) – The polar angles (phi in spherical coordinates).

  • z_angles (list[float]) – The azimuthal angles (theta in spherical coordinates).

Returns

The phi and theta angles.

Return type

tuple[numpy.ndarray[float], numpy.ndarray[float]]

neurots.generate.orientations.trunk_to_spherical_angles(trunk_angles, z_angles, phi_interval=None)

Generate spherical angles from a list of NeuroM angles.

Parameters
  • trunk_angles (list[float]) – The polar angles (phi in spherical coordinates).

  • z_angles (list[float]) – The azimuthal angles (theta in spherical coordinates).

  • phi_interval (tuple[float, float]) – The interval in which the trunks should be added.

Returns

The phi and theta angles.

Return type

tuple[numpy.ndarray[float], numpy.ndarray[float]]