How to use the neuron.h.setpointer function in NEURON

To help you get started, we’ve selected a few NEURON examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Neurosim-lab / netpyne / netpyne / cell / compartCell.py View on Github external
# diff in yvals, scaled against the pos np.array. y_long as in longitudinal
        y_scale = (self.__dipoleGetSecLength(secName) * sec['hObj'].L) * pos
        # y_long = (h.y3d(1, sec=sect) - h.y3d(0, sec=sect)) * pos
        # diff values calculate length between successive section points
        y_diff = np.diff(y_scale)
        for i in range(len(loc)):
            # assign the ri value to the dipole
            sec['hObj'](loc[i]).dipole.ri = h.ri(loc[i], sec=sec['hObj'])
            # range variable 'dipole'
            # set pointers to previous segment's voltage, with boundary condition
            if i > 0:
                h.setpointer(sec['hObj'](loc[i-1])._ref_v, 'pv', sec['hObj'](loc[i]).dipole)
            else:
                h.setpointer(sec['hObj'](0)._ref_v, 'pv', sec['hObj'](loc[i]).dipole)
            # set aggregate pointers
            h.setpointer(dpp._ref_Qsum, 'Qsum', sec['hObj'](loc[i]).dipole)
            if self.tags['cellType'].startswith('L2'):
                h.setpointer(h._ref_dp_total_L2, 'Qtotal', sec['hObj'](loc[i]).dipole)
            elif self.tags['cellType'].startswith('L5'):
                h.setpointer(h._ref_dp_total_L5, 'Qtotal', sec['hObj'](loc[i]).dipole)
            # add ztan values
            sec['hObj'](loc[i]).dipole.ztan = y_diff[i]
        # set the pp dipole's ztan value to the last value from y_diff
        dpp.ztan = y_diff[-1]
github research-team / robot-dream / Nociception / cfiber.py View on Github external
diff.k = 0
            else:
                diff.k = 0.01
        else:
            diff = h.AtP_slow(compartment(0.5))
            diff.h = self.distances.get(compartment)
            diff.tx1 = time + 0 + (diff.h/1250)*1000
            diff.c0cleft = 100
        self.diffusions.update({diff: compartment})
        rec = h.p2x3(compartment(0.5))
        rec.gmax = g
        rec.Ev = 5
        # rec2 = h.p2x2(compartment(0.5))
        # rec2.gmax = g/2
        # rec2.Ev = -7
        h.setpointer(diff._ref_atp, 'patp', rec)
        # h.setpointer(diff._ref_atp, 'patp', rec2)
        self.recs.append(rec)
        self.diffs.append(diff)
        # self.recs.append(rec2)
github Neurosim-lab / netpyne / netpyne / cell / compartCell.py View on Github external
# insert Dipole point process (dipole_pp.mod)
        try: 
            sec['hDipole_pp'] = h.Dipole(1.0, sec = sec['hObj'])
        except:
            print('Error inserting Dipole point process')
            return -1
        dpp = sec['hDipole_pp']
        # assign internal resistance values to dipole point process (dpp)
        dpp.ri = h.ri(1, sec=sec['hObj'])
        # sets pointers in dipole mod file to the correct locations -- h.setpointer(ref, ptr, obj)
        h.setpointer(sec['hObj'](0.99)._ref_v, 'pv', dpp)
        if self.tags['cellType'].startswith('L2'):
            h.setpointer(h._ref_dp_total_L2, 'Qtotal', dpp)
        elif self.tags['cellType'].startswith('L5'):
            h.setpointer(h._ref_dp_total_L5, 'Qtotal', dpp)

        # gives INTERNAL segments of the section, non-endpoints
        # creating this because need multiple values simultaneously
        loc = np.array([seg.x for seg in sec['hObj']])
        # these are the positions, including 0 but not L
        pos = np.array([seg.x for seg in sec['hObj'].allseg()])
        # diff in yvals, scaled against the pos np.array. y_long as in longitudinal
        y_scale = (self.__dipoleGetSecLength(secName) * sec['hObj'].L) * pos
        # y_long = (h.y3d(1, sec=sect) - h.y3d(0, sec=sect)) * pos
        # diff values calculate length between successive section points
        y_diff = np.diff(y_scale)
        for i in range(len(loc)):
            # assign the ri value to the dipole
            sec['hObj'](loc[i]).dipole.ri = h.ri(loc[i], sec=sec['hObj'])
            # range variable 'dipole'
            # set pointers to previous segment's voltage, with boundary condition
