コード例 #1
0
ファイル: virtualcell.py プロジェクト: sunzhe839/bmtk
 def set_stim(self, stim_prop, spike_train):
     """Gets the spike trains for each individual cell."""
     self._train_vec = h.Vector(spike_train.get_times(
         node_id=self.node_id))  #, population=self._population))
     vecstim = h.VecStim()
     vecstim.play(self._train_vec)
     self._hobj = vecstim
コード例 #2
0
    def __init__(self, cf=None, sr=None, simulator=None):
        """
        Parameters
        ----------
        cf : float (default: None)
            Required: the characteristic frequency for the SGC
        
        sr : int (default None)
            required : Selects the spontaneous rate group from the
            Zilany et al (2010) model. 1 = LSR, 2 = MSR, 3 = HSR
        
        simulator : 'cochlea' | 'matlab' | None (default None)
            Sets the simulator interface that will be used. All models
            currently use the Zilany et al. model, but the simulator can
            be run though a Python-interface directly to the Matlab code
            as publicy available, (simulator='matlab'), or can be run through
            Rudnicki & Hemmert's Python interface to the simulator's C code 
            (simulator='cochlea').
        
        """
        self._simulator = simulator
        SGC.__init__(self, cf, sr)
        self.vecstim = h.VecStim()

        # this causes the terminal to receive events from the VecStim:
        self.spike_source = self.vecstim

        # just an empty section for holding the terminal
        self.add_section(h.Section(), 'soma')
コード例 #3
0
    def __init__(self,
                 spike_train=None,
                 position=np.array([0, 0, 0]),
                 background=3.9,
                 cv=1,
                 whatami='glom'):
        self.whatami = whatami

        self.background = background

        self.position = position

        self.mfncpc = []

        self.record = {}
        if spike_train is not None:
            self.spk_vector = h.Vector()

            # Populate Vector
            for time in spike_train:
                self.spk_vector.append(float(time))
            self.spike = h.VecStim()
            self.spike.play(self.spk_vector)
        else:
            self.spike = h.NetStim(0.5)
            self.spike.start = -10
            self.spike.number = 1
            self.spike.interval = 1e9
        self.nc_spike = h.NetCon(self.spike, None)
        self.record['spk'] = h.Vector()
        self.nc_spike.record(self.record['spk'])
コード例 #4
0
    def create_stim(self, S, syns, weights):
        """Create vecstim and netcon objects for simulation.

        Parameters
        ----------
        S : ndarray
            presynaptic spike times
        syns : list
            neuron synapse objects
        weights : ndarray
            synaptic weights

        Returns
        -------
        t_vec_list : list
            spike time vectors
        stim_list : list
            vec_stim objects
        con_list : list
            netcon objects
        """
        t_vec_list = []
        stim_list = []
        con_list = []
        for k, (t_list, syn) in enumerate(zip(S, syns)):
            stim = h.VecStim()
            t_vec = h.Vector(t_list[~np.isinf(t_list)])
            stim.play(t_vec)
            t_vec_list.append(t_vec)
            stim_list.append(stim)
            con_list.append(h.NetCon(stim, syn, 0, 0, weights[k]))
        return t_vec_list, stim_list, con_list
コード例 #5
0
ファイル: staggered_input.py プロジェクト: subhacom/mbnet
def connect_independent_stimuli(spiketrains,
                                synlist,
                                threshold=-20,
                                delay=0,
                                weight=1):
    """Create a list of VecStim object with event times from spiketrains,
    and create NetCon objects to feed this to each synapse.

    spiketrains: list of arrays containing stimulus time for each entry in synlist

    synlist: list of synapses

    Returns list of NetCon objects, VecStim object and the list of Vectors
    containing stimulus times.

    """
    netcons = []
    stimtimes = []
    stimlist = []
    for st, syn in zip(spiketrains, synlist):
        stimvec = h.Vector()
        stimvec.append(*st)
        stimtimes.append(stimvec)
        vecstim = h.VecStim()
        vecstim.play(stimvec)
        stimlist.append(vecstim)
        netcons.append(h.NetCon(vecstim, syn, threshold, delay, weight))
    return netcons, stimlist, stimtimes
