Exemplo n.º 1
0
def make_cable_cell(gid):
    b = arbor.flat_cell_builder()

    # Soma with radius 6 μm.
    s  = b.add_sphere(6, "soma")
    # Single dendrite of length 100 μm and radius 2 μm attached to soma.
    b1 = b.add_cable(parent=s, length=100, radius=2, name="dend", ncomp=1)
    # Attach two dendrites of length 50 μm to the end of the first dendrite.
    # Radius tapers from 2 to 0.5 μm over the length of the dendrite.
    b2 = b.add_cable(parent=b1, length=50, radius=(2,0.5), name="dend", ncomp=1)
    # Constant radius of 1 μm over the length of the dendrite.
    b3 = b.add_cable(parent=b1, length=50, radius=1, name="dend", ncomp=1)

    # Mark location for synapse at the midpoint of branch 1 (the first dendrite).
    b.add_label('synapse_site', '(location 1 0.5)')
    # Mark the root of the tree.
    b.add_label('root', '(root)')

    cell = b.build()

    # Put hh dynamics on soma, and passive properties on the dendrites.
    cell.paint('soma', 'hh')
    cell.paint('dend', 'pas')
    # Attach a single synapse.
    cell.place('synapse_site', 'expsyn')
    # Attach a spike detector with threshold of -10 mV.
    cell.place('root', arbor.spike_detector(-10))

    return cell
Exemplo n.º 2
0
    def cell_description(self, gid):
        tree = arbor.segment_tree()
        tree.append(arbor.mnpos,
                    arbor.mpoint(-3, 0, 0, 3),
                    arbor.mpoint(3, 0, 0, 3),
                    tag=1)

        labels = arbor.label_dict({
            'soma': '(tag 1)',
            'center': '(location 0 0.5)'
        })

        decor = arbor.decor()
        decor.set_property(Vm=-40)
        decor.paint('(all)', arbor.density('hh'))

        decor.place('"center"', arbor.spike_detector(-10), "detector")
        decor.place('"center"', arbor.synapse('expsyn'), "synapse")

        mech = arbor.mechanism('expsyn_stdp')
        mech.set("max_weight", 1.)
        syn = arbor.synapse(mech)

        decor.place('"center"', syn, "stpd_synapse")

        cell = arbor.cable_cell(tree, labels, decor)

        return cell
Exemplo n.º 3
0
def make_cable_cell(gid):
    # (1) Build a segment tree
    tree = arbor.segment_tree()

    # Soma (tag=1) with radius 6 μm, modelled as cylinder of length 2*radius
    s = tree.append(arbor.mnpos,
                    arbor.mpoint(-12, 0, 0, 6),
                    arbor.mpoint(0, 0, 0, 6),
                    tag=1)

    # Single dendrite (tag=3) of length 50 μm and radius 2 μm attached to soma.
    b0 = tree.append(s,
                     arbor.mpoint(0, 0, 0, 2),
                     arbor.mpoint(50, 0, 0, 2),
                     tag=3)

    # Attach two dendrites (tag=3) of length 50 μm to the end of the first dendrite.
    # Radius tapers from 2 to 0.5 μm over the length of the dendrite.
    b1 = tree.append(b0,
                     arbor.mpoint(50, 0, 0, 2),
                     arbor.mpoint(50 + 50 / sqrt(2), 50 / sqrt(2), 0, 0.5),
                     tag=3)
    # Constant radius of 1 μm over the length of the dendrite.
    b2 = tree.append(b0,
                     arbor.mpoint(50, 0, 0, 1),
                     arbor.mpoint(50 + 50 / sqrt(2), -50 / sqrt(2), 0, 1),
                     tag=3)

    # Associate labels to tags
    labels = arbor.label_dict()
    labels['soma'] = '(tag 1)'
    labels['dend'] = '(tag 3)'

    # (2) Mark location for synapse at the midpoint of branch 1 (the first dendrite).
    labels['synapse_site'] = '(location 1 0.5)'
    labels['synapse_site2'] = '(location 1 0.5)'
    # Mark the root of the tree.
    labels['root'] = '(root)'

    # (3) Create a decor and a cable_cell
    decor = arbor.decor()

    # Put hh dynamics on soma, and passive properties on the dendrites.
    decor.paint('"soma"', 'hh')
    decor.paint('"dend"', 'pas')

    # (4) Attach a single synapse.
    decor.place('"synapse_site"', 'expsyn')
    decor.place('"synapse_site2"', 'expsyn')

    # Attach a spike detector with threshold of -10 mV.
    decor.place('"root"', arbor.spike_detector(-10))

    cell = arbor.cable_cell(tree, labels, decor)

    return cell
