neurots.astrocyte.space_colonization

Basic class for TreeGrower Algorithms for space colonization.

Classes

SpaceColonization(input_data, params, ...[, ...])

Algorithm for growing a tree using a variation of the space colonization algorithm.

SpaceColonizationTarget(input_data, params, ...)

A target is specified for this algorithm.

class neurots.astrocyte.space_colonization.SpaceColonization(input_data, params, start_point, context=None, random_generator=numpy.random, **_)

Bases: TMDAlgo

Algorithm for growing a tree using a variation of the space colonization algorithm.

A spatial colonization context is required, which will provide access to the seed point cloud for the respective queries needed for the splitting strategies.

The neurots space colonization algorithm operates using the following data:

  • SpaceColonizationContext
    • Seeds point cloud

    • Space colonization parameters (kill and influence distance)

bifurcate(current_section)

When the section bifurcates two new sections need to be created.

This method computes from the current state the data required for the generation of two new sections and returns the corresponding dictionaries.

select_persistence(input_data, random_generator=numpy.random)

Select the persistence.

The persistaece is randomly selected from the barcodes the max radial of which is greater or equal to the distance from the soma to the domain face.

Parameters:
  • input_data (dict) – The input data parameters.

  • random_generator (numpy.random.Generator) – The random number generator to use.

Returns:

The topology barcode.

Return type:

Barcode

class neurots.astrocyte.space_colonization.SpaceColonizationTarget(input_data, params, start_point, context=None, random_generator=numpy.random, **_)

Bases: SpaceColonization

A target is specified for this algorithm.

The tree grows biased from the target and when it reaches it, it stops being influenced by the point.

bifurcate(current_section)

When the section bifurcates two new sections need to be created.

This method computes from the current state the data required for the generation of two new sections and returns the corresponding dictionaries.

get_stop_criteria(current_section)

Get stop criteria.

Use the stop criteria of the parent class with the additional information of the target_id that is assigned to the tree and the max_target_distance for calculating the magnitude of the attraction field generated by the target.

initialize()

TMD basic grower of an apical tree based on path distance.

Initializes the tree grower and computes the apical distance using the input barcode.

select_persistence(input_data, random_generator=numpy.random)

Select the persistence.

The persistaece is randomly selected from the barcodes the max radial of which is greater or equal to the distance from the soma to the target.

Parameters:
  • input_data (dict) – The input data parameters.

  • random_generator (numpy.random.Generator) – The random number generator to use.

Returns:

The topology barcode.

Return type:

Barcode

neurots.astrocyte.space_colonization._add_attraction_bias(current_point, target_point, max_target_distance, direction, attraction_function)

Adds a bias to the direction whose magnitude depends on the attraction function.

The attraction function takes as an input the ratio of the distance of the current point to the target over the total distance of the target from the soma.

Parameters:
  • current_point (numpy.ndarray) – The reference point.

  • target_point (numpy.ndarray) – The attractor point.

  • max_target_distance (float) – The distance from soma center to attraction point.

  • direction (numpy.ndarray) – Section direction.

  • attraction_function (Callable[float] -> float) – Attraction strength function handle.

Returns:

The new direction.

Return type:

numpy.ndarray

neurots.astrocyte.space_colonization._colonization_split(section, angles, parameters, context)

Creates a bifurcation using the space colonization algorithm.

Parameters:
Returns:

A tuple containing the following values:

  • first direction

  • first section type

  • second direction

  • second section type

Return type:

tuple[numpy.ndarray, str, numpy.ndarray, str]

Note

A repulsion contribution is calculated first from the morphology points that are around the bifurcation point. If there are no points available the repulsion will be zero.

If the section grower is a major type:

A partial ball query is performed to find all the point cloud seeds that are around the bifurcation point. The primary colonization strategy is then used where the first direction is the same as the direction of the section plus the repulsion and the second one is chosen so that it maximized the angle with the first direction.

if the section grower is not a major type:

A half bal query is perfmored along the direction of the section to find the point cloud seeds around the bifurcation point. The secondary colonization strategy is then used where the first direction is chosen by the closest seed to the bifurcation point and the second one from the direction that maximizes the direction to the first one.

