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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196 | class Cook2020DataReader(ConnectomeDataset):
"""
Reader of data from Cook et al. 2020 - The connectome of the Caenorhabditis elegans pharynx
"""
cells = []
conns = []
def __init__(self):
ConnectomeDataset.__init__(self)
cells, neuron_conns = self.read_data()
for conn in neuron_conns:
self.add_connection_info(conn)
def read_data(self):
"""
Returns:
Tuple[list, list]: List of cells (str) and list of connections (``ConnectionInfo``) which have been read in
"""
with open(filename, "r") as f:
reader = csv.DictReader(f)
print_("Opened file: " + filename)
for row in reader:
pre = str.strip(row["Source"])
if is_potential_muscle(pre):
pre = convert_to_preferred_muscle_name(pre)
post = str.strip(row["Target"])
if is_potential_muscle(post):
post = convert_to_preferred_muscle_name(post)
if is_marginal_cell(post):
post = convert_to_preferred_phar_cell_name(post)
num = float(row["Weight"])
syntype = str.strip(row["Type"])
synclass = (
GENERIC_ELEC_SYN if "Electrical" in syntype else GENERIC_CHEM_SYN
)
if syntype == "Electrical":
self.conns.append(ConnectionInfo(post, pre, num, syntype, synclass))
self.conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if pre not in self.cells:
self.cells.append(pre)
if post not in self.cells:
self.cells.append(post)
with open(filename2, "r") as f:
reader = csv.DictReader(f)
print_("Opened file: " + filename)
for row in reader:
pre = str.strip(row["Source"])
if is_potential_muscle(pre):
pre = convert_to_preferred_muscle_name(pre)
if is_marginal_cell(pre):
pre = convert_to_preferred_phar_cell_name(pre)
post = str.strip(row["Target"])
if is_potential_muscle(post):
post = convert_to_preferred_muscle_name(post)
if is_marginal_cell(post):
post = convert_to_preferred_phar_cell_name(post)
num = float(row["Weight"])
syntype = "Electrical"
if syntype == "Electrical":
self.conns.append(ConnectionInfo(post, pre, num, syntype, synclass))
synclass = (
GENERIC_ELEC_SYN if "Electrical" in syntype else GENERIC_CHEM_SYN
)
self.conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if pre not in self.cells:
self.cells.append(pre)
if post not in self.cells:
self.cells.append(post)
return self.cells, self.conns
def read_muscle_data(self):
"""
Returns:
neurons (:obj:`list` of :obj:`str`): List of motor neurons. Each neuron has at least one connection with a post-synaptic muscle cell.
muscles (:obj:`list` of :obj:`str`): List of muscle cells.
conns (:obj:`list` of :obj:`ConnectionInfo`): List of neuron-muscle connections.
"""
neurons = []
muscles = []
conns = []
with open(filename, "r") as f:
reader = csv.DictReader(f)
print_("Opened file: " + filename)
for row in reader:
pre = str.strip(row["Source"])
if is_potential_muscle(pre):
pre = convert_to_preferred_muscle_name(pre)
if is_marginal_cell(pre):
pre = convert_to_preferred_phar_cell_name(pre)
post = str.strip(row["Target"])
if is_potential_muscle(post):
post = convert_to_preferred_muscle_name(post)
if is_marginal_cell(post):
post = convert_to_preferred_phar_cell_name(post)
num = float(row["Weight"])
syntype = str.strip(row["Type"])
synclass = (
GENERIC_ELEC_SYN if "Electrical" in syntype else GENERIC_CHEM_SYN
)
if syntype == "Electrical":
conns.append(ConnectionInfo(post, pre, num, syntype, synclass))
conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if is_known_muscle(post):
if post in PREFERRED_MUSCLE_NAMES and post not in muscles:
muscles.append(post)
if pre in PREFERRED_HERM_NEURON_NAMES and pre not in neurons:
neurons.append(pre)
with open(filename2, "r") as f:
reader = csv.DictReader(f)
print_("Opened file: " + filename2)
for row in reader:
pre = str.strip(row["Source"])
if is_potential_muscle(pre):
pre = convert_to_preferred_muscle_name(pre)
if is_marginal_cell(pre):
pre = convert_to_preferred_phar_cell_name(pre)
post = str.strip(row["Target"])
if is_potential_muscle(post):
post = convert_to_preferred_muscle_name(post)
if is_marginal_cell(post):
post = convert_to_preferred_phar_cell_name(post)
num = float(row["Weight"])
syntype = "Electrical"
synclass = (
GENERIC_ELEC_SYN if "Electrical" in syntype else GENERIC_CHEM_SYN
)
if syntype == "Electrical":
conns.append(ConnectionInfo(post, pre, num, syntype, synclass))
conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if is_known_muscle(post):
if post in PREFERRED_MUSCLE_NAMES and post not in muscles:
muscles.append(post)
if pre in PREFERRED_HERM_NEURON_NAMES and pre not in neurons:
neurons.append(pre)
return neurons, muscles, conns
|