neurots.utils

NeuroTS utils used by multiple tools.

Functions

accept_reject(propose, probability, rng[, ...])

Generic accept/reject algorithm.

convert_from_legacy_neurite_type(data)

Convert legacy neurite type names, basal -> basal_dendrite and apical -> apical_dendrite.

format_values(obj[, decimals])

Format values of an object recursively.

neurite_type_warning(key)

Print a deprecation warning for old neurite_type key.

point_to_section_segment(neuron, point[, ...])

Find section and segment that matches the point (also in morph_tool.spatial).

Exceptions

NeuroTSError

Raises NeuroTS error.

exception neurots.utils.NeuroTSError

Bases: Exception

Raises NeuroTS error.

neurots.utils.accept_reject(propose, probability, rng, max_tries=50, randomness_increase=1.2, **probability_kwargs)

Generic accept/reject algorithm.

Parameters:
  • propose (callable) – function to propose a move, which has an ‘noise’ argument to allow for increasing randomness and faster acceptance (to allow sharp turns, etc…)

  • probability (callable) – function to compute probability, first arg is the proposal (output of propose function), and takes extra kwargs via probability_kwargs

  • rng (np.random._generator.Generator) – random number generator

  • max_tries (int) – maximum number of tries to accept before we return best proposal

  • randomness_increase (float) – increase of noise amplitude after each try

  • probability_kwargs (dict) – parameters for probability function

neurots.utils.convert_from_legacy_neurite_type(data)

Convert legacy neurite type names, basal -> basal_dendrite and apical -> apical_dendrite.

neurots.utils.format_values(obj, decimals=None)

Format values of an object recursively.

neurots.utils.neurite_type_warning(key)

Print a deprecation warning for old neurite_type key.

neurots.utils.point_to_section_segment(neuron, point, rtol=1e-05, atol=1e-08)

Find section and segment that matches the point (also in morph_tool.spatial).

Only the first point found with the exact same coordinates as the point argument is considered

Parameters:
  • neuron (morphio.Morphology) – neuron object

  • point (point) – value of the point to find in the h5 file

  • rtol (floats) – precision of np.isclose

  • atol (floats) – precision of np.isclose

Returns:

(NeuroM/MorphIO section ID, point ID) of the point the matches the input coordinates. Since NeuroM v2, section ids of NeuroM and MorphIO are the same excluding soma.

Return type:

Tuple