Exemplo n.º 1
0
def addRxD (self, nthreads=None):
    """
    Function for/to <short description of `netpyne.network.netrxd.addRxD`>

    Parameters
    ----------
    self : <type>
        <Short description of self>
        **Default:** *required*


    """


    from .. import sim

    if len(self.params.rxdParams):
        try:
            global rxd
            from neuron import crxd as rxd 
            sim.net.rxd = {'species': {}, 'regions': {}}  # dictionary for rxd  
            if nthreads:
                rxd.nthread(nthreads)
                print('Using %d threads for RxD' % (nthreads))
        except:
            print('cRxD module not available')
            return -1
    else:
        return -1


    # Instantiate network connections based on the connectivity rules defined in params
    sim.timing('start', 'rxdTime')
    if sim.rank==0:
        print('Adding RxD...')

    # make copy of Python structure
    #if sim.cfg.createPyStruct: -- don't make conditional since need to have Python structure
    sim.net.rxd = copy.deepcopy(sim.net.params.rxdParams)

    # add NEURON objects
    if sim.cfg.createNEURONObj:
        rxdParams = sim.net.params.rxdParams
        if 'regions' in rxdParams:
            self._addRegions(rxdParams['regions'])
        if 'extracellular' in rxdParams:
            #self._addExtracellular(rxdParams['extracellular'])
            self._addExtracellularRegion('extracellular', rxdParams['extracellular'])
        if 'species' in rxdParams:
            self._addSpecies(rxdParams['species'])
        if 'states' in rxdParams:
            self._addStates(rxdParams['states'])
        if 'reactions' in rxdParams:
            self._addReactions(rxdParams['reactions'])
        if 'parameters' in rxdParams:
            self._addParameters(rxdParams['parameters'])
        if 'multicompartmentReactions' in rxdParams:
            self._addReactions(rxdParams['multicompartmentReactions'], multicompartment=True)
        if 'rates' in rxdParams:
            self._addRates(rxdParams['rates'])

    sim.pc.barrier()
    sim.timing('stop', 'rxdTime')
    if sim.rank == 0 and sim.cfg.timing: print(('  Done; RxD setup time = %0.2f s.' % sim.timingData['rxdTime']))

    return sim.net.rxd
Exemplo n.º 2
0
from neuron import gui
'''

    Oriens-lacunosum moleculare (OLM) cells are a major subclass of hippocampal interneurons 
    involved in controlling synaptic plasticity in Shaffer collateral synapses 
    and electrogenesis in pyramidal cell (PC) dendrites. 

see more in here: https://www.frontiersin.org/articles/10.3389/fncel.2015.00201/full

for run : mpiexec -n 1 nrniv -mpi -python OLM_cell.py 
'''

pc = h.ParallelContext()
pcid = pc.id()
nhost = pc.nhost()
rxd.nthread()


rxd.options.enable.extracellular = True

h.load_file('stdrun.hoc')
h.celsius = 37
numpy.random.seed(6324555+pcid)

outdir = os.path.abspath('tests/305')


k_na_dir = os.path.abspath(os.path.join(outdir, 'K_NA'))
nmh_dir = os.path.abspath(os.path.join(outdir, 'n_m_h'))

if not os.path.exists(k_na_dir):
diff_constant = 1
h.cvode_active(True)
r = rxd.Region(h.allsec(), dx=0.25)

rxd.set_solve_type([dend1], dimension=3)

ca = rxd.Species(
    r,
    d=diff_constant,
    atolscale=0.1,
    initial=lambda node: 1 if (0.8 < node.x and node.segment in dend1) or
    (node.x < 0.2 and node.segment in dend2) else 0,
)
bistable_reaction = rxd.Rate(ca, -ca * (1 - ca) * (0.01 - ca))
h.finitialize()

for i in range(2):
    h.fadvance()
rxd.nthread(2)
for i in range(2, 4):
    h.fadvance()
rxd.nthread(3)
for i in range(4, 6):
    h.fadvance()
rxd.nthread(4)
for i in range(6, 8):
    h.fadvance()
rxd.nthread(1)
for i in range(8, 11):
    h.fadvance()
Exemplo n.º 4
0
                        type=str,
                        help='a directory to save the figures and data')
    args = parser.parse_args()
except:
    os._exit(1)

outdir = os.path.abspath(args.dir)
if pcid == 0 and not os.path.exists(outdir):
    try:
        os.makedirs(outdir)
    except:
        print("Unable to create the directory %r for the data and figures" %
              outdir)
        os._exit(1)

rxd.nthread(4)  # set the number of rxd threads
rxd.options.enable.extracellular = True  # enable extracellular rxd

h.load_file('stdrun.hoc')
h.celsius = 37

numpy.random.seed(6324555 + pcid)  # use a difference seed for each process

# simulation parameters
Lx, Ly, Lz = 1000, 1000, 1000  # size of the extracellular space mu m^3
Kceil = 15.0  # threshold used to determine wave speed
Ncell = int(9e4 * (Lx * Ly * Lz * 1e-9))  # number of neurons (90'000 per mm^3)
Nrec = 1000

somaR = 11.0  # soma radius
dendR = 1.4  # dendrite radius