Skip to content

network

Source code in navis/interfaces/neuron/network.py
628
629
630
631
632
633
634
635
636
637
class NetworkIdIndexer:
    def __init__(self, network):
        self.network = network

    def __getitem__(self, id):
        neurons = self.network._neurons_dict
        if utils.is_iterable(id):
            return [neurons[i] for i in id]
        else:
            return neurons[id]
Source code in navis/interfaces/neuron/network.py
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
class PointNeuron:
    def __init__(self, id, model, label=None, **props):
        self.process = model()
        self.id = id
        self.label = label
        for p, v in props.items():
            setattr(self.process, p, v)

        self.record_spikes()

    def __str__(self):
        return f'{type(self).__name__}<id={self.id},label={self.label}>'

    def __repr__(self):
        return self.__str__()

    def record_spikes(self, threshold=10):
        """Set up spike recording for this neuron."""
        self.spk_timings = neuron.h.Vector()
        self.sp_det = neuron.h.NetCon(self.process, None)
        self.sp_det.record(self.spk_timings)

    def record_state(self):
        """Set up recording of state for this neuron."""
        self.state = neuron.h.Vector()
        self.state.record(self.process._ref_m)

Set up spike recording for this neuron.

Source code in navis/interfaces/neuron/network.py
616
617
618
619
620
def record_spikes(self, threshold=10):
    """Set up spike recording for this neuron."""
    self.spk_timings = neuron.h.Vector()
    self.sp_det = neuron.h.NetCon(self.process, None)
    self.sp_det.record(self.spk_timings)

Set up recording of state for this neuron.

Source code in navis/interfaces/neuron/network.py
622
623
624
625
def record_state(self):
    """Set up recording of state for this neuron."""
    self.state = neuron.h.Vector()
    self.state.record(self.process._ref_m)

Note to self: it would best best if PointNetwork would not actually build the model until it's executed. That way we can run the entire simulation in a separate thread (or multiple cores).