コード例 #6
0
    def connect_axon(self, axon):

        # configure ExpSyn synapse
        synapse = h.ExpSyn(1e-3, axon.allseclist)  #1e-3
        synapse.e = 10
        synapse.i = 0.2
        synapse.tau = 0.1

        # get spike train
        spikeTrain = self.spikeTrains[self.axonIndex]
        self.axonIndex += 1

        # configure input to synapse
        vecStim = h.VecStim()
        spikeVec = h.Vector(spikeTrain)
        # axon.spikeVec = h.Vector([1,2,3])
        vecStim.play(spikeVec)

        # connect synapse and VecStim input
        netCon = h.NetCon(vecStim, synapse)
        netCon.weight[0] = 1

        # add the variables to the axon instance in order to keep them alive
        # delete after simulation
        excitationMechanismVars = [
            synapse, vecStim, spikeVec, spikeTrain, netCon
        ]
        axon.append_ex_mech_vars(excitationMechanismVars)
コード例 #7
0
    def __init__(self, spike_train=None, position = np.array([0,0,0]),whatami ='mossy',record_all = 0):
        self.record_all = record_all
        self.spike_train = spike_train
        self.whatami = whatami
	
        self.position = position
        if spike_train is not None:
            self.spk_vector = h.Vector()
        
            # Populate Vector
            for time in spike_train:
                self.spk_vector.append(float(time))

            self.output = h.VecStim()
            self.output.play(self.spk_vector)
        else:
            self.output = h.NetStim(0.5)
            self.output.start = -10
            self.output.number = 0
            self.output.interval = 1e9
            
        self.record = {}
        self.nc_spike = h.NetCon(self.output,None)
        self.record['spk'] = h.Vector()
        self.nc_spike.record(self.record['spk'])
コード例 #8
0
ファイル: ga.py プロジェクト: Kobrs/TheCreatureProject
    def apply_stimuli(self, stim_dict, weight=0.5):
        """This function applies stimuli based on stim_dict parameters.
        :param stim_dict: key is target cell id and value is spike times list"""
        for tgt_cell_id, times in stim_dict.iteritems():
            # try:
            if tgt_cell_id in self.cells_dict.keys():
                tgt_cell = self.cells_dict[tgt_cell_id]
                # DEBUG: The following line causes slowdown!!!
                #        This isn't due to creation time though, rather to
                #        the effect it has on simulation itslef.
                syn = tgt_cell.create_synapses(1, return_syns=True)[0]

                stim_train = h.Vector(times)

                vplay = h.VecStim()  # NOTE: this requires compiled vecstim.mod
                vplay.play(stim_train)
                nc = h.NetCon(vplay, syn)
                nc.weight[0] = weight

                # Now note, that if I'm going to be re running simulation
                #   and reinitalize it each time, the time will reset and
                #   each time network will be stimulated by old stimuli.
                self.stim_conns.append((nc, syn))
                self.vecStims.append(vplay)
                self.stim_trains.append(stim_train)
コード例 #9
0
ファイル: feedback_loop.py プロジェクト: mccdqw/LUT_Prelim
    def initialize(self, sim):
        #####  Make sure to save spikes vector and vector stim object
        # Attach a NetCon/synapse on the high-level neuron(s) soma. We can use the NetCon.event(time) method to send
        # a spike to the synapse. Which, is a spike occurs, the high-level neuron will inhibit the low-level neuron.
        self._spikes = h.Vector()  # start off with empty input
        vec_stim = h.VecStim()
        vec_stim.play(self._spikes)
        self._vect_stim = vec_stim

        self._high_level_neurons = list(
            sim.net.get_node_set('high_level_neurons').gids())
        self._pag_neurons = list(sim.net.get_node_set('pag_neurons').gids())

        io.log_info('Found {} high level neurons'.format(
            len(self._high_level_neurons)))
        for gid in self._high_level_neurons:
            cell = sim.net.get_cell_gid(gid)
            self._spike_events[gid] = np.array([])

            # Create synapse
            # These values will determine how the high-level neuron behaves with the input
            syn = h.Exp2Syn(0.5, cell.hobj.soma[0])
            syn.e = 0.0
            syn.tau1 = 0.1
            syn.tau2 = 0.3
            self._synapses[gid] = syn

            nc = h.NetCon(self._vect_stim, syn)
            nc.threshold = sim.net.spike_threshold
            nc.weight[0] = 0.2
            nc.delay = 1.0
            self._netcons[gid] = nc

        io.log_info('Found {} PAG neurons'.format(len(self._pag_neurons)))
        for gid in self._pag_neurons:
            trg_cell = sim.net.get_cell_gid(
                gid)  # network._rank_node_ids['LUT'][51]
            self._spike_events[gid] = np.array([])

            syn = h.Exp2Syn(0.5, sec=trg_cell.hobj.soma[0])
            syn.e = 0.0
            syn.tau1 = 0.1
            syn.tau2 = 0.3
            self._synapses[gid] = syn

            nc = h.NetCon(self._vect_stim, syn)
            nc.threshold = sim.net.spike_threshold
            nc.weight[0] = 0.2
            nc.delay = 1.0
            self._netcons[gid] = nc

        # Attach another netcon to the low-level neuron(s) that will record
        self._low_level_neurons = list(
            sim.net.get_node_set('low_level_neurons').gids())
        io.log_info('Found {} low level neurons'.format(
            len(self._low_level_neurons)))

        self._set_spike_detector(sim)
        pc.barrier()