Exemplo n.º 4
0
def make_cable_cell(gid):

    # Build a segment tree
    tree = arbor.segment_tree()

    # Soma with radius 5 μm and length 2 * radius = 10 μm, (tag = 1)
    s = tree.append(arbor.mnpos,
                    arbor.mpoint(-10, 0, 0, 5),
                    arbor.mpoint(0, 0, 0, 5),
                    tag=1)

    # Single dendrite with radius 2 μm and length 40 μm, (tag = 2)
    b = tree.append(s,
                    arbor.mpoint(0, 0, 0, 2),
                    arbor.mpoint(40, 0, 0, 2),
                    tag=2)

    # Label dictionary for cell components
    labels = arbor.label_dict()
    labels['soma'] = '(tag 1)'
    labels['dend'] = '(tag 2)'

    # Mark location for synapse site at midpoint of dendrite (branch 0 = soma + dendrite)
    labels['synapse_site'] = '(location 0 0.6)'

    # Gap junction site at connection point of soma and dendrite
    labels['gj_site'] = '(location 0 0.2)'

    # Label root of the tree
    labels['root'] = '(root)'

    # Paint dynamics onto the cell, hh on soma and passive properties on dendrite
    decor = arbor.decor()
    decor.paint('"soma"', arbor.density("hh"))
    decor.paint('"dend"', arbor.density("pas"))

    # Attach one synapse and gap junction each on their labeled sites
    decor.place('"synapse_site"', arbor.synapse('expsyn'), 'syn')
    decor.place('"gj_site"', arbor.junction('gj'), 'gj')

    # Attach spike detector to cell root
    decor.place('"root"', arbor.spike_detector(-10), 'detector')

    cell = arbor.cable_cell(tree, labels, decor)

    return cell
Exemplo n.º 5
0
def cable_cell():
    # (1) Create a morphology with a single (cylindrical) segment of length=diameter=6 μm
    tree = arbor.segment_tree()
    tree.append(
        arbor.mnpos,
        arbor.mpoint(-3, 0, 0, 3),
        arbor.mpoint(3, 0, 0, 3),
        tag=1,
    )

    # (2) Define the soma and its midpoint
    labels = arbor.label_dict({'soma':   '(tag 1)',
                               'midpoint': '(location 0 0.5)'})

    # (3) Create cell and set properties
    decor = arbor.decor()
    decor.set_property(Vm=-40)
    decor.paint('"soma"', arbor.density('hh'))
    decor.place('"midpoint"', arbor.iclamp( 10, 2, 0.8), "iclamp")
    decor.place('"midpoint"', arbor.spike_detector(-10), "detector")
    return arbor.cable_cell(tree, labels, decor)
Exemplo n.º 6
0
def create_arbor_cell(cell, nl_network, gid):

    if cell.arbor_cell=='cable_cell':

        default_tree = arbor.segment_tree()
        radius = evaluate(cell.parameters['radius'], nl_network.parameters) if 'radius' in cell.parameters else 3

        default_tree.append(arbor.mnpos, arbor.mpoint(-1*radius, 0, 0, radius), arbor.mpoint(radius, 0, 0, radius), tag=1)

        labels = arbor.label_dict({'soma':   '(tag 1)',
                                   'center': '(location 0 0.5)'})

        labels['root'] = '(root)'

        decor = arbor.decor()

        v_init = evaluate(cell.parameters['v_init'], nl_network.parameters) if 'v_init' in cell.parameters else -70
        decor.set_property(Vm=v_init)

        decor.paint('"soma"', cell.parameters['mechanism'])

        if gid==0:
            ic = arbor.iclamp( nl_network.parameters['input_del'], nl_network.parameters['input_dur'], nl_network.parameters['input_amp'])
            print_v("Stim: %s"%ic)
            decor.place('"center"', ic)

        decor.place('"center"', arbor.spike_detector(-10))


        # (2) Mark location for synapse at the midpoint of branch 1 (the first dendrite).
        labels['synapse_site'] = '(location 0 0.5)'
        # (4) Attach a single synapse.
        decor.place('"synapse_site"', 'expsyn')

        default_cell = arbor.cable_cell(default_tree, labels, decor)

        print_v("Created a new cell for gid %i: %s"%(gid,cell))
        print_v("%s"%(default_cell))

        return default_cell
