neuror.cut_plane.detection¶
Module for the detection of the cut plane
Functions
|
|
|
Returns a tuple of the optimized values of (rot_x, rot_y, rot_z, transl_x, transl_y, transl_z) |
|
The success function is low (=good) when the difference of points on the left side and right side of the plane is high |
Compute -Log(p|k) where p is the a posteriori probability to observe k counts in bin given than the mean value was "mu": demo: p(k|mu) = exp(-mu) * mu**k / k! |
|
Plot the neuron, the cut plane and the cut leaves. |
Classes
The cut plane class. |
- class neuror.cut_plane.detection.CutPlane(coefs: List[float], upward: bool, morphology: None | str | Path | Morphology, bin_width: float)[source]¶
Bases:
HalfSpace
The cut plane class.
It is composed of a HalfSpace and a morphology The morphology is part of the HalfSpace, the cut space is the complementary HalfSpace.
- classmethod find(neuron, bin_width=3, searched_axes=('X', 'Y', 'Z'), searched_half_spaces=(-1, 1), fix_position=None)[source]¶
Find and return the cut plane that is oriented along X, Y or Z.
6 potential positions are considered: for each axis, they correspond to the coordinate of the first and last point of the neuron.
Description of the algorithm:
The distribution of all points along X, Y and Z is computed and put into 3 histograms.
For each histogram we look at the first and last empty bins (ie. the last bin before the histogram starts rising, and the first after it reaches zero again). Under the assumption that there is no cut plane, the posteriori probability of observing this empty bin given the value of the not-empty neighbour bin is then computed.
The lowest probability of the 6 probabilities (2 for each axes) corresponds to the cut plane
- Parameters:
neuron (Morphology|str|pathlib.Path) – a morphology
bin_width – The size of the binning
display – where or not to display the control plots Note: It is the user responsability to call matplotlib.pyplot.show()
searched_axes – x, y or z. Specify the planes for which to search the cut plane
searched_half_spaces – A negative value means the morphology lives on the negative side of the plane, and a positive one the opposite.
fix_position – If not None, this is the position for which to search the cut plane. Only the orientation will be searched for. This can be useful to find the orientation of a plane whose position is known.
- Returns:
A cut plane object
- classmethod find_legacy(neuron, axis)[source]¶
Find the cut points according to the legacy algorithm
As implemented in: https://bbpgitlab.epfl.ch/nse/morphologyrepair/BlueRepairSDK/-/blob/main/BlueRepairSDK/src/repair.cpp#L263
- classmethod from_json(cut_plane_obj, morphology=None)[source]¶
Factory constructor from a JSON file.
- Parameters:
cut_plane_obj (dict|str|pathlib.Path) – a cut plane It can be a python dictionary or a path to a json file that contains one
morphology (Morphology) – the morphology passed to the
CutPlane
object
- classmethod from_rotations_translations(transformations, morphology, bin_width)[source]¶
Factory method to build the plane equation from the rotation and translation provided by the
viewer
.- Parameters:
transformations – An array
[rot_x, rot_y, rot_z, transl_x, transl_y, transl_z]
- histogram()[source]¶
Get the point distribution projected along the normal to the plane
- Returns:
a numpy.histogram
- to_json()[source]¶
Return a dictionary with the following items:
status: ‘ok’ if everything went right, else an informative string
- cut_plane: a tuple (plane, position) where ‘plane’ is ‘X’, ‘Y’ or ‘Z’
and ‘position’ is the position
cut_leaves: an np.array of all termination points in the cut plane
- figures: if ‘display’ option was used, a dict where values are tuples (fig, ax)
for each figure
- details: A dict currently only containing -LogP of the bin where the cut plane was
found
- neuror.cut_plane.detection.get_minus_log_p(k, mu)[source]¶
Compute -Log(p|k) where p is the a posteriori probability to observe k counts in bin given than the mean value was “mu”: demo: p(k|mu) = exp(-mu) * mu**k / k!
- neuror.cut_plane.detection.plot(neuron, result, inline=False)[source]¶
Plot the neuron, the cut plane and the cut leaves.
- Parameters:
neuron (Morphology) – the neuron to be plotted
result (dict) – the cut plane object in dictionary form
inline (bool) – if True, plot as an interactive plot (for example in a Jupyter notebook)