コード例 #10
0
ファイル: feedback_loop.py プロジェクト: MJC598/LUT_Prelim
    def initialize(self, sim):
        network = sim.net

        #####  Make sure to save spikes vector and vector stim object
        # Attach a NetCon/synapse on the high-level neuron(s) soma. We can use the NetCon.event(time) method to send
        # a spike to the synapse. Which, is a spike occurs, the high-level neuron will inhibit the low-level neuron.
        self._spikes = h.Vector(np.array([]))  # start off with empty input
        vec_stim = h.VecStim()
        vec_stim.play(self._spikes)
        self._vect_stim = vec_stim

        self._high_level_neurons = list(sim.net.get_node_set('high_level_neurons').gids())
        self._pag_neurons = list(sim.net.get_node_set('pag_neurons').gids())
        # self._pag_neurons = [i for i in np.arange(50,75)]

        for gid in self._high_level_neurons:
            cell = sim.net.get_cell_gid(gid)

            # Create synapse
            # These values will determine how the high-level neuron behaves with the input
            new_syn = h.Exp2Syn(0.5, cell.hobj.soma[0])
            new_syn.e = 0.0
            new_syn.tau1 = 0.1
            new_syn.tau2 = 0.3

            nc = h.NetCon(self._vect_stim, new_syn)
            ##nc = h.NetCon(vec_stim, new_syn)
            nc.weight[0] = 0.5
            nc.delay = 1.0

            self._synapses[gid] = new_syn
            self._netcons[gid] = nc

        io.log_info('Found {} PAG neurons'.format(len(self._pag_neurons)))
        for gid in self._pag_neurons:
            trg_cell = network.get_cell_gid(gid)  # network._rank_node_ids['LUT'][51]
            syn = h.Exp2Syn(0.5, sec=trg_cell.hobj.soma[0])
            syn.e = 0.0
            syn.tau1 = 0.1
            syn.tau2 = 0.3
            self._synapses[gid] = syn

            nc = h.NetCon(self._vect_stim, syn)
            nc.weight[0] = 0.5
            nc.delay = 1.0
            self._netcons[gid] = nc


        # Attach another netcon to the low-level neuron(s) that will record
        self._low_level_neurons = list(sim.net.get_node_set('low_level_neurons').gids())
        for gid in self._low_level_neurons:
            cell = sim.net.get_cell_gid(gid)
            # NOTE: If you set the segment to 0.5 it will interfere with the record_spikes module. Neuron won't let
            # us record from the same place multiple times, so for now just set to 0.0. TODO: read and save spikes in biosimulator.
            nc = h.NetCon(cell.hobj.soma[0](0.0)._ref_v, None, sec=cell.hobj.soma[0])
            self._netcons[gid] = nc

        self._set_spike_detector(sim)
コード例 #11
0
 def __init__(self, sid):
     self.s = h.VecStim()
     self.nvec = inspk[np.where(inspk[:, 1].astype(int) == sid), 0][0]
     self.vec = h.Vector(self.nvec.shape[0])
     self.vec.from_python(self.nvec)
     self.s.play(self.vec)
     self.recorder = h.NetCon(self.s, None)
     self.spk = h.Vector()
     self.recorder.record(self.spk)
