neat.MorphTree.readSWCTreeFromFile¶
-
MorphTree.
readSWCTreeFromFile
(file_n, types=[1, 3, 4])[source]¶ Non-specific for a “tree data structure” Read and load a morphology from an SWC file and parse it into an neat.MorphTree object.
On the NeuroMorpho.org website, 5 types of somadescriptions are considered (http://neuromorpho.org/neuroMorpho/SomaFormat.html). The “3-point soma” is the standard and most files are converted to this format during a curation step. neat follows this default specification and the internal structure of `neat` implements the 3-point soma. Additionally multi-cylinder descriptions with more than three nodes are also supported, but are converted to the standard three point description.
Additionally, the root node of the tree must have
index == 1
,swc_type == 1
and occur first in the SWC file.- Parameters
file_n (str) – name of the file to open
types (list of ints) – NeuroMorpho.org segment types to be loaded
Examples
The three point description is
1 1 x y z r -1 1 1 x y-r z r 1 1 1 x y+r z r 1
with x,y,z the coordinates of the soma center and r the soma radius
This is a valid three point desciption
# start of file 1 1 45.3625 18.6775 -50.25 10.1267403895 -1 2 1 45.3625 8.55075961052 -50.25 10.1267403895 1 3 1 45.3625 28.8042403895 -50.25 10.1267403895 1 # dendrite nodes 4 3 37.76 12.99 -46.08 0.29 1 5 3 26.7068019951 8.26344199599 -36.9426896493 0.795614809475 4 # ...
This is a valid multi-cylinder descirption
# start of file 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 # dendrite nodes 9 3 1070.0 427.75 161.0 0.886 8 # ...
- Raises
ValueError – If the SWC file is not consistent with the aforementioned conventions