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

3 point SWC soma #273

Closed asanin-epfl closed 3 years ago

asanin-epfl commented 3 years ago

Currently the only somas, that follow the below spec, are considered correct 3-point somas:

// The only valid neuro-morpho soma is:
// 1 1 x   y   z r -1
// 2 1 x (y-r) z r  1
// 3 1 x (y+r) z r  1

According to the preparing Neuron 8.0 and https://github.com/neuronsimulator/nrn/pull/1144, it's a wrong assumption. Should we stop following the above mentioned spec?

@mgeplf @tomdele

mgeplf commented 3 years ago

No, there are two types of 3 point somas; the neuromorpho ones (http://neuromorpho.org/SomaFormat.html) with the above format (ie: y, (y - r), (y + r)) and normal ones, where they are just stacked cynlinders (which is truen when https://github.com/neuronsimulator/nrn/pull/1144/files#diff-61e727d6dc48930b1ab9dffbcf39e9888837c0253780242a21c7270ddc18c596L194) doesn't pass.

asanin-epfl commented 3 years ago

ok, for me the problem is that MorphIO always throws a warning if 3-point soma does not conform the neuromorpho standard. Should this warning be thrown if 3 point soma is a normal one?

Here it always check for the neuromorpho https://github.com/BlueBrain/MorphIO/blob/master/src/readers/morphologySWC.cpp#L248. In this check the warning is always raised if the neuromorpho standard is not met https://github.com/BlueBrain/MorphIO/blob/master/src/readers/morphologySWC.cpp#L195.

mgeplf commented 3 years ago

I see, that doesn't seem right - I guess we have to fix it; question is - what is a good heuristic, such that small imprecision in y/y-r/y+r is acceptable. Can you try and implement it?

asanin-epfl commented 3 years ago

Can you try and implement it?

Yes, I will implement it.

mgeplf commented 3 years ago

I "drew" the 1/2/3 point soma cases: image

We should redraw this nicely, and add it to the doc w/ #275, so it's clear that is happening, and say what we handle. Couple notes: 1) we shouldn't do the sphere -> cylinder 'conversion' in MorphIO, that's how NEURON interprets it, iirc. 2) We need to decide if we handle the 3 point 'split/bifurcating' case

asanin-epfl commented 3 years ago

We should redraw this nicely

I will use matplotlib or similar tool.

  1. we shouldn't do the sphere -> cylinder 'conversion' in MorphIO, that's how NEURON interprets it, iirc.

I don't see that MorphIO does any implicit 'conversion' like NEURON. MorphIO should not do any conversion IMO. The only exception is a single point .swc soma.

  1. We need to decide if we handle the 3 point 'split/bifurcating' case

MorphIO currently supports this case. It only warns if it does not fit the neuromorpho spec. #275 will remove this warning. Another thing that worries me that MorphIO allows any bifurcating soma or I don't understand what bifurcating soma is. All the below morphologies don't cause any error/warning by MorphIO:

1 1 0 0 0 2.0 -1
2 1 -4 0 0 2.0 1
3 1 1 3 0 2.0 1
1 1 0 0 0 2.0 -1
2 1 -4 0 0 2.0 1
3 1 1 3 0 2.0 1
4 1 5 3 0 2.0 1
1 1 0 0 0 2.0 -1
2 1 -4 0 0 2.0 1
3 1 1 3 0 2.0 1
4 1 5 3 0 2.0 1
5 1 6 3 0 2.0 1
1 1 0 0 0 2.0 -1
2 1 -4 0 0 2.0 1
3 1 1 3 0 2.0 2
4 1 5 3 0 2.0 1
5 1 6 3 0 2.0 4
mgeplf commented 3 years ago

I will use matplotlib or similar tool.

I recommend inkscape and creating svgs - that way someone else can edit them. Thanks for doing this.

MorphIO should not do any conversion IMO.

Agree 100%.

All the below morphologies don't cause any error/warning by MorphIO:

Great, I'm on the same page as you now. The bifurcating soma is weird, imo, but not disallowed, as far as I can see. I don't know what the utility of them is, though.

Are those examples in the tests? If not, might be worth having them, and then they can be linked in the docs as 'examples of valid SWC somas'

asanin-epfl commented 3 years ago

Are those examples in the tests? If not, might be worth having them, and then they can be linked in the docs as 'examples of valid SWC somas'

No, I just made them up. The conflict is that MorphIO has the check for bifurcating soma https://github.com/BlueBrain/MorphIO/blob/master/src/readers/morphologySWC.cpp#L111. I'm looking at it, and it has a different understanding of bifurcating soma. According to it, the first soma point can not be the bifurcation point. That's why the above examples are working. The below example throws the bifurcation error. Do we have a solid description of bifurcation point? Is this a bug of MorphIO?

1 1 0 0 0 2.0 -1
2 1 -4 0 0 2.0 1
3 1 1 3 0 2.0 2
4 1 5 3 0 2.0 2
asanin-epfl commented 3 years ago

The morphologies from https://github.com/BlueBrain/MorphIO/issues/273#issuecomment-816509500:

1 1 0 0 0 2.0 -1
2 1 -4 0 0 2.0 1
3 1 1 3 0 2.0 1

...

They throw an error of bifurcating soma in NeuroM v1. I suppose we should throw in MorphIO as well?

asanin-epfl commented 3 years ago

fixed by #275