コード例 #12
0
ファイル: run_bionet.py プロジェクト: tjbanks/MizzouREU
    def initialize(self, sim):
        # Attach a NetCon/synapse on the high-level neuron(s) soma. We can use the NetCon.event(time) method to send
        # a spike to the synapse. Which, is a spike occurs, the high-level neuron will inhibit the low-level neuron.
        spikes = h.Vector([])  # start off with empty input
        vec_stim = h.VecStim()
        vec_stim.play(spikes)
        self._high_level_neurons = list(
            sim.net.get_node_set('high_level_neurons').gids())
        self._eus_neurons = list(sim.net.get_node_set('eus_neurons').gids())

        for gid in self._high_level_neurons:
            cell = sim.net.get_cell_gid(gid)

            # Create synapse
            # These values will determine how the high-level neuron behaves with the input
            new_syn = h.Exp2Syn(0.7, cell.hobj.soma[0])
            new_syn.e = 0.0
            new_syn.tau1 = 1.0
            new_syn.tau2 = 3.0

            nc = h.NetCon(vec_stim, new_syn)
            nc.weight[0] = 0.5
            nc.delay = 1.0

            self._synapses[gid] = new_syn
            self._netcons[gid] = nc

        for gid in self._eus_neurons:
            cell = sim.net.get_cell_gid(gid)

            # Create synapse
            # These values will determine how the high-level neuron behaves with the input
            new_syn = h.Exp2Syn(0.9, cell.hobj.soma[0])
            new_syn.e = 0.0
            new_syn.tau1 = 1.0
            new_syn.tau2 = 3.0

            nc = h.NetCon(vec_stim, new_syn)
            nc.weight[0] = 0.5
            nc.delay = 1.0

            self._synapses[gid] = new_syn
            self._netcons[gid] = nc

        # Attach another netcon to the low-level neuron(s) that will record
        self._low_level_neurons = list(
            sim.net.get_node_set('low_level_neurons').gids())
        for gid in self._low_level_neurons:
            cell = sim.net.get_cell_gid(gid)
            # NOTE: If you set the segment to 0.5 it will interfere with the record_spikes module. Neuron won't let
            # us record from the same place multiple times, so for now just set to 0.0. TODO: read and save spikes in biosimulator.
            nc = h.NetCon(cell.hobj.soma[0](0.0)._ref_v,
                          None,
                          sec=cell.hobj.soma[0])
            self._netcons[gid] = nc

        self._set_spike_detector(sim)
コード例 #13
0
ファイル: stim.py プロジェクト: johnsonc/bmtk
    def set_stim(self, stim_prop, spike_train):
        #spike_trains_handle = input_prop["spike_trains_handle"]
        #self.spike_train = spike_trains_handle['%d/data' % self.stim_gid][:]

        self.train_vec = h.Vector(spike_train[:])
        vecstim = h.VecStim()
        vecstim.play(self.train_vec)
        
        self.hobj = vecstim
コード例 #14
0
ファイル: base.py プロジェクト: nsk6999/pype9
    def play(self, port_name, signal, properties=[]):
        """
        Injects current into the segment

        Parameters
        ----------
        port_name : str
            The name of the receive port to play the signal into
        signal : neo.AnalogSignal (current) | neo.SpikeTrain
            Signal to play into the port
        properties : list(nineml.Property)
            The connection properties of the event port
        """
        ext_is = self.build_component_class.annotations.get(
            (BUILD_TRANS, PYPE9_NS), EXTERNAL_CURRENTS).split(',')
        port = self.component_class.port(port_name)
        if isinstance(port, EventPort):
            if len(list(self.component_class.event_receive_ports)) > 1:
                raise Pype9Unsupported9MLException(
                    "Multiple event receive ports ('{}') are not currently "
                    "supported".format("', '".join([
                        p.name
                        for p in self.component_class.event_receive_ports
                    ])))
            if signal.t_start < 1.0:
                raise Pype9UsageError(
                    "Signal must start at or after 1 ms to handle delay in "
                    "neuron ({})".format(signal.t_start))
            times = numpy.asarray(signal.times.rescale(pq.ms)) - 1.0
            vstim = h.VecStim()
            vstim_times = h.Vector(times)
            vstim.play(vstim_times)
            vstim_con = h.NetCon(vstim, self._hoc, sec=self._sec)
            self._check_connection_properties(port_name, properties)
            if len(properties) > 1:
                raise NotImplementedError(
                    "Cannot handle more than one connection property per port")
            elif properties:
                vstim_con.weight[0] = self.unit_handler.scale_value(
                    properties[0].quantity)
            self._inputs['vstim'] = vstim
            self._input_auxs.extend((vstim_times, vstim_con))
        else:
            if port_name not in ext_is:
                raise Pype9Unsupported9MLException(
                    "Can only play into external current ports ('{}'), not "
                    "'{}' port.".format("', '".join(ext_is), port_name))
            iclamp = h.IClamp(0.5, sec=self._sec)
            iclamp.delay = 0.0
            iclamp.dur = 1e12
            iclamp.amp = 0.0
            iclamp_amps = h.Vector(pq.Quantity(signal, 'nA'))
            iclamp_times = h.Vector(signal.times.rescale(pq.ms))
            iclamp_amps.play(iclamp._ref_amp, iclamp_times)
            self._inputs['iclamp'] = iclamp
            self._input_auxs.extend((iclamp_amps, iclamp_times))
