neuror.utils¶
Utils module
Functions
Returns the angle in radians between vectors 'v1' and 'v2'. |
|
Return the direction vector of a section. |
|
Return a dict of extended types. |
|
Return the rotation matrix associated with counterclockwise rotation about the given axis by theta radians. |
|
Section length. |
|
Returns the unit vector of the vector. |
Classes
JSON encoder that handles numpy types. |
|
The types used for the repair. |
- class neuror.utils.RepairJSON(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶
Bases:
JSONEncoder
JSON encoder that handles numpy types.
In python3, numpy types don’t serialize to correctly, so a custom converter is needed.
- default(o)[source]¶
Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
- class neuror.utils.RepairType(value)[source]¶
Bases:
Enum
The types used for the repair.
Note
This class is based on https://bbpgitlab.epfl.ch/nse/morphologyrepair/BlueRepairSDK/-/blob/main/BlueRepairSDK/src/helper_dendrite.h#L22
- neuror.utils.angle_between(v1, v2)[source]¶
Returns the angle in radians between vectors ‘v1’ and ‘v2’.
..code:
>>> angle_between((1, 0, 0), (0, 1, 0)) 1.5707963267948966 >>> angle_between((1, 0, 0), (1, 0, 0)) 0.0 >>> angle_between((1, 0, 0), (-1, 0, 0)) 3.141592653589793
- neuror.utils.direction(section)[source]¶
Return the direction vector of a section.
- Parameters:
section (morphio.mut.Section) – section
- neuror.utils.rotation_matrix(axis, theta)[source]¶
Return the rotation matrix associated with counterclockwise rotation about the given axis by theta radians.
- neuror.utils.section_length(section)[source]¶
Section length.
- Parameters:
section (morphio.mut.Section) – section