Skip to content

UpdatedSpreadsheetDataReader

UpdatedSpreadsheetDataReader

Bases: ConnectomeDataset

Source code in cect/UpdatedSpreadsheetDataReader.py
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
class UpdatedSpreadsheetDataReader(ConnectomeDataset):
    def __init__(self):
        ConnectomeDataset.__init__(self)

        cells, neuron_conns = self.read_data()
        for conn in neuron_conns:
            self.add_connection_info(conn)

        neurons2muscles, muscles, muscle_conns = self.read_muscle_data()
        for conn in muscle_conns:
            self.add_connection_info(conn)

    def read_data(self, include_nonconnected_cells=False):
        """
        Returns:
            Tuple[list, list]: List of cells (str) and list of connections (``ConnectionInfo``) which have been read in
        """

        conns = []
        cells = []

        with open(filename, "r") as f:
            reader = csv.DictReader(f)
            print_("Opened file: " + filename)

            # known_nonconnected_cells = ["CANL", "CANR"]

            for row in reader:
                pre, post, num, syntype, synclass = parse_row(row)

                if not _is_neuron(pre) or not _is_neuron(post):
                    continue  # pre or post is not a neuron

                pre = _remove_leading_index_zero(pre)
                post = _remove_leading_index_zero(post)

                conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
                # print ConnectionInfo(pre, post, num, syntype, synclass)
                if pre not in cells:
                    cells.append(pre)
                if post not in cells:
                    cells.append(post)

            if include_nonconnected_cells:
                from cect.Cells import PREFERRED_HERM_NEURON_NAMES

                for c in PREFERRED_HERM_NEURON_NAMES:
                    if c not in cells:
                        cells.append(c)

        return cells, 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, post, num, syntype, synclass = parse_row(row)

                if not (
                    _is_neuron(pre) or _is_body_wall_muscle(pre)
                ) or not _is_body_wall_muscle(post):
                    continue

                if _is_neuron(pre):
                    pre = _remove_leading_index_zero(pre)
                else:
                    pre = _get_old_muscle_name(pre)
                post = _get_old_muscle_name(post)

                conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
                if _is_neuron(pre) and pre not in neurons:
                    neurons.append(pre)
                elif _is_body_wall_muscle(pre) and pre not in muscles:
                    muscles.append(pre)
                if post not in muscles:
                    muscles.append(post)

        return neurons, muscles, conns

read_data(include_nonconnected_cells=False)

Returns:

Type Description

Tuple[list, list]: List of cells (str) and list of connections (ConnectionInfo) which have been read in

Source code in cect/UpdatedSpreadsheetDataReader.py
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
def read_data(self, include_nonconnected_cells=False):
    """
    Returns:
        Tuple[list, list]: List of cells (str) and list of connections (``ConnectionInfo``) which have been read in
    """

    conns = []
    cells = []

    with open(filename, "r") as f:
        reader = csv.DictReader(f)
        print_("Opened file: " + filename)

        # known_nonconnected_cells = ["CANL", "CANR"]

        for row in reader:
            pre, post, num, syntype, synclass = parse_row(row)

            if not _is_neuron(pre) or not _is_neuron(post):
                continue  # pre or post is not a neuron

            pre = _remove_leading_index_zero(pre)
            post = _remove_leading_index_zero(post)

            conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
            # print ConnectionInfo(pre, post, num, syntype, synclass)
            if pre not in cells:
                cells.append(pre)
            if post not in cells:
                cells.append(post)

        if include_nonconnected_cells:
            from cect.Cells import PREFERRED_HERM_NEURON_NAMES

            for c in PREFERRED_HERM_NEURON_NAMES:
                if c not in cells:
                    cells.append(c)

    return cells, conns

read_muscle_data()

Returns:

Name Type Description
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.

Source code in cect/UpdatedSpreadsheetDataReader.py
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
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, post, num, syntype, synclass = parse_row(row)

            if not (
                _is_neuron(pre) or _is_body_wall_muscle(pre)
            ) or not _is_body_wall_muscle(post):
                continue

            if _is_neuron(pre):
                pre = _remove_leading_index_zero(pre)
            else:
                pre = _get_old_muscle_name(pre)
            post = _get_old_muscle_name(post)

            conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
            if _is_neuron(pre) and pre not in neurons:
                neurons.append(pre)
            elif _is_body_wall_muscle(pre) and pre not in muscles:
                muscles.append(pre)
            if post not in muscles:
                muscles.append(post)

    return neurons, muscles, conns