Exemplo n.º 7
0
# (1) Create a morphology with a single (cylindrical) segment of length=diameter=6 μm
tree = arbor.segment_tree()
tree.append(arbor.mnpos,
            arbor.mpoint(-3, 0, 0, 3),
            arbor.mpoint(3, 0, 0, 3),
            tag=1)

# (2) Define the soma and its midpoint
labels = arbor.label_dict({'soma': '(tag 1)', 'midpoint': '(location 0 0.5)'})

# (3) Create cell and set properties
decor = arbor.decor()
decor.set_property(Vm=-40)
decor.paint('"soma"', 'hh')
decor.place('"midpoint"', arbor.iclamp(10, 2, 0.8))
decor.place('"midpoint"', arbor.spike_detector(-10))

# (4) Create cell and the single cell model based on it
cell = arbor.cable_cell(tree, labels, decor)

# (5) Make single cell model.
m = arbor.single_cell_model(cell)

# (6) Attach voltage probe sampling at 10 kHz (every 0.1 ms).
m.probe('voltage', '"midpoint"', frequency=10000)

# (7) Run simulation for 30 ms of simulated activity.
m.run(tfinal=30)

# (8) Print spike times.
if len(m.spikes) > 0:
Exemplo n.º 8
0
decor.set_ion('ca', method=mech('nernst/x=ca'))
#decor.set_ion('ca', method='nernst/x=ca')
# hh mechanism on the soma and axon.
decor.paint('"soma"', 'hh')
decor.paint('"axon"', 'hh')
# pas mechanism the dendrites.
decor.paint('"dend"', 'pas')
# Increase resistivity on dendrites.
decor.paint('"dend"', rL=500)
# Attach stimuli that inject 4 nA current for 1 ms, starting at 3 and 8 ms.
decor.place('"root"', arbor.iclamp(10, 1, current=5), "iclamp0")
decor.place('"stim_site"', arbor.iclamp(3, 1, current=0.5), "iclamp1")
decor.place('"stim_site"', arbor.iclamp(10, 1, current=0.5), "iclamp2")
decor.place('"stim_site"', arbor.iclamp(8, 1, current=4), "iclamp3")
# Detect spikes at the soma with a voltage threshold of -10 mV.
decor.place('"axon_end"', arbor.spike_detector(-10), "detector")

# Create the policy used to discretise the cell into CVs.
# Use a single CV for the soma, and CVs of maximum length 1 μm elsewhere.
soma_policy = arbor.cv_policy_single('"soma"')
dflt_policy = arbor.cv_policy_max_extent(1.0)
policy = dflt_policy | soma_policy
decor.discretization(policy)

# Combine morphology with region and locset definitions to make a cable cell.
cell = arbor.cable_cell(morpho, labels, decor)

print(cell.locations('axon_end'))

# Make single cell model.
m = arbor.single_cell_model(cell)
Exemplo n.º 9
0
# Set initial membrane potential everywhere on the cell to -40 mV.
cell.set_properties(Vm=-40)
# Put hh dynamics on soma, and passive properties on the dendrites.
cell.paint('"soma"', 'hh')
cell.paint('"dend"', 'pas')
# Set axial resistivity in dendrite regions (Ohm.cm)
cell.paint('"dendn"', rL=500)
cell.paint('"dendx"', rL=10000)
# Attach stimuli with duration of 2 ms and current of 0.8 nA.
# There are three stimuli, which activate at 10 ms, 50 ms and 80 ms.
cell.place('"stim_site"', arbor.iclamp(10, 2, 0.8))
cell.place('"stim_site"', arbor.iclamp(50, 2, 0.8))
cell.place('"stim_site"', arbor.iclamp(80, 2, 0.8))
# Add a spike detector with threshold of -10 mV.
cell.place('"root"', arbor.spike_detector(-10))

