neuror.sanitize¶
Module for the sanitization of raw morphologies.
Functions
Function to be called by sanitize_all to catch all exceptions and return path if in error. |
|
Annotate errors on a morphology in neurolucida format. |
|
Annotate errors on a list of morphologies in neurolicida format. |
|
Return a neuron with zero length segments removed |
|
Ensure section points are not inside the soma. |
|
Recursively yield morphology files in folder and its sub-directories. |
|
Sanitize one morphology. |
|
Sanitize all morphologies in input_folder and its sub-directories. |
- neuror.sanitize._sanitize_one(path, input_folder, output_folder)[source]¶
Function to be called by sanitize_all to catch all exceptions and return path if in error.
Since
multiprocessing.pool.Pool.imap_unordered()
only supports one argument, the argument is a tuple: (path, input_folder, output_folder).
- neuror.sanitize.annotate_neurolucida(morph_path: str, checkers: Dict | None = None)[source]¶
Annotate errors on a morphology in neurolucida format.
- Parameters:
morph_path – absolute path to an ascii morphology
checkers – dict of checker functons from neurom with function as keys and marker data in a dict as values, if None, default checkers are used
- Default checkers include:
fat ends
z-jumps
narrow start
dangling branch
multifurcation
- Returns:
annotations to append to .asc file
dict of error summary
dict of error markers
- neuror.sanitize.annotate_neurolucida_all(morph_paths: List[str], nprocesses: int = 1) Tuple[Dict, Dict, Dict] [source]¶
Annotate errors on a list of morphologies in neurolicida format.
- Parameters:
morph_paths – list of str of paths to morphologies.
nprocesses – number of processes to use for parallel computation
- Returns:
dict annotations to append to .asc file (morph_path as keys)
dict of dict of error summary (morph_path as keys)
dict of dict of markers (morph_path as keys)
- neuror.sanitize.fix_non_zero_segments(neuron, zero_length=0.0001)[source]¶
Return a neuron with zero length segments removed
Sections composed of a single zero length segment are deleted, where zero is parametrized by zero_length
- Parameters:
neuron (str|pathlib.Path|morphio.Morphology|morphio.mut.Morphology) – input neuron
zero_length (float) – smallest length of a segment
- Returns:
a fixed morphology
- Return type:
- neuror.sanitize.fix_points_in_soma(morph: Morphology) bool [source]¶
Ensure section points are not inside the soma.
- Method:
for each root section, we check which points are inside the soma.
if all points of a root section are inside the soma, an exception is raised because it means that a bifurcation is located inside the soma, which is hard to automatically fix.
if there is at least 1 point inside the soma, a new point is defined to replace them. If this new point is too close to the first point outside the soma, the point is not added.
- Parameters:
morph – the morphology
- Returns:
True
if at least one point was changed, elseFalse
.
- neuror.sanitize.iter_morphologies(folder)[source]¶
Recursively yield morphology files in folder and its sub-directories.
- neuror.sanitize.sanitize(input_neuron, output_path)[source]¶
Sanitize one morphology.
ensures it can be loaded with MorphIO
raises if the morphology has no soma or of invalid format
removes unifurcations
set negative diameters to zero
raises if the morphology has a neurite whose type changes along the way
removes segments with near zero lengths (shorter than 1e-4)
- Parameters:
input_neuron (str|pathlib.Path|morphio.Morphology|morphio.mut.Morphology) – input neuron
output_path (str|pathlib.Path) – output name
- neuror.sanitize.sanitize_all(input_folder, output_folder, nprocesses=1)[source]¶
Sanitize all morphologies in input_folder and its sub-directories.
See
sanitize()
for more information on the sanitization process.- Parameters:
input_folder (str|pathlib.Path) – input neuron
output_folder (str|pathlib.Path) – output name
Note
The sub-directory structure is maintained.