Created
August 27, 2016 08:54
-
-
Save zeffii/6fc0498988ff01a96b14ab47deab8214 to your computer and use it in GitHub Desktop.
swc importer
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
def find_number_of_prelim_comments_lines(p): | |
num = 0 | |
with open(p) as file: | |
while next(file).startswith('#'): | |
num += 1 | |
continue | |
return num | |
def make_visual_dict(p): | |
num_comment_lines = find_number_of_prelim_comments_lines(path) | |
spamz = {} | |
with open(p) as swc_file: | |
for _ in range(num_comment_lines): | |
next(swc_file) | |
for line in swc_file: | |
n, t, x, y, z, r, p = line.rstrip().split() | |
spamz[int(n)] = int(t), float(x), float(y), float(z), float(r), int(p) | |
break | |
return spamz | |
path = r'C:\Users\zeffi\Downloads\rubber\neuron_nmo\bergstrom\CNG version\291-1.CNG.swc' | |
points_dict = make_visual_dict(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment