-
Notifications
You must be signed in to change notification settings - Fork 1
/
neuron_visualization.py
executable file
·122 lines (81 loc) · 2.06 KB
/
neuron_visualization.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import re
from math import sqrt
from random import randint
import sys
import numpy as np
from random import uniform, randrange
from math import cos, sin, pi, sqrt, radians, degrees
def first_graph(abs_path, file_name, dlist, dend_add3d, points, parental_points, soma_index):
my_plot=[]
for point in soma_index:
for k in soma_index:
i=point[0]
x=point[2]
y=point[3]
z=point[4]
d=point[5]
c=point[6]
if c==k[0]:
xp=k[2]
yp=k[3]
zp=k[4]
my_plot.append([x, y, z, xp, yp, zp, d, 1, '0x0000FF'])
for dend in dlist:
for point in dend_add3d[dend]:
i=point[0]
x=point[2]
y=point[3]
z=point[4]
d=point[5]
c=point[6]
to_whom_is_connected=parental_points[c]
if to_whom_is_connected==-1 or point[1]==2:
continue
xp=points[to_whom_is_connected][2]
yp=points[to_whom_is_connected][3]
zp=points[to_whom_is_connected][4]
my_plot.append([x, y, z, xp, yp, zp, d, dend, '0x0000FF'])
fname=file_name.replace('.swc','') + '_before.txt'
name=abs_path+fname
f = open(name, 'w')
for i in my_plot:
print >>f, str(i)[1:-1]
f.close()
def second_graph(abs_path,file_name, dlist, dend_add3d, points, parental_points, soma_index):
my_plot=[]
for point in soma_index:
for k in soma_index:
i=point[0]
x=point[2]
y=point[3]
z=point[4]
d=point[5]
c=point[6]
if c==k[0]:
xp=k[2]
yp=k[3]
zp=k[4]
my_plot.append([x, y, z, xp, yp, zp, d, 0, '0x0000FF'])
for dend in dlist:
for point in dend_add3d[dend]:
i=point[0]
x=point[2]
y=point[3]
z=point[4]
d=point[5]
c=point[6]
to_whom_is_connected=parental_points[c]
if to_whom_is_connected==-1 or point[1]==2:
continue
xp=points[to_whom_is_connected][2]
yp=points[to_whom_is_connected][3]
zp=points[to_whom_is_connected][4]
my_plot.append([x, y, z, xp, yp, zp, d, dend, '0x0000FF'])
print '>>' + str(len(my_plot))
print file_name
fname=file_name.replace('.swc','') + '_after.txt'
name=abs_path+fname
f = open(name, 'w')
for i in my_plot:
print >>f, str(i)[1:-1]
f.close()