morph_tool.simplify

Module for morphology simplification.

Functions

simplify_morphology(morph, epsilon)

Simplify the sections of a morphology.

morph_tool.simplify.simplify_morphology(morph, epsilon)

Simplify the sections of a morphology.

Each section in the morphology is simplified using the Ramer-Douglas-Peucker algorithm.

The algorithm starts from the first and last points of a curve represented as a list of points and recursively divides them into smaller segments.

At each step it finds the furthest point from the segment. If the point is not within a certain threshold distance ‘epsilon’ from the segment then this point can not be simplified and the segment is split into two smaller ones passing through that point, else all the intermediate points of this segment are discarded. The algorithm is then applied recursively to each new segment.

The result is a simplified curve that approximates the original with a fewer number of points. The distance threshold controls the simplification strength. Higher epsilon values result in simpler and less accurate curves with less inflection points (turns). A zero epsilon will result in a copy of the initial morphology, whereas a large epsilon will only keep the start and end points of each section.

Parameters:
  • morph – Morphology object, mutable or immutable

  • epsilon (float) – distance tolerance in microns

Returns:

Simplified morphology copy

Return type:

morphio.mut.Morphology

Note

This algorithm simplifies morphologies, therefore it will change morphometrics such as the tortuosity and the path length.