BlueBrain / MorphIO

A python and C++ library for reading and writing neuronal morphologies
https://morphio.readthedocs.io
Apache License 2.0
27 stars 24 forks source link

SWC reading error due to soma #213

Open jonathanlurie opened 3 years ago

jonathanlurie commented 3 years ago

Hello,

I am having an issue parsing an SWC file and I think it's related to the soma being multipoint. The Python error I have is the following:

Traceback (most recent call last):
  File "test_morphio.py", line 11, in <module>
    m = Morphology(morph_path)
morphio._morphio.SectionBuilderError: Cannot create section with type soma

When I open the morph with my JS or custom Python parser, I can see that the soma is actually having a "star shape" and that one branch of the star is an actual section composed of the point 1, 5136 and 5137 (on the file I'll provide you by email). I admit it's a bit weird to have a soma designed like that, but to my understanding, it's still somehow compliant with the SWC pseudo-spec (very loose spec imo).

As a side note, I haven't tested all the files but on the about 100 files I have tested, this happens only once.

Best.

mgeplf commented 3 years ago

[...] soma being multipoint [...]

Do you mean that it's a contour as opposed to a set of stacked cylinders?

jonathanlurie commented 3 years ago

No, it's not a contour, it's more like that (attempt to ASCII art!):

         A
           \
          O \______ C
            /
           /
          B

On the point O you have the node with no parent, and then A and B are regular neurite sections while the section between O and C is of type soma and composed of 3 nodes. Then, after C, it continues with a regular neurite type.

mgeplf commented 3 years ago

Spec wise, it's quite hard to nail anything down, and people seem to put stuff out that isn't conformant with what little there is. For the soma; I have always referred to this: http://neuromorpho.org/SomaFormat.html as neuromorpho.org has the most clout (in a way). 4. Multiple cylinders on that page sorta describe what you have, although the split isn't in their example (ri05.swc is a single stack).

The original paper (R.C.Cannon et al.: Journal of Neuroscience Methods - 1998) with the spec says:

Screenshot 2020-12-03 at 19 25 33

So it specifically says the parent must have a lower index, but it doesn't really say anything about split somas.

What do you think @wizmer?

Nice art :)

mgeplf commented 3 years ago

Ping @wizmer

wizmer commented 3 years ago

I don't think this should be allowed if we don't understand the physical meaning of such thing. How can we make something useful of those points if we don't understand what they represent. Are these points supposed to represent a surface as in the contour representation, a volume as in the single point soma representation ? If we can't put a physical meaning on this representation we won't be able to compute anything with (for example, soma surface, soma volume, center of gravity...)