github research-team / robot-dream / Nociception / cfiber.py View on Github external
diff.h = self.distances.get(compartment)
            diff.tx1 = time
            if self.numofmodel == 14:
                diff.a = 100
            else:
                diff.a = 0
            diff.Deff = 0.004
            diff.c0cleft = 3
        else:
            diff = h.slow_5HT(compartment(0.5))
            diff.h = self.distances.get(compartment)
            diff.tx1 = time + 0 + (diff.h/50)*1000
            diff.c0cleft = 3
        rec = h.r5ht3a(compartment(0.5))
        rec.gmax = g
        h.setpointer(diff._ref_serotonin, 'serotonin', rec)
        self.diffs.append(diff)
        self.recs.append(rec)      
    def build_subsets(self):
github Neurosim-lab / netpyne / netpyne / cell / compartCell.py View on Github external
sec['hObj'].insert('dipole')
        except:
            print('Error inserting dipole mechanism')
            return -1

        # insert Dipole point process (dipole_pp.mod)
        try: 
            sec['hDipole_pp'] = h.Dipole(1.0, sec = sec['hObj'])
        except:
            print('Error inserting Dipole point process')
            return -1
        dpp = sec['hDipole_pp']
        # assign internal resistance values to dipole point process (dpp)
        dpp.ri = h.ri(1, sec=sec['hObj'])
        # sets pointers in dipole mod file to the correct locations -- h.setpointer(ref, ptr, obj)
        h.setpointer(sec['hObj'](0.99)._ref_v, 'pv', dpp)
        if self.tags['cellType'].startswith('L2'):
            h.setpointer(h._ref_dp_total_L2, 'Qtotal', dpp)
        elif self.tags['cellType'].startswith('L5'):
            h.setpointer(h._ref_dp_total_L5, 'Qtotal', dpp)

        # gives INTERNAL segments of the section, non-endpoints
        # creating this because need multiple values simultaneously
        loc = np.array([seg.x for seg in sec['hObj']])
        # these are the positions, including 0 but not L
        pos = np.array([seg.x for seg in sec['hObj'].allseg()])
        # diff in yvals, scaled against the pos np.array. y_long as in longitudinal
        y_scale = (self.__dipoleGetSecLength(secName) * sec['hObj'].L) * pos
        # y_long = (h.y3d(1, sec=sect) - h.y3d(0, sec=sect)) * pos
        # diff values calculate length between successive section points
        y_diff = np.diff(y_scale)
        for i in range(len(loc)):
github neuronsimulator / nrn / share / examples / nrniv / nmodl / tstpnt1.py View on Github external
#h.setpointer(a(.5)._ref_v, 'p1', tp[0])
tp[0]._ref_p1 = a(.5)._ref_v
for i in range(1, 10):
  #h.setpointer(vec._ref_x[i], 'p1', tp[i])
  tp[i]._ref_p1 = vec._ref_x[i]

for i in range(0, 10):
  print (i, tp[i].p1, tp[i].f1())

tp[2].p1 = 25
print (vec[2], tp[2].p1)

z = h.t1()
import sys
try:
  h.setpointer(a(.5)._ref_v, 'p1', z)
except:
  print (sys.exc_info()[0], ': ', sys.exc_info()[1])

try:
  z._ref_p1 = a(.5)._ref_v
except:
  print (sys.exc_info()[0], ': ', sys.exc_info()[1])