# Discretization: the default discretization in Arbor is 1 compartment per branch.
# Let's be a bit more precise and make that every 2 micron:
cell.compartments_length(2)

# Make single cell model.
m = arbor.single_cell_model(cell)

# Attach voltage probes, sampling at 10 kHz.
m.probe('voltage', '(location 0 0)', 10000)  # at the soma.
m.probe('voltage', '"dtips"', 10000)  # at the tips of the dendrites.

# Run simulation for 100 ms of simulated activity.
tfinal = 100
m.run(tfinal)
Exemplo n.º 10
0
def run_arb(fit, swc, current, t_start, t_stop):
    tree = arbor.load_swc_allen(swc, no_gaps=False)

    # Load mechanism data
    with open(fit) as fd:
        fit = json.load(fd)
    ## collect parameters in dict
    mechs = defaultdict(dict)

    ### Passive parameters
    ra = float(fit['passive'][0]['ra'])

    ### Remaining parameters
    for block in fit['genome']:
        mech = block['mechanism'] or 'pas'
        region = block['section']
        name = block['name']
        if name.endswith('_' + mech):
            name = name[:-(len(mech) + 1)]
        mechs[(mech, region)][name] = float(block['value'])
    # Label regions
    labels = arbor.label_dict({
        'soma': '(tag 1)',
        'axon': '(tag 2)',
        'dend': '(tag 3)',
        'apic': '(tag 4)',
        'center': '(location 0 0.5)'
    })

    properties = fit['conditions'][0]
    T = properties['celsius'] + 273.15
    Vm = properties['v_init']

    # Run simulation
    morph = arbor.morphology(tree)

    # Build cell and attach Clamp and Detector
    cell = arbor.cable_cell(morph, labels)
    cell.place('center', arbor.iclamp(t_start, t_stop - t_start, current))
    cell.place('center', arbor.spike_detector(-40))
    cell.compartments_length(20)

    # read json file and proceed to set parameters and mechanisms

    # set global values
    print('Setting global parameters')
    print(f"  * T  =  {T}K = {T - 273.15}C")
    print(f"  * Vm =  {Vm}mV")
    cell.set_properties(tempK=T, Vm=Vm, rL=ra)

    # Set reversal potentials
    print("Setting reversal potential for")
    for kv in properties['erev']:
        region = kv['section']
        for k, v in kv.items():
            if k == 'section':
                continue
            ion = k[1:]
            print(f'  * region {region:6} species {ion:5}: {v:10}')
            cell.paint(region, arbor.ion(ion, rev_pot=float(v)))

    cell.set_ion('ca',
                 int_con=5e-5,
                 ext_con=2.0,
                 method=arbor.mechanism('default_nernst/x=ca'))

    # Setup mechanisms and parameters
    print('Setting up mechanisms')
    ## Now paint the cell using the dict
    for (mech, region), vs in mechs.items():
        print(f"  * {region:10} -> {mech:10}: {str(vs):>60}", end=' ')
        try:
            if mech != 'pas':
                m = arbor.mechanism(mech, vs)
                cell.paint(region, m)
            else:
                m = arbor.mechanism('default_pas', {
                    'e': vs['e'],
                    'g': vs['g']
                })
                cell.paint(region, m)
                cell.paint(region, cm=vs["cm"] / 100, rL=vs["Ra"])
            print("OK")
        except Exception as e:
            print("ERROR")
            print("When trying to set", mech, vs)
            print("  ->", e)
            exit()

    # Run the simulation, collecting voltages
    print('Simulation', end=' ')
    default = arbor.default_catalogue()
    catalogue = arbor.allen_catalogue()
    catalogue.extend(default, 'default_')

    model = arbor.single_cell_model(cell)
    model.properties.catalogue = catalogue
    model.probe('voltage', 'center', frequency=200000)
    model.run(tfinal=t_start + t_stop, dt=1000 / 200000)
    print('DONE')
    for t in model.traces:
        ts = t.time[:]
        vs = t.value[:]
        break
    spikes = np.array(model.spikes)
    count = len(spikes)
    print('Counted spikes', count)
    return np.array(ts), np.array(vs) + 14
    decor.paint('"all"', 'ca_boyle')

    # Set calcium ion concentration.
    decor.set_ion('ca', int_con=0, ext_con=2.0, rev_pot = 40.0)

    # Set potassium reversal potential
    decor.set_ion('k', rev_pot=-60.0)


    # Place stimulus and a spike detector.
    # Stimulation at the center of the soma from t = 100 ms until t = 400 ms.
    # offset current "value"
    decor.place('"center"', arbor.iclamp(100, 300, value))

    # Spike detection at center of soma.
    decor.place('"center"', arbor.spike_detector(-26))

    #define CV policy and add it to decor
    #policy = arbor.cv_policy_every_segment('(all)')
    policy = arbor.cv_policy_fixed_per_branch(1, '(all)')
    #policy = arbor.cv_policy_max_extent(1.0)
    decor.discretization(policy)

    # (4) Create cell.
    dd1_cell = arbor.cable_cell(morph, labels, decor)

    # (5) Create probes for membrane voltage and calcium ion concentration.
    voltage_probe = arbor.cable_probe_membrane_voltage('"center"')
    ca_conc_probe = arbor.cable_probe_ion_int_concentration('"center"', "ca")

