GithubHelp home page GithubHelp logo

bluebrain / neuror Goto Github PK

View Code? Open in Web Editor NEW
9.0 11.0 6.0 3.04 MB

A collection of tools to repair morphologies

Home Page: https://neuror.readthedocs.io/

License: GNU Lesser General Public License v3.0

Python 49.69% CSS 2.82% AGS Script 47.49%

neuror's Issues

2 small issues in sanitize

1: the check of non constant type has a wrong message, it compares with root, not parent section
2: the remove zero lenght should have a hidden warning if it does it, and a strong warning if it removes a root section, as the whole tree will be removed. It removes if only one point is left.

option to bypass soma check in sanitize

@mariarv wants to sanitize dendrites for some morphologies, but does not care about soma. Some of her morphs don't have soma, so an option in sanitize such as ignore_soma=False could be of some use.

Sanitize deletes all children sections when parent section length is zero

Hi, @Stannislav noticed that during sanitize of a neuron, if a section has zero length subsequent sections are deleted as well. This is probably coming from here:

def fix_non_zero_segments(neuron, zero_length=_ZERO_LENGTH):

This should not be the expected behavior for sanitize (imo). Instead when a zero length section is removed subsequent sections should be stitched back to its parent.

Could you please look into this issue? Thanks a lot!

Sanitize deletes all children sections when parent section (non-soma) is zero

This is a continuation of #99
Running neuror sanitize file simple1.asc out.asc on

("CellBody"
  (Color Red)
  (CellBody)
  (0.001000000 0.001000000 0.000000000 0.010000000)
  (-0.001000000 0.001000000 0.000000000 0.010000000)
  (-0.001000000 -0.001000000 0.000000000 0.010000000)
  (0.001000000 -0.001000000 0.000000000 0.010000000)
)

( (Color Cyan)
  (Axon)
  (0.000000000 0.000000000 0.000000000 2.000000000)
  (0.000000000 -4.000000000 0.000000000 2.000000000)
  (
    (0.000000000 -4.000000000 0.000000000 4.000000000)
    (0.000000000 -4.000000000 0.000000000 4.000000000)
    (0.000000000 -4.000000000 0.000000000 4.000000000)
    (
        (6.000000000 -4.000000000 0.000000000 4.000000000)
        (7.000000000 -5.000000000 0.000000000 4.000000000)
    |
        (6.000000000 -4.000000000 0.000000000 4.000000000)
        (8.000000000 -4.000000000 0.000000000 4.000000000)
    )
  |
    (0.000000000 -4.000000000 0.000000000 4.000000000)
    (-5.000000000 -4.000000000 0.000000000 4.000000000)
  )
)

Which results in:

[...snip cellbody]
( (Color Cyan)
  (Axon)
  (0.000000000 0.000000000 0.000000000 2.000000000)
  (0.000000000 -4.000000000 0.000000000 2.000000000)
  (
    (0.000000000 -4.000000000 0.000000000 4.000000000)
    (-5.000000000 -4.000000000 0.000000000 4.000000000)
  )
)

and doesn't have the correct subtree.

Unraveling breaks up sections

I tried to unravel the morphology of L23_PC_cADpyr_229_2 from the Blue Brain-database but the sections seem to get scattered in the x-direction.

import matplotlib.pyplot as plt

from morphio import Morphology
from neuror.unravel import unravel


def display(morph, color):
    for sec in morph.sections:
        x = sec.points.T
        plt.plot(x[0], x[1], x[2], c=color)


u, _ = unravel('data/morph_7.h5')
u.write('data/morph_7_unr.h5')

plt.subplot(projection='3d')
display(Morphology('data/morph_7.h5'), 'k')
display(Morphology('data/morph_7_unr.h5'), 'tab:blue')
plt.show()

Raise an Error if 0-length section is found at the soma

This is related to #105.

Context

Currently, if a 0-length section is found at the soma, sanitize will drop the entire neurite that is attached to it.

This behavior is not what a normal user could expect, especially because there is no Warning or Error when this dropping takes place during sanitization and the user cannot know that this has happened.

Action

After discussions (@lidakanari @adrien-berchet @mgeplf @eleftherioszisis) we agreed that the solution would be to raise an informative Error (e.g. ValueError("Zero-length section found at the soma ...") and terminate the execution of sanitize.

Improve repair by using pool of dendrites (as for axons)

This change is beyond the scope of #65 and will be treated in a future PR.
The rational is similar to synthesis, where all dendrites of all morphologies of same mtypes are used to synthesize a morphology, to avoid biases from specific features of morphologies. With this improvement, the repaired branches would be more varied, and not be almost a copy of other branches of the current morphology.

Different results depending on availability of AVX-512 instruction set and numpy>1.25 's vectorized sort/argsort

numpy==1.25 introduced simd vectorized version of quicksort with: numpy/numpy#23707

That change affects the behavior of the sort and argsort functions when using quicksort (default) based on the existence of the avx-512 instruction set.

In NeuroR, one of the functions that are affected is scipy.optimize.minimize:

result = optimize.minimize(_success_function,

which uses internally numpy's argsort in:
https://github.com/scipy/scipy/blob/cfe80116aaa145061246b8aec0e98248fbefb835/scipy/optimize/_optimize.py#L907

See also:
numpy/numpy#24064

Github hosted runners for ubuntu-latest seem to have enabled the aforementioned instruction set as they output different values than the expected ones in the past: https://github.com/BlueBrain/NeuroR/actions/runs/5484236591/jobs/9991722132

add z-range to error detection

z-range is the thickness of the morpho in the z-direction, corresponding to slice thickness. A small range can be understood as an error from reconstruction

Segfault in fix_zero_diameters because of stack limit

When using neuror.zero_diameter_fixer.fix_zero_diameters on the attached morphology, I get a segmentation fault.
After some investigation with @arnaudon , it appeared that it happens when the Python recursion limit is updated in the function with sys.setrecursionlimit and is set to a value greater than the actual stack size (which can be updated using ulimit -s <new_size>). When increasing the stack size with ulimit the problem disappears.

Here is a MWE:
First update the stack size in bash then run Python:

    ulimit -s 8192
    python

Then in Python:

    import morphio
    from neuror.zero_diameter_fixer import fix_zero_diameters
    morph = morphio.mut.Morphology("AA0319.asc")
    fix_zero_diameters(morph)

It should end in a segfault while the same with ulimit -s 16384 should pass.

I think the best way to solve this issue would be to change the algorithm to avoid recursion. But it might not be easy...

AA0319.asc.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.