예제 #1
0
    def _clip_pair(self):

        handlers = self._cell_pair.handlers
        assert(all(handlers))
        gids = self._cell_pair.gids
        morphologies = self._cell_pair.morphologies

        handlers[0].apply(_NeuronClipping().clipAll().unclipEfferentBranches(
            gids[0], morphologies[0], self._synapses))
        handlers[1].apply(_NeuronClipping().clipAll().unclipAfferentBranches(
            gids[1], morphologies[1], self._synapses))
예제 #2
0
    def _pick_first_cell(self, gid):

        to_pick = self._cell_to_pick
        def other(cell_to_pick):
            return 1 - cell_to_pick

        neurons = self._scene.objects[0]

        # Loading synapses
        circuit = self._scene.circuit
        if to_pick == self.POSTSYNAPTIC_CELL:
            synapses = circuit.afferent_synapses([gid])
        else:
            synapses = circuit.efferent_synapses([gid])
        self._synapses = synapses

        # Hiding all the cells
        neurons.attributes.mode = _rtneuron.RepresentationMode.NO_DISPLAY
        neurons.update()

        # Highlighting the cell picked and displaying it in detailed mode.
        selected = neurons.query([gid])
        selected.attributes.mode = \
            _rtneuron.RepresentationMode.WHOLE_NEURON
        selected.attributes.color_scheme = _rtneuron.ColorScheme.SOLID
        selected.attributes.primary_color = self._cell_colors[to_pick]
        selected.update()
        # Make sure the cell is unclipped at this point.
        selected.apply(_NeuronClipping().unclipAll())

        # Finding the connected cells and grouping the synapses per connection.
        if to_pick == self.PRESYNAPTIC_CELL:
            connected = synapses.post_gids()
        else:
            connected = synapses.pre_gids()
        connected = _np.unique(connected)

        connections = dict()

        for i in connected:
            pre = [gid if to_pick == self.PRESYNAPTIC_CELL else int(i)]
            post = [int(i) if to_pick == self.PRESYNAPTIC_CELL else gid]
            connections[i] = circuit.projected_synapses(pre, post)

        # Setting the mask for making only the connected cells selectable.
        mask = _np.setdiff1d(neurons.object, connected)
        self._base_selection_mask = mask
        connected = neurons.query(connected)

        # Adding one synapes set per connection. Doing this instead
        # of adding a single set makes it easier to apply a different color
        # to each synapse subset.
        functors = [_rtneuron.Scene.addEfferentSynapses,
                    _rtneuron.Scene.addAfferentSynapses]
        attributes = _rtneuron.AttributeMap()
        attributes.radius = self._synapse_radius
        self._synapse_handlers = dict()
        _rtneuron.engine.pause()
        for key, synapses in connections.items():
            self._synapse_handlers[key] = \
                    functors[to_pick](self._scene, synapses, attributes)
        _rtneuron.engine.resume()

        # Applying the coloring based on the user selection
        self._coloring_handler.set_target_cells(
            connected, self._cell_colors[other(to_pick)],
            visible=self._show_connected_cells)
        self._coloring_handler.set_target_synapses(
            self._synapse_handlers, self._synapse_colors[to_pick])
        self._coloring_handler.colorize()

        # Updating state variables
        self._cell_pair.handlers[to_pick] = selected
        self._cell_pair.gids[to_pick] = gid
        self._connected_cells = connected
        self._cell_to_pick = other(to_pick)
        self._update_connection_info.emit()
        self._connected_cells_hideable.emit(True)

        # Setting the new home position for the view
        position = list(map(float, circuit.positions([gid])[0]))
        view = _rtneuron.engine.views[0]
        view.cameraManipulator.setHomePosition(
            view.camera.getView()[0], position, [0, 1, 0])
예제 #3
0
 def _unclip_pair(self):
     for handler in self._cell_pair.handlers:
         handler.apply(_NeuronClipping().unclipAll())