unibe-cns / NEAT

NEAT (NEural Analysis Toolkit)
Other
12 stars 15 forks source link

[WIP] Fix soma loading #98

Closed WillemWybo closed 4 years ago

sunzhenyang2018 commented 4 years ago

I checkout the code and ran, got some error. issue4

WillemWybo commented 4 years ago

Seems like I will have to test things out more systematically. Could you indicate how the soma is described that you are trying to load (according to http://www.neuromorpho.org/SomaFormat.html)? Could you also attach an example of an swc. file (doesn't have to be the full morphology, just the soma) so that I can test it?

In neat, all soma's are internally encoded as spheres (although neat.MorphTree stores them in the 3-point format), the only relevant property being their radius, which has to be adjusted to match the surface area of the original soma file. Hence, if you also have this 'ground truth' surface area available I could test everything properly.

sunzhenyang2018 commented 4 years ago

Sorry for the delay. The link you provided does not work. Here is the swc file for the full morphology of the cell I was working with. Cell1.zip

WillemWybo commented 4 years ago

So there were some bugs that should now be corrected.

However, there is also an issue with your morphology:

1 3 1066.38 399.67 157.0 4.9215 -1
2 3 1071.3 399.67 157.0 4.9215 1
3 3 1076.22 399.67 157.0 4.9215 2
4 1 1066.5 402.83 157.0 11.494 2
5 1 1062.4 405.5 157.0 15.308 4
6 1 1056.6 410.25 158.0 20.536 5
7 1 1056.6 410.25 158.0 20.536 6
8 1 1070.0 427.75 161.0 2.305 7
9 3 1070.0 427.75 161.0 0.886 8
...

In neat, the first soma node (whose coordinates indicate the center of the soma) should always be the root node, and should occur first in your file. Hence, the following loads correctly:

1 1 1066.38 399.67 157.0 4.9215 -1
2 1 1071.3 399.67 157.0 4.9215 1
3 1 1076.22 399.67 157.0 4.9215 2
4 1 1066.5 402.83 157.0 11.494 2
5 1 1062.4 405.5 157.0 15.308 4
6 1 1056.6 410.25 158.0 20.536 5
7 1 1056.6 410.25 158.0 20.536 6
8 1 1070.0 427.75 161.0 2.305 7
9 3 1070.0 427.75 161.0 0.886 8
...

Note that internally, neat has the three-point representation, with as center of the soma the average x,y,z coordinates of all soma points defined in the SWC file. Nevertheless, as neat represents the soma as a sphere, the three-point representation is redundant, and we only retain the node with index 1 in the standard iterators, the coordinates of which can be acces through MorphTree.root.xyz and the spherical radius as MorphTree.root.R. Note that the two other nodes of the three point representation can also be accessed explicitly by MorphTree.__getitem__(2) or MorphTree.__getitem__(3).

Finally, I have modified the docstring of the function MorphTree.readSWCTreeFromFile() and it should also show up on the documentation website now. It describes the accepted soma formats.

sunzhenyang2018 commented 4 years ago

Thank you for the fix. I tested it out on my own and it worked.