def addNetStim (self, params, stimContainer=None): from .. import sim if not stimContainer: self.stims.append(Dict(params.copy())) # add new stim to Cell object stimContainer = self.stims[-1] if sim.cfg.verbose: print((' Created %s NetStim for cell gid=%d'% (params['source'], self.gid))) if sim.cfg.createNEURONObj: rand = h.Random() stimContainer['hRandom'] = rand # add netcon object to dict in conns list if isinstance(params['rate'], str): if params['rate'] == 'variable': try: netstim = h.NSLOC() netstim.interval = 0.1**-1*1e3 # inverse of the frequency and then convert from Hz^-1 to ms (set very low) netstim.noise = params['noise'] except: print('Error: tried to create variable rate NetStim but NSLOC mechanism not available') else: print('Error: Unknown stimulation rate type: %s'%(h.params['rate'])) else: netstim = h.NetStim() netstim.interval = params['rate']**-1*1e3 # inverse of the frequency and then convert from Hz^-1 to ms netstim.noise = params['noise'] # note: random number generator initialized via Random123() from sim.preRun() netstim.start = params['start'] netstim.number = params['number'] stimContainer['hNetStim'] = netstim # add netstim object to dict in stim list return stimContainer['hNetStim']
def createcell(cellid, interval, number, start, noise): from neuron import h # Open NEURON cell = h.NSLOC() # Create a new NSLOC unit cell.interval = interval cell.number = number cell.start = start cell.noise = noise #cell.type = celltype # Set cell celltype (used for setting celltype-specific dynamics) cell.id = cellid # Cell ID for keeping track which cell this is return cell