Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from kapilkd13/nmlimport
importing morphologies from nml file
- Loading branch information
Showing
12 changed files
with
985 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from pprint import pformat | ||
from collections import defaultdict | ||
|
||
|
||
# Returns parent segment | ||
def get_parent_segment(segment, segments): | ||
for s in segments: | ||
if s.id == segment.parent.segments: | ||
return s | ||
|
||
|
||
# Pretty format data | ||
def formatter(datum): | ||
a = pformat(datum) | ||
if len(a) > 160: | ||
a = a[0:160] + "[...]" | ||
return a | ||
|
||
# Returns a dictionary of child segments of each segment, segment id is a key. | ||
def get_child_segments(segments): | ||
children = defaultdict(list) | ||
root = None | ||
for segment in segments: | ||
if segment.parent is None: | ||
root = segment.id | ||
else: | ||
children[segment.parent.segments].append(segment.id) | ||
|
||
assert root is not None | ||
return children | ||
|
Oops, something went wrong.