github Neurosim-lab / netpyne / netpyne / cell / compartCell.py View on Github external
print('Error inserting dipole mechanism')
            return -1

        # insert Dipole point process (dipole_pp.mod)
        try: 
            sec['hDipole_pp'] = h.Dipole(1.0, sec = sec['hObj'])
        except:
            print('Error inserting Dipole point process')
            return -1
        dpp = sec['hDipole_pp']
        # assign internal resistance values to dipole point process (dpp)
        dpp.ri = h.ri(1, sec=sec['hObj'])
        # sets pointers in dipole mod file to the correct locations -- h.setpointer(ref, ptr, obj)
        h.setpointer(sec['hObj'](0.99)._ref_v, 'pv', dpp)
        if self.tags['cellType'].startswith('L2'):
            h.setpointer(h._ref_dp_total_L2, 'Qtotal', dpp)
        elif self.tags['cellType'].startswith('L5'):
            h.setpointer(h._ref_dp_total_L5, 'Qtotal', dpp)

        # gives INTERNAL segments of the section, non-endpoints
        # creating this because need multiple values simultaneously
        loc = np.array([seg.x for seg in sec['hObj']])
        # these are the positions, including 0 but not L
        pos = np.array([seg.x for seg in sec['hObj'].allseg()])
        # diff in yvals, scaled against the pos np.array. y_long as in longitudinal
        y_scale = (self.__dipoleGetSecLength(secName) * sec['hObj'].L) * pos
        # y_long = (h.y3d(1, sec=sect) - h.y3d(0, sec=sect)) * pos
        # diff values calculate length between successive section points
        y_diff = np.diff(y_scale)
        for i in range(len(loc)):
            # assign the ri value to the dipole
            sec['hObj'](loc[i]).dipole.ri = h.ri(loc[i], sec=sec['hObj'])
github Neurosim-lab / netpyne / netpyne / cell / compartCell.py View on Github external
# y_long = (h.y3d(1, sec=sect) - h.y3d(0, sec=sect)) * pos
        # diff values calculate length between successive section points
        y_diff = np.diff(y_scale)
        for i in range(len(loc)):
            # assign the ri value to the dipole
            sec['hObj'](loc[i]).dipole.ri = h.ri(loc[i], sec=sec['hObj'])
            # range variable 'dipole'
            # set pointers to previous segment's voltage, with boundary condition
            if i > 0:
                h.setpointer(sec['hObj'](loc[i-1])._ref_v, 'pv', sec['hObj'](loc[i]).dipole)
            else:
                h.setpointer(sec['hObj'](0)._ref_v, 'pv', sec['hObj'](loc[i]).dipole)
            # set aggregate pointers
            h.setpointer(dpp._ref_Qsum, 'Qsum', sec['hObj'](loc[i]).dipole)
            if self.tags['cellType'].startswith('L2'):
                h.setpointer(h._ref_dp_total_L2, 'Qtotal', sec['hObj'](loc[i]).dipole)
            elif self.tags['cellType'].startswith('L5'):
                h.setpointer(h._ref_dp_total_L5, 'Qtotal', sec['hObj'](loc[i]).dipole)
            # add ztan values
            sec['hObj'](loc[i]).dipole.ztan = y_diff[i]
        # set the pp dipole's ztan value to the last value from y_diff
        dpp.ztan = y_diff[-1]
github Neurosim-lab / netpyne / netpyne / cell / compartCell.py View on Github external
def _addConnPlasticity (self, params, sec, netcon, weightIndex):
        from .. import sim

        plasticity = params.get('plast')
        if plasticity and sim.cfg.createNEURONObj:
            try:
                plastMech = getattr(h, plasticity['mech'], None)(0, sec=sec['hSec'])  # create plasticity mechanism (eg. h.STDP)
                for plastParamName,plastParamValue in plasticity['params'].items():  # add params of the plasticity mechanism
                    setattr(plastMech, plastParamName, plastParamValue)
                if plasticity['mech'] == 'STDP':  # specific implementation steps required for the STDP mech
                    precon = sim.pc.gid_connect(params['preGid'], plastMech); precon.weight[0] = 1 # Send presynaptic spikes to the STDP adjuster
                    pstcon = sim.pc.gid_connect(self.gid, plastMech); pstcon.weight[0] = -1 # Send postsynaptic spikes to the STDP adjuster
                    h.setpointer(netcon._ref_weight[weightIndex], 'synweight', plastMech) # Associate the STDP adjuster with this weight
                    #self.conns[-1]['hPlastSection'] = plastSection
                    self.conns[-1]['hSTDP']         = plastMech
                    self.conns[-1]['hSTDPprecon']   = precon
                    self.conns[-1]['hSTDPpstcon']   = pstcon
                    self.conns[-1]['STDPdata']      = {'preGid':params['preGid'], 'postGid': self.gid, 'receptor': weightIndex} # Not used; FYI only; store here just so it's all in one place
                    if sim.cfg.verbose: print('  Added STDP plasticity to synaptic mechanism')
            except:
                print('Error: exception when adding plasticity using %s mechanism' % (plasticity['mech']))