コード例 #15
0
ファイル: virtualcell.py プロジェクト: HDictus/bmtk
    def set_stim(self, stim_prop, spike_train):
        """Gets the spike trains for each individual cell."""
        spikes = spike_train.get_times(node_id=self.node_id)
        assert(np.all(spikes >= 0))
        spikes = np.sort(spikes)  # sort the spikes for NEURON

        self._train_vec = h.Vector(spikes)
        vecstim = h.VecStim()
        vecstim.play(self._train_vec)
        self._hobj = vecstim
コード例 #16
0
    def __init__(self, event_times):
        # Convert event times into nrn vector
        self.nrn_eventvec = h.Vector()
        self.nrn_eventvec.from_python(event_times)

        # load eventvec into VecStim object
        self.nrn_vecstim = h.VecStim()
        self.nrn_vecstim.play(self.nrn_eventvec)

        # create the cell and artificial NetCon
        self.nrn_netcon = h.NetCon(self.nrn_vecstim, None)
コード例 #17
0
    def add_stim(self, where_what, tstim, w, name='default'):
        """
        Create a synapse of a given type (Epx2Syn, NMDA, etc..) on a given
        section and activate at the time in tstim with a given intensity set by
        w. This is the where, what, when scheme. Tstim is determined by a
        vecstim object that needs to be compiled with the vecstim.mod

        Parameters
        ----------
        where_when: triple (str, float, str)
            (name of section, location between 0 and 1, type of synapse)
        name: str
            name of the synaptic object
        tstim: list
            different times at which the point process is activated
        w: float
            weight of the point process

        Comments
        --------
        IMPORTANT: This method requires the pre-compiling of vecstim.mod by
        NEURON.

        By default we insert a single Exp2Syn object. This can be moved in
        future version

        The sort command is here to make sure that tstim are in the right order.
        """
        # Select the location
        segment = self.sections[where_what[0]](where_what[1])
        # Define the type of point process to use
        meca = getattr(h,  where_what[2])
        self.syn[name] = meca(segment)
        # Try to change the time constant of the pt process
        if where_what[2] == "Exp2syn":
            self.syn[name].tau1 = 1
            self.syn[name].tau2 = 2

        if where_what[2] == "NmdaSynapse":
            self.syn[name].tau1 = 0.1
            self.syn[name].tau2 = 10

        # Convert tstim into a NEURON vector (to play in NEURON)
        self.stim[name] = h.Vector(np.sort(tstim))
        # Create play vectors to interface with NEURON
        self.vplay[name] = h.VecStim()
        # Connect vector to VecStim object to play them
        self.vplay[name].play(self.stim[name])
        # Build the netcon object to connect the stims and the synapses
        self.netcon[name] = h.NetCon(self.vplay[name],   self.syn[name])

        # Set the individual weights
        self.netcon[name].weight[0] = w
コード例 #18
0
 def __init__(self, ty, celltype, p_ext, gid):
     # VecStim setup
     self.eventvec = h.Vector()
     self.vs = h.VecStim()
     # self.p_unique = p_unique[type]
     self.p_ext = p_ext
     self.celltype = celltype
     self.ty = ty  # feed type
     self.gid = gid
     self.set_prng()  # sets seeds for random num generator
     # sets event times into self.eventvec and plays into self.vs (VecStim)
     self.set_event_times()
