Skip to content

ConnectomeView

NodeSet

Set of nodes (can be single cells or lists of cells) to use in a View. Can specify the color, shape, position or size to use in graphical depictions.

Source code in cect/ConnectomeView.py
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
class NodeSet:
    """Set of nodes (can be single cells or lists of cells) to use in a ``View``. Can specify the `color`, `shape`, `position` or `size` to use in graphical depictions."""

    def __init__(self, name, cells, color=None, shape=None, position=None, size=None):
        self.name = name
        self.color = color
        self.cells = cells
        self.shape = shape
        self.position = position
        self.size = size

    def is_one_cell(self):
        return len(self.cells) == 1 and self.name == self.cells[0]

    def __repr__(self):
        info = "NodeSet: %s\t(" % self.name
        if self.color is not None:
            info += "%s " % self.color
        if self.shape is not None:
            info += "%s " % self.shape
        if self.position is not None:
            info += "%s " % (str(self.position))
        info += "\t%s" % self.cells

        return info

View

A view of a ConnectomeDataset specifying subsets of cells (or lists of cells) as NodeSets, e.g. can be used to just show the connections between the pharyngeal neurons in a whole connectome dataset, or to group the sensory neurons, interneuron, etc. together.

Source code in cect/ConnectomeView.py
 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
class View:
    """A view of a ``ConnectomeDataset`` specifying subsets of cells (or lists of cells) as ``NodeSet``s, e.g. can be used to just show the connections between the pharyngeal neurons in a whole connectome dataset, or to group the sensory neurons, interneuron, etc. together."""

    def __init__(
        self,
        id,
        name,
        description,
        node_sets,
        synclass_sets={},
        colormap=DEFAULT_COLORMAP,
        only_show_existing_nodes=False,
    ):
        self.id = id
        self.name = name
        self.description = description
        self.node_sets = node_sets
        self.synclass_sets = synclass_sets
        self.colormap = colormap
        self.only_show_existing_nodes = only_show_existing_nodes

    def __repr__(self):
        info = "ConnectomeView: %s (%s)" % (
            self.name,
            self.id,
        )
        if self.description is not None:
            info += "\n  %s" % self.description
        for n in self.node_sets:
            info += "\n    %s" % n
        return info

    def has_color(self):
        for ns in self.node_sets:
            if ns.color is not None:
                return True
        return False

    def has_multicell_nodes(self):
        for ns in self.node_sets:
            if not ns.is_one_cell():
                return True
        return False

    def get_node_set(self, node_set_name):
        for ns in self.node_sets:
            if ns.name == node_set_name:
                return ns
        return None

    def get_index_of_cell(self, cell):
        for i in range(len(self.node_sets)):
            if cell in self.node_sets[i].cells:
                return i
        return -1