Skip to content

WormNeuroAtlasFuncReader

WormNeuroAtlasFuncReader

Bases: ConnectomeDataset

Data on functional connectivity from the WormNeuroAtlas package

Source code in cect/WormNeuroAtlasFuncReader.py
 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
class WormNeuroAtlasFuncReader(ConnectomeDataset):
    """Data on functional connectivity from the **[WormNeuroAtlas package](https://github.com/francescorandi/wormneuroatlas)**"""

    def __init__(self, max_q):
        ConnectomeDataset.__init__(self)

        self.max_q = max_q

        print_(
            "Initialising WormNeuroAtlasFuncReader with max q value: %s" % self.max_q
        )

        self.atlas = wa.NeuroAtlas()

        self.all_cells = get_all_cells(self.atlas)

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

    def read_data(self):
        conns = []

        dff = self.atlas.get_signal_propagation_map(strain="wt")
        q = self.atlas.get_signal_propagation_q(strain="wt")

        connected_cells = []

        for pre in self.all_cells:
            apre = self.atlas.ids_to_ai([pre])
            for post in self.all_cells:
                apost = self.atlas.ids_to_ai([post])

                connection = False

                bound = 10

                dff_ij_orig = dff[apost, apre][0]

                dff_ij = (
                    0
                    if (apost == apre or math.isnan(dff_ij_orig))
                    else max(-1 * bound, min(bound, dff_ij_orig))
                )
                # dff_ij = dff_ij_orig

                q_ij = q[apost, apre]

                num = dff_ij

                if abs(num) > -10 and q_ij < self.max_q:
                    if num < 0:
                        print_(
                            "Functional conn junc (%s (%i) -> %s (%i):\t%s (orig = %s, q = %s)"
                            % (pre, apre, post, apost, dff_ij, dff_ij_orig, q_ij)
                        )
                    synclass = FUNCTIONAL_SYN_CLASS
                    syntype = FUNCTIONAL_SYN_TYPE
                    conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
                    connection = True

                if connection:
                    if pre not in connected_cells:
                        connected_cells.append(pre)
                    if post not in connected_cells:
                        connected_cells.append(post)

        return connected_cells, conns

    def read_muscle_data(self):
        neurons = []
        muscles = []
        conns = []
        return neurons, muscles, conns