In both cases if not enough seeds are found the strategy will fall back to a directional splitting sampling from the bio angles. It will also fallback if the two new directions are identical. It’s a rare case but it can happen given overlapping point cloud seeds.

neurots.astrocyte.space_colonization._colonization_split_with_target_influence(section, angles, parameters, context)

Creates a bifurcation using the space colonization algorithm.

Parameters:
Returns:

A tuple containing the following values:

  • first direction

  • first section type

  • second direction

  • second section type

Return type:

tuple[numpy.ndarray, str, numpy.ndarray, str]

Note

Bifurcation directions are calculated based on the space colonization split. If the endfoot target is active and is close to the bifurcation point, then the the second section type will become an endfoot and the target will be exclusive to it, rendering it not active. The second direction will be overridden with the direction to the target.

If the target is not in proximity and the section has a major type, an attraction bias is added towards the target that depends on the strength of the attraction field. If it isn’t a major type, it can become major via the majorization function. In order to be majorized the bar must be a long one, i.e. longer than 80% of the distance from the tree start to the soma.

neurots.astrocyte.space_colonization._colonization_strategy_primary(previous_direction, vectors_to_seeds, repulsion)

Compute directions with primary strategy.

Note

dir1 is calculated by the mean direction from the vectors_to_seeds.

dir2 is determined by the direction that maximized its angle to dir1.

Both dir1 and dir2 and dir2 are affected by repulsion.

Parameters:
  • previous_direction (numpy.ndarray) – The previous section direction.

  • vectors_to_seeds (numpy.ndarray) – Vectors from current point to seeds.

  • repulsion (numpy.ndarray) – Absolute repulsion contribution.

Returns:

first and second split directions.

Return type:

tuple[numpy.ndarray, numpy.ndarray]

neurots.astrocyte.space_colonization._colonization_strategy_secondary(vectors_to_seeds, repulsion)

Compute directions with secondary strategy.

Note

dir1 is calculated by the mean direction from the vectors_to_seeds.

dir2 is determined by the direction that maximized its angle to dir1.

Both dir1 and dir2 and dir2 are affected by repulsion.

Parameters:
  • vectors_to_seeds (numpy.ndarray) – Vectors from current point to seeds.

  • repulsion (numpy.ndarray) – Absolute repulsion contribution.

Returns:

The first and second split directions.

Return type:

tuple[numpy.ndarray, numpy.ndarray]

neurots.astrocyte.space_colonization._fallback_strategy(section_direction, angles, repulsion)

Directional splitting.

dir1 is always same as section_direction plus the repulsion. dir2 is determined by the angles and the repulsion.

Parameters:
  • section_direction (numpy.ndarray) – The direction of the section.

  • angles (list) – The list angle distribution to sample from.

  • repulsion (numpy.ndarray) – The absolute repulsion contribution.

Returns:

first and second split directions.

Return type:

tuple[numpy.ndarray, numpy.ndarray]

neurots.astrocyte.space_colonization._majorize_process(process, stop, target_distance)

Curates the non-major processes to apply a gradient to large components.

Note

If the expected maximum length is larger that target distance, then a process type of major will be returned. Otherwise, the initial type process will be returned.

Parameters:
  • process (str) – Process type.

  • stop (StopCriteria) – Section stop criteria.

  • target_distance (float) – Target distance to check the stop criteria against.

Returns:

process type

Return type:

str

neurots.astrocyte.space_colonization._repulsion(points, current_point, length_constant)

Calculate the repulsion from the points to the ref_point.

The length_constant determines the decay rate of the exponential contribution.

Only the points that are inside the hemisphere with radius cutoff_distance and in the same halfspace as section_radius are taken into account.

Parameters:
  • points (numpy.ndarray) – Seed points, the sources of the repulsion force.

  • current_point (numpy.ndarray) – Reference point on which the repulsion will be applied.

  • length_constant (float) – Exponential’s decay length constant for repulsion strength.

Returns:

The average absolute repulsion contribution.

Return type:

numpy.ndarray