morph_tool.nrnhines

Utils related to the NRN simulator.

Functions

NeuroM_section_to_NRN_compartment_paths(...)

Returns a dictionary NeuroM section id -> path of each compartment for the section.

NeuroM_section_to_NRN_section(filename)

Returns a mapping from NeuroM section IDs to NRN ones.

get_NRN_cell(filename)

Returns a NRN cell.

isolate(func)

Isolate a generic function for independent NEURON instances.

point_to_section_end(sections, point[, ...])

Returns the index of the first section whose end is close to point.

Classes

NestedPool([processes, initializer, ...])

Class that represents a MultiProcessing nested pool.

class morph_tool.nrnhines.NestedPool(processes=None, initializer=None, initargs=(), maxtasksperchild=None, context=None)

Class that represents a MultiProcessing nested pool.

class Process(*args, **kwargs)

Class that represents a non-daemon process.

property daemon

Stub method. Always returns False.

morph_tool.nrnhines.NeuroM_section_to_NRN_compartment_paths(morph_path: Path)

Returns a dictionary NeuroM section id -> path of each compartment for the section.

Path are formed by following the section points until the pathlength of the compartment is reached.

Parameters:

morph_path – the morphology path

  1. Compute the cumulative pathlength along the section segments_directions

  2. Get the compartment pathlengths (compartment are of equal pathlength in a given section)

  3. Compartment by compartment, follow the points until the compartment pathlength is reached

Example for one section:

               (1, 2) ------ (2, 2)
                  |
                  |
                  |
(0, 0) ------- (1, 0)

If n_compartments == 3, three paths are returned:

[array([[0.        , 0.        , 0.        ],
        [1.        , 0.        , 0.        ],
        [1.        , 0.33333333, 0.        ]]),

 array([[1.        , 0.33333333, 0.        ],
        [1.        , 1.66666667, 0.        ]]),

 array([[1.        , 1.66666667, 0.        ],
        [1.        , 2.        , 0.        ],
        [2.        , 2.        , 0.        ]])]
morph_tool.nrnhines.NeuroM_section_to_NRN_section(filename: Path)

Returns a mapping from NeuroM section IDs to NRN ones.

morph_tool.nrnhines.get_NRN_cell(filename: Path)

Returns a NRN cell.

morph_tool.nrnhines.isolate(func)

Isolate a generic function for independent NEURON instances.

It must be used in conjunction with NestedPool.

Example:

def _to_be_isolated(morphology_path, point):
    cell = nrnhines.get_NRN_cell(morphology_path)
    return nrnhines.point_to_section_end(cell.icell.all, point)

def _isolated(morph_data):
    return nrnhines.isolate(_to_be_isolated)(*morph_data)

with nrnhines.NestedPool(processes=n_workers) as pool:
    result = pool.imap_unordered(_isolated, data)
Parameters:

func (function) – function to isolate

Returns:

the isolated function

Note: it does not work as decorator.

morph_tool.nrnhines.point_to_section_end(sections: Sequence[neuron.nrn.Section], point: List[float], atol: float = 1e-08, rtol: float = 1e-05) None | int

Returns the index of the first section whose end is close to point.

The distance between the end and point must be less than EPSILON from POINT. If no section satisfies this requirement, returns None. The iteration order is given by the section index.

Parameters:
  • sections – a sequence of sections

  • point – the points’s 3D coordinates

  • atol – absolute tolerance

  • rtol – relative tolerance