class WitvlietDataReader(ConnectomeDataset):
"""Reader for datasets from [Witvliet et al. 2021](../../Witvliet_2021.md)"""
verbose = False
def __init__(self, spreadsheet):
ConnectomeDataset.__init__(self)
self.filename = get_filename_from_spreadsheet(spreadsheet)
neurons, muscles, other_cells, conns = self.read_all_data()
for conn in conns:
self.add_connection_info(
conn,
append_existing_connections=False,
check_overwritten_connections=True,
)
def read_data(self):
return self._read_data()
def read_muscle_data(self):
return self._read_muscle_data()
def read_all_data(self):
neurons = set([])
muscles = set([])
other_cells = set([])
conns = []
wb = load_workbook(self.filename)
sheet = wb.worksheets[0]
print_("Opened the Excel file (Witvliet data): " + self.filename)
for row in sheet.iter_rows(
min_row=2, values_only=True
): # Assuming data starts from the second row
pre = str(row[0])
post = str(row[1])
pre = fix_witvliet_cell_naming(remove_leading_index_zero(pre))
post = fix_witvliet_cell_naming(remove_leading_index_zero(post))
if is_potential_muscle(pre):
pre = convert_to_preferred_muscle_name(pre)
if is_potential_muscle(post):
post = convert_to_preferred_muscle_name(post)
syntype_here = str(row[2])
num = int(row[3])
if syntype_here == "electrical":
syntype = ELECTRICAL_SYN_TYPE
elif syntype_here == "chemical":
syntype = CHEMICAL_SYN_TYPE
if self.verbose and num > 0:
print_("Conn %s -> %s #%i" % (pre, post, num))
synclass = (
GENERIC_ELEC_SYN_CLASS
if syntype == ELECTRICAL_SYN_TYPE
else GENERIC_CHEM_SYN_CLASS
)
# Add the reverse connection for electrical synapses, since they are bidirectional
if synclass == GENERIC_ELEC_SYN_CLASS:
conns.append(ConnectionInfo(post, pre, num, syntype, synclass))
conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
for p in [pre, post]:
if is_herm_neuron(p):
neurons.add(pre)
elif is_known_muscle(p):
muscles.add(pre)
else:
other_cells.add(p)
return list(neurons), list(muscles), list(other_cells), conns