neuror.main

Dendritic repair module

It is based on the BlueRepairSDK’s implementation

Functions

_branching_angles

Return a list of 2-tuples.

_continuation

Continue growing the section.

_get_sholl_layer

Returns this section sholl layer.

_get_sholl_proba

Return the probabilities of bifurcation, termination and bifurcation in a dictionnary for the given sholl layer and branch order.

_grow_until_sholl_sphere

Grow until reaching next sholl layer.

_last_segment_vector

Returns the vector formed by the last 2 points of the section

_max_y_dendritic_cylindrical_extent

Return the maximum distance of dendritic section ends and the origin in the XZ plane.

_y_cylindrical_extent

Returns the distance from the last section point to the origin in the XZ plane.

is_branch_intact

Does the branch have leaves belonging to the cut plane?

is_cut_section

Return true if the section is close from the cut plane.

repair

The repair function.

Classes

Action

To bifurcate or not to bifurcate?

Repair

Repair the input morphology.

class neuror.main.Action(value)[source]

Bases: Enum

To bifurcate or not to bifurcate?

class neuror.main.Repair(inputfile: Path, axons: Path | None = None, seed: int | None = 0, cut_leaves_coordinates: ndarray | None = None, legacy_detection: bool = False, repair_flags: Dict[RepairType, bool] | None = None, apical_point: ndarray | None = None, params: Dict | None = None, validate_params=False)[source]

Bases: object

Repair the input morphology.

The repair algorithm uses sholl analysis of intact branches to grow new branches from cut leaves. The algorithm is fairly complex, but can be controled via a few parameters in the params dictionary. By default, they are:

_PARAMS = {
    'seg_length': 5.0,  # lenghts of new segments
    'sholl_layer_size': 10,  # resolution of the sholl profile
    'noise_continuation': 0.5,  # together with seg_length, this controls the tortuosity
    'soma_repulsion': 0.2,  # if 0, previous section direction, if 1, radial direction
    'bifurcation_angle': 20,  # noise amplitude in degree around mean bif angle on the cell
    'path_length_ratio': 0.5,  # a smaller value will make a strornger taper rate
    'children_diameter_ratio': 0.8,  # 1: child diam = parent diam, 0: child diam = tip diam
    'tip_percentile': 25,  # percentile of tip radius distributions to use as tip radius
}
Parameters:
  • inputfile – the input neuron to repair

  • axons – donor axons whose section will be used to repair this axon

  • seed – the numpy seed

  • cut_leaves_coordinates – List of 3D coordinates from which to start the repair

  • legacy_detection – if True, use the legacy cut plane detection (see neuror.cut_plane.legacy_detection)

  • repair_flags – a dict of flags where key is a neuror.utils.RepairType and value is whether it should be repaired or not. If not provided, all types will be repaired.

  • apical_point – 3d vector for apical point, else, the automatic apical detection is used if apical_point == -1, no automatic detection will be tried

  • params – repair internal parameters (see comments in code for details)

  • validate_params – if set to True, the given parameters are validated before processing

run(outputfile: Path, plot_file: Path | None = None)[source]

Run repair and export the result.

Parameters:
  • outputfile – path to the output morphology

  • plot_file – path to the output figure

static validate_params(params)[source]

Validate the given parameters according to the JSON schema.

neuror.main._get_sholl_proba(sholl_data: dict, section_type: SectionType, sholl_layer: int, pseudo_order: int) Dict[Action, float][source]

Return the probabilities of bifurcation, termination and bifurcation in a dictionnary for the given sholl layer and branch order.

If no data are available for this branch order, the action_counts are averaged on all branch orders for this sholl layer

Parameters:
  • sholl_data

    nested dict that stores the number of section per SectionType, sholl order, sholl layer and Action type

    sholl_data[neurite_type][layer][order][action_type] = counts

  • section_type – section type

  • sholl_layer – sholl layer

  • pseudo_order – pseudo order

Returns:

Probability of each action

Note

OrderedDict ensures the reproducibility of numpy.random.choice() outcome.

neuror.main.is_branch_intact(branch, cut_points)[source]

Does the branch have leaves belonging to the cut plane?

neuror.main.is_cut_section(section, cut_points)[source]

Return true if the section is close from the cut plane.

neuror.main.repair(inputfile: Path, outputfile: Path, axons: List[Path] | None = None, seed: int = 0, cut_leaves_coordinates: ndarray | None = None, legacy_detection: bool = False, plot_file: Path | None = None, repair_flags: Dict[RepairType, bool] | None = None, apical_point: List | None = None, params: Dict | None = None, validate_params=False)[source]

The repair function.

Parameters:
  • inputfile – the input morph

  • outputfile – the output morph

  • axons – the axons

  • seed – the numpy seed

  • cut_leaves_coordinates – List of 3D coordinates from which to start the repair

  • plot_file – the filename of the plot

  • repair_flags – a dict of flags where key is a neuror.utils.RepairType and value is whether it should be repaired or not. If not provided, all types will be repaired.

  • apical_point – 3d vector for apical point, else, the automatic apical detection is used

  • params – repair internal parameters, None will use defaults

  • validate_params – if set to True, the given parameters are validated before processing