コード例 #19
0
    def __init__(self, node, population_name, bionetwork):
        super(BioCellSpontSyn, self).__init__(node, population_name=population_name, bionetwork=bionetwork)

        # Get the timestamp at which synapses
        self._syn_timestamps = bionetwork.spont_syns_times
        self._syn_timestamps = [self._syn_timestamps] if np.isscalar(self._syn_timestamps) else self._syn_timestamps
        self._spike_trains = h.Vector(self._syn_timestamps)
        self._vecstim = h.VecStim()
        self._vecstim.play(self._spike_trains)

        self._precell_filter = bionetwork.spont_syns_filter
        assert(isinstance(self._precell_filter, dict))
コード例 #20
0
def artificial_cell(event_times):
    # Convert event times into nrn vector
    nrn_eventvec = h.Vector()
    nrn_eventvec.from_python(event_times)

    # load eventvec into VecStim object
    nrn_vecstim = h.VecStim()
    nrn_vecstim.play(nrn_eventvec)

    # create the cell and artificial NetCon
    nrn_netcon = h.NetCon(nrn_vecstim, None)
    return nrn_netcon
コード例 #21
0
 def setSpikeTrain(self, syn_index, syn_weight, spike_times):
     # add spiketrain
     spks = np.array(spike_times) + self.t_calibrate
     spks_vec = h.Vector(spks.tolist())
     vecstim = h.VecStim()
     vecstim.play(spks_vec)
     netcon = h.NetCon(vecstim, self.syns[syn_index], 0, self.dt,
                       syn_weight)
     # store the objects
     self.vecs.append(spks_vec)
     self.vecstims.append(vecstim)
     self.netcons.append(netcon)
コード例 #22
0
ファイル: cell.py プロジェクト: noraabiakar/arbor-usc-collab
 def testSingleSyn(self, syn_type, layer, idx, t1, t2, weight):
     Input = h.VecStim()
     evec = h.Vector([200])
     Input.play(evec)
     self.synGroups[syn_type][layer][idx].tau1 = t1
     self.synGroups[syn_type][layer][idx].tau2 = t2
     if syn_type == 'GABA':
         self.synGroups[syn_type][layer][idx].e = -75
     else:
         self.synGroups[syn_type][layer][idx].e = -0
     self.syn_con = h.NetCon(Input, self.synGroups[syn_type][layer][idx])
     self.syn_con.delay = 0
     self.syn_con.weight[0] = weight
     self.syn_con.threshold = 10.0
コード例 #23
0
    def __init__(self,
                 post_pop,
                 t_pattern,
                 spat_pattern,
                 target_segs,
                 tau_1,
                 tau_facil,
                 U,
                 tau_rec,
                 e,
                 weight,
                 rec_cond=False):

        self.init_parameters = locals()
        post_pop.add_connection(self)
        synapses = []
        netcons = []
        t_pattern = list(t_pattern)  # nrn does not like np.ndarrays?
        target_cells = post_pop[spat_pattern]
        self.pre_pop = 'Implicit'
        self.post_pop = post_pop
        self.vecstim = h.VecStim()
        self.pattern_vec = h.Vector(t_pattern)
        self.vecstim.play(self.pattern_vec)
        conductances = []

        for curr_cell in target_cells:
            curr_seg_pool = curr_cell.get_segs_by_name(target_segs)
            curr_conductances = []
            for seg in curr_seg_pool:
                curr_syn = h.tmgsyn(seg(0.5))
                curr_syn.tau_1 = tau_1
                curr_syn.tau_facil = tau_facil
                curr_syn.U = U
                curr_syn.tau_rec = tau_rec
                curr_syn.e = e
                curr_netcon = h.NetCon(self.vecstim, curr_syn)
                curr_gvec = h.Vector()
                curr_gvec.record(curr_syn._ref_g)
                curr_conductances.append(curr_gvec)
                curr_netcon.weight[0] = weight
                netcons.append(curr_netcon)
                synapses.append(curr_syn)
            if rec_cond:
                conductances.append(curr_conductances)

        self.conductances = conductances
        self.netcons = netcons
        self.pre_cell_targets = np.array(spat_pattern)
        self.synapses = synapses
コード例 #24
0
 def __init__(self, feed_type, target_cell_type, params, gid):
     # VecStim setup
     self.nrn_eventvec = h.Vector()
     self.nrn_vecstim = h.VecStim()
     self.params = params
     # used to determine cell type-specific parameters for
     # (not used for 'common', such as for rhythmic alpha/beta input)
     self.cell_type = target_cell_type
     self.feed_type = feed_type
     self.gid = gid
     self.set_prng()  # sets seeds for random num generator
     # sets event times into self.nrn_eventvec (Vector)
     # and plays into self.nrn_vecstim (VecStim)
     self.set_event_times()
