Skip to content

WitvlietDataReader

WitvlietDataReader

Bases: ConnectomeDataset

Reader for datasets from Witvliet et al. 2021

Source code in cect/WitvlietDataReader.py
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
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 = "%s%s" % (spreadsheet_location, spreadsheet)

        neurons, muscles, other_cells, conns = self.read_all_data()

        for conn in conns:
            self.add_connection_info(conn)

    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: " + 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 = str(row[2])
            num = int(row[3])

            if self.verbose and num > 0:
                print("Conn %s -> %s #%i" % (pre, post, num))

            synclass = GENERIC_ELEC_SYN if "electrical" in syntype else GENERIC_CHEM_SYN
            if synclass == GENERIC_ELEC_SYN:
                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