Exemplo n.º 12
0
# Set initial membrane potential to -55 mV
cell.set_properties(Vm=-55)
# Use Nernst to calculate reversal potential for calcium.
cell.set_ion('ca', method=mech('nernst/x=ca'))
# hh mechanism on the soma and axon.
cell.paint('"soma"', 'hh')
cell.paint('"axon"', 'hh')
# pas mechanism the dendrites.
cell.paint('"dend"', 'pas')
# Increase resistivity on dendrites.
cell.paint('"dend"', rL=500)
# Attach stimuli that inject 0.8 nA currents for 1 ms, starting at 3 and 8 ms.
cell.place('"stim_site"', arbor.iclamp(3, 1, current=2))
cell.place('"stim_site"', arbor.iclamp(8, 1, current=4))
# Detect spikes at the soma with a voltage threshold of -10 mV.
cell.place('"axon_end"', arbor.spike_detector(-10))

# Have one compartment between each sample point.
cell.compartments_on_segments()

# Make single cell model.
m = arbor.single_cell_model(cell)

# Attach voltage probes that sample at 50 kHz.
m.probe('voltage', where='"root"', frequency=50000)
m.probe('voltage', where=loc(2, 1), frequency=50000)
m.probe('voltage', where='"stim_site"', frequency=50000)
m.probe('voltage', where='"axon_end"', frequency=50000)

# Simulate the cell for 15 ms.
tfinal = 15
Exemplo n.º 13
0
                         'center': '(location 0 0.5)'})
cell = arb.cable_cell(morphology, labels) # see !\circled{3}!
cell.compartments_length(20) # discretisation strategy: max compartment length
# !\circled{4}! load and assign electro-physical parameters
defaults, regions, ions, mechanisms = utils.load_allen_fit('fit.json')
# set defaults and override by region
cell.set_properties(tempK=defaults.tempK, Vm=defaults.Vm,
                    cm=defaults.cm, rL=defaults.rL)
for region, vs in regions:
    cell.paint('"'+region+'"', tempK=vs.tempK, Vm=vs.Vm, cm=vs.cm, rL=vs.rL)
# set reversal potentials
for region, ion, e in ions:
    cell.paint('"'+region+'"', ion, rev_pot=e)
cell.set_ion('ca', int_con=5e-5, ext_con=2.0, method=arb.mechanism('nernst/x=ca'))
# assign ion dynamics
for region, mech, values in mechanisms:
    cell.paint('"'+region+'"', arb.mechanism(mech, values))
    print(mech)
# !\circled{5}! attach stimulus and spike detector
cell.place('"center"', arb.iclamp(200, 1000, 0.15))
cell.place('"center"', arb.spike_detector(-40))
# !\circled{6}! set up runnable simulation
model = arb.single_cell_model(cell)
model.probe('voltage', '"center"', frequency=200000) # see !\circled{5}!
# !\circled{7}! assign catalogues
model.properties.catalogue = arb.allen_catalogue()
model.properties.catalogue.extend(arb.default_catalogue(), '')
# !\circled{8}! run simulation and plot results
model.run(tfinal=1400, dt=0.005)
utils.plot_results(model)
Exemplo n.º 14
0