コード例 #25
0
ファイル: neuron_utils.py プロジェクト: iraikov/dentate
def mknetcon_vecstim(syn, delay=0.1, weight=0, source=None):
    """
    Creates a VecStim object to drive the provided synaptic point process, 
    and a network connection from the VecStim source to the synapse target.
    :param syn: synapse point process
    :param delay: float
    :param weight: float
    :return: :class:'h.NetCon', :class:'h.VecStim'
    """
    vs = h.VecStim()
    nc = h.NetCon(vs, syn)
    nc.weight[0] = weight
    nc.delay = delay
    return nc, vs
コード例 #26
0
def create_pn_output(spike_trains):
    """Create stimvec and vecstim for proxy of PN spikes"""
    global model_dict
    cfg.logger.info('Started creating PN output vecstims and stimvecs')
    stimvecs = []
    vecstims = []
    for st in spike_trains:
        stimvecs.append(h.Vector(st))
        vecstims.append(h.VecStim())
        vecstims[-1].play(stimvecs[-1])
    model_dict['vecstim'] = vecstims
    model_dict['stimvec'] = stimvecs
    cfg.logger.info('Finished creating PN output vecstims and stimvecs')
    return stimvecs, vecstims
コード例 #27
0
    def add_ExpSyn(self, section='soma', position=0.5, name='default', tstim=[50], w=.001):
        """
        Create/replace an Expsyn synapse on a given section which is active at the time in tstim

        Comments
        --------
        The sort command is here to make sure that tstim are in the right order. This method
        requires the pre-compiling of vecstim.mod by NEURON.

        """
        self.syn[name] = h.ExpSyn(self.cell.__getattribute__(section)(position))
        self.stim[name] = h.Vector(np.sort(tstim)) # Converting tstim into a NEURON vector (to play in NEURON)
        self.vplay[name] = h.VecStim() # Creating play vectors to interface with NEURON
        self.vplay[name].play(self.stim[name])  # Connecting vector to VecStim object to play them
        self.netcon[name] = h.NetCon(self.vplay[name], self.syn[name]) # Building the netcon object to connect the stims and the synapses
        self.netcon[name].weight[0] = w # Setting the individual weights
コード例 #28
0
    def __init__(self, event_times, threshold, gid=None):
        # Convert event times into nrn vector
        self.nrn_eventvec = h.Vector()
        self.nrn_eventvec.from_python(event_times)

        # load eventvec into VecStim object
        self.nrn_vecstim = h.VecStim()
        self.nrn_vecstim.play(self.nrn_eventvec)

        # create the cell and artificial NetCon
        self.nrn_netcon = h.NetCon(self.nrn_vecstim, None)
        self.nrn_netcon.threshold = threshold

        self._gid = None
        if gid is not None:
            self.gid = gid  # use setter method to check input argument gid
コード例 #29
0
def generate_stimulus(single_cell, attachment_dend, times, weight,
                      n_dend_attach):
    times = h.Vector(times)  #eventvec move from seconds to ms
    single_cell[0].tlist.append(times)
    inputs = h.VecStim()  #presyn
    inputs.play(times)
    single_cell[0].vslist.append(inputs)

    for i in np.arange(n_dend_attach):  #create synapses
        synapse = h.ExpSyn(single_cell[0].dend[int(attachment_dend[i])](0.5))
        synapse.tau = 2
        single_cell[0].synlist.append(synapse)
        ncstim = h.NetCon(inputs, synapse)
        ncstim.weight[0] = weight
        ncstim.threshold = -32.4
        ncstim.delay = 1
        single_cell[0].nclist.append(ncstim)

    return single_cell
コード例 #30
0
    def create_VecStim(self, t_vec, synapse, weight):
        """
        Creates a vector stream of events for given synapse.

        Parameters
        ----------
        t_vec : numpy.ndarray
            the time vector
        synapse : Synapse
            synapse
        weight : float
            the stimulus weight
        """
        vec = h.Vector(t_vec)
        vec_stim = h.VecStim()
        vec_stim.play(vec)
        self.vec_stims.append(vec_stim)
        nc = h.NetCon(vec_stim, synapse.synapse, 0, 0, weight)
        nc.record(synapse.input_spikes)
        self.net_cons.append(nc)