Skip to content

WormNeuroAtlasReader

Data extracted from the WormNeuroAtlas package for neuronal connectivity

WormNeuroAtlasReader

Bases: ConnectomeDataset

Data from the WormNeuroAtlas package for neuronal connectivity

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

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

        print_("Initialising WormNeuroAtlasReader")

        self.atlas = wa.NeuroAtlas()
        syn_sign = wa.SynapseSign()

        self.dom_glu = syn_sign.get_neurons_producing("Glu", mode="dominant")
        self.dom_ach = syn_sign.get_neurons_producing("ACh", mode="dominant")
        self.dom_gaba = syn_sign.get_neurons_producing("GABA", mode="dominant")

        self.alt_glu = syn_sign.get_neurons_producing("Glu", mode="alternative")
        self.alt_ach = syn_sign.get_neurons_producing("ACh", mode="alternative")
        self.alt_gaba = syn_sign.get_neurons_producing("GABA", mode="alternative")

        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 determine_nt(self, neuron):
        if neuron in self.dom_glu:
            return "Glutamate"
        elif neuron in self.dom_ach:
            return "Acetylcholine"
        elif neuron in self.dom_gaba:
            return "GABA"
        else:
            nt = GENERIC_CHEM_SYN
            if neuron in self.alt_glu:
                nt += "_Glutamate"
            if neuron in self.alt_ach:
                nt += "_Acetylcholine"
            if neuron in self.dom_gaba:
                nt += "_GABA"

            return nt

    def read_data(self):
        conns = []
        gj = self.atlas.get_gap_junctions()
        cs = self.atlas.get_chemical_synapses()

        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

                gji = gj[apost, apre]
                num = gji[0]
                if num > 0:
                    # print("Gap junc (%s (%i) -> %s (%i): %s"%(pre, apre, post, apost, gji))
                    synclass = GENERIC_ELEC_SYN
                    syntype = "GapJunction"
                    conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
                    connection = True

                csi = cs[apost, apre]
                num = csi[0]
                if num > 0:
                    # print("Chem syn (%s (%i) -> %s (%i): %s"%(pre, apre, post, apost, gji))
                    synclass = self.determine_nt(pre)
                    syntype = "Chemical"
                    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)

        """if include_nonconnected_cells:
            return self.all_cells, conns
        else:"""

        return connected_cells, conns

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