# neuroML: <channelDensity id="ca_boyle_all" ionChannel="ca_boyle" condDensity="2 mS_per_cm2" erev="40 mV" ion="ca"/>
ca_boyle_all = arbor.mechanism("ca_boyle")


# put hh dynamics on soma and passive properties on the dendrites
#dd1_cell.paint('"soma"', 'Leak')
dd1_cell.paint('"soma"', 'k_slow')
dd1_cell.paint('"soma"', 'k_fast')
dd1_cell.paint('"soma"', 'CaPoolTH')
dd1_cell.paint('"soma"', 'ca_boyle')
#dd1_cell.paint('"soma"', 'hh')

dd1_cell.place('"center"', arbor.iclamp(100, 300, 0.0087))
dd1_cell.place('"center"', arbor.spike_detector(-26))


# (4) Make single cell model.
m = arbor.single_cell_model(dd1_cell)

# (5) Attach voltage probe sampling at 10 kHz (every 0.1 ms).
m.probe('voltage', '"center"', frequency=10000)

# (6) Run simulation for 30 ms of simulated activity.
m.run(tfinal=500)

# (7) Print spike times, if any.
if len(m.spikes)>0:
    print('{} spikes:'.format(len(m.spikes)))
    for s in m.spikes:
Exemplo n.º 15
0
# Set initial membrane potential everywhere on the cell to -40 mV.
cell.set_properties(Vm=-40)
# Put hh dynamics on soma, and passive properties on the dendrites.
cell.paint('soma', 'hh')
cell.paint('dend', 'pas')
# Set axial resistivity in dendrite regions (Ohm.cm)
cell.paint('dendn', rL=500)
cell.paint('dendx', rL=10000)
# Attach stimuli with duration of 2 ms and current of 0.8 nA.
# There are three stimuli, which activate at 10 ms, 50 ms and 80 ms.
cell.place('stim_site', arbor.iclamp(10, 2, 0.8))
cell.place('stim_site', arbor.iclamp(50, 2, 0.8))
cell.place('stim_site', arbor.iclamp(80, 2, 0.8))
# Add a spike detector with threshold of -10 mV.
cell.place('root', arbor.spike_detector(-10))

# Make single cell model.
m = arbor.single_cell_model(cell)

# Attach voltage probes, sampling at 10 kHz.
m.probe('voltage', loc(0, 0), 10000)  # at the soma.
m.probe('voltage', 'dtips', 10000)  # at the tips of the dendrites.

# Run simulation for 100 ms of simulated activity.
tfinal = 100
m.run(tfinal)

# Print spike times.
if len(m.spikes) > 0:
    print('{} spikes:'.format(len(m.spikes)))
Exemplo n.º 16
0
# Create a sample tree with a single sample of radius 3 μm
tree = arbor.sample_tree()
tree.append(arbor.msample(x=0, y=0, z=0, radius=3, tag=2))

labels = arbor.label_dict({'soma': '(tag 2)', 'center': '(location 0 0.5)'})

cell = arbor.cable_cell(tree, labels)

# Set initial membrane potential everywhere on the cell to -40 mV.
cell.set_properties(Vm=-40)
# Put hh dynamics on soma, and passive properties on the dendrites.
cell.paint('soma', 'hh')
# Attach stimuli with duration of 2 ms and current of 0.8 nA.
cell.place('center', arbor.iclamp(10, 2, 0.8))
# Add a spike detector with threshold of -10 mV.
cell.place('center', arbor.spike_detector(-10))

# Make single cell model.
m = arbor.single_cell_model(cell)

# Attach voltage probes, sampling at 10 kHz.
m.probe('voltage', 'center', 10000)

# Run simulation for 100 ms of simulated activity.
tfinal = 30
m.run(tfinal)

# Print spike times.
if len(m.spikes) > 0:
    print('{} spikes:'.format(len(m.spikes)))
    for s in m.spikes:
Exemplo n.º 17
0
    def create_arbor_cell(self, cell, gid, pop_id, index):

        if cell.arbor_cell == "cable_cell":

            default_tree = arbor.segment_tree()
            radius = (evaluate(cell.parameters["radius"],
                               self.nl_network.parameters)
                      if "radius" in cell.parameters else 3)

            default_tree.append(
                arbor.mnpos,
                arbor.mpoint(-1 * radius, 0, 0, radius),
                arbor.mpoint(radius, 0, 0, radius),
                tag=1,
            )

            labels = arbor.label_dict({
                "soma": "(tag 1)",
                "center": "(location 0 0.5)"
            })

            labels["root"] = "(root)"

            decor = arbor.decor()

            v_init = (evaluate(cell.parameters["v_init"],
                               self.nl_network.parameters)
                      if "v_init" in cell.parameters else -70)
            decor.set_property(Vm=v_init)

            decor.paint('"soma"', arbor.density(cell.parameters["mechanism"]))

            decor.place('"center"', arbor.spike_detector(0), "detector")

            for ip in self.input_info:
                if self.input_info[ip][0] == pop_id:
                    print_v("Stim: %s (%s) being placed on %s" %
                            (ip, self.input_info[ip], pop_id))
                    for il in self.input_lists[ip]:
                        cellId, segId, fract, weight = il
                        if cellId == index:
                            if self.input_info[ip][
                                    1] == 'i_clamp':  # TODO: remove hardcoding of this...
                                ic = arbor.iclamp(
                                    self.nl_network.parameters["input_del"],
                                    self.nl_network.parameters["input_dur"],
                                    self.nl_network.parameters["input_amp"],
                                )
                                print_v("Stim: %s on %s" % (ic, gid))
                                decor.place('"center"', ic, "iclamp")

            # (2) Mark location for synapse at the midpoint of branch 1 (the first dendrite).
            labels["synapse_site"] = "(location 0 0.5)"
            # (4) Attach a single synapse.
            decor.place('"synapse_site"', arbor.synapse("expsyn"), "syn")

            default_cell = arbor.cable_cell(default_tree, labels, decor)

            print_v("Created a new cell for gid %i: %s" % (gid, cell))
            print_v("%s" % (default_cell))

            return default_cell
Exemplo n.º 18
0
decor.paint('"custom"', tempK=270)
decor.paint('"soma"', Vm=-50)

# Paint density mechanisms.

decor.paint('"all"', 'pas')
decor.paint('"custom"', 'hh')
decor.paint('"dend"', mech('Ih', {'gbar': 0.001}))

# Place stimuli and spike detectors.

decor.place('"root"', arbor.iclamp(10, 1, current=2), "iclamp0")
decor.place('"root"', arbor.iclamp(30, 1, current=2), "iclamp1")
decor.place('"root"', arbor.iclamp(50, 1, current=2), "iclamp2")
decor.place('"axon_terminal"', arbor.spike_detector(-10), "detector")

# Set cv_policy

soma_policy = arbor.cv_policy_single('"soma"')
dflt_policy = arbor.cv_policy_max_extent(1.0)
policy = dflt_policy | soma_policy
decor.discretization(policy)

# Create a cell

cell = arbor.cable_cell(morph, labels, decor)

# (2) Declare a probe.

probe = arbor.cable_probe_membrane_voltage('"custom_terminal"')
Exemplo n.º 19
0
tree = arbor.segment_tree()
tree.append(arbor.mnpos,
            arbor.mpoint(-3, 0, 0, 3),
            arbor.mpoint(3, 0, 0, 3),
            tag=1)

# Label dictionary
labels = arbor.label_dict()
labels['centre'] = '(location 0 0.5)'

# Decorations
decor = arbor.decor()
decor.set_property(Vm=-40)
decor.paint('(all)', 'hh')
decor.place('"centre"', arbor.iclamp(10, 2, 0.8))
decor.place('"centre"', arbor.spike_detector(-10))

cell = arbor.cable_cell(tree, labels, decor)

# (3) Instantiate recipe with a voltage probe.

recipe = single_recipe(cell, [arbor.cable_probe_membrane_voltage('"centre"')])

# (4) Instantiate simulation and set up sampling on probe id (0, 0).

context = arbor.context()
domains = arbor.partition_load_balance(recipe, context)
sim = arbor.simulation(recipe, domains, context)

sim.record(arbor.spike_recording.all)
handle = sim.sample((0, 0), arbor.regular_schedule(0.1))