예제 #1
0
 def cell_description(self, gid):
     c = A.cable_cell(self.the_morphology, A.label_dict())
     c.set_properties(Vm=0.0, cm=0.01, rL=30, tempK=300)
     c.paint('(all)', "pas")
     c.place('(location 0 0)', A.iclamp(current=10 if gid == 0 else 20))
     c.place('(sum (on-branches 0.3) (location 0 0.6))', "expsyn")
     return c
예제 #2
0
    def cell_description(self, gid):
        """A high level description of the cell with global identifier gid.

        For example the morphology, synapses and ion channels required
        to build a multi-compartment neuron.
        """
        assert gid == 0

        tree = arbor.segment_tree()

        tree.append(arbor.mnpos,
                    arbor.mpoint(0, 0, 0, self.radius),
                    arbor.mpoint(self.length, 0, 0, self.radius),
                    tag=1)

        labels = arbor.label_dict({'cable': '(tag 1)',
                                   'start': '(location 0 0)'})

        decor = arbor.decor()
        decor.set_property(Vm=self.Vm)
        decor.set_property(cm=self.cm)
        decor.set_property(rL=self.rL)

        decor.paint('"cable"',
                    arbor.density(f'pas/e={self.Vm}', {'g': self.g}))

        decor.place('"start"', arbor.iclamp(self.stimulus_start, self.stimulus_duration, self.stimulus_amplitude), "iclamp")

        policy = arbor.cv_policy_max_extent(self.cv_policy_max_extent)
        decor.discretization(policy)

        return arbor.cable_cell(tree, labels, decor)
예제 #3
0
    def test_iclamp(self):
        # Constant amplitude iclamp:
        clamp = A.iclamp(10)
        self.assertEqual(0, clamp.frequency)
        self.assertEqual([(0, 10)], clamp.envelope)

        clamp = A.iclamp(10, frequency=20)
        self.assertEqual(20, clamp.frequency)
        self.assertEqual([(0, 10)], clamp.envelope)

        # Square pulse:
        clamp = A.iclamp(100, 20, 3)
        self.assertEqual(0, clamp.frequency)
        self.assertEqual([(100, 3), (120, 3), (120, 0)], clamp.envelope)

        clamp = A.iclamp(100, 20, 3, frequency=7)
        self.assertEqual(7, clamp.frequency)
        self.assertEqual([(100, 3), (120, 3), (120, 0)], clamp.envelope)

        # Explicit envelope:
        envelope = [(1, 10), (3, 30), (5, 50), (7, 0)]
        clamp = A.iclamp(envelope)
        self.assertEqual(0, clamp.frequency)
        self.assertEqual(envelope, clamp.envelope)

        clamp = A.iclamp(envelope, frequency=7)
        self.assertEqual(7, clamp.frequency)
        self.assertEqual(envelope, clamp.envelope)
예제 #4
0
    def __init__(self):
        A.recipe.__init__(self)
        st = A.segment_tree()
        st.append(A.mnpos, (0, 0, 0, 10), (1, 0, 0, 10), 1)

        dec = A.decor()

        dec.place('(location 0 0.08)', A.synapse("expsyn"), "syn0")
        dec.place('(location 0 0.09)', A.synapse("exp2syn"), "syn1")
        dec.place('(location 0 0.1)', A.iclamp(20.), "iclamp")
        dec.paint('(all)', A.density("hh"))

        self.cell = A.cable_cell(st, A.label_dict(), dec)

        self.props = A.neuron_cable_properties()
        self.props.catalogue = A.default_catalogue()
예제 #5
0
def make_cable_cell(morphology, clamp_location):
    # number of CVs per branch
    cvs_per_branch = 3

    # Label dictionary
    defs = {}
    labels = arbor.label_dict(defs)

    # decor
    decor = arbor.decor()

    # set initial voltage, temperature, axial resistivity, membrane capacitance
    decor.set_property(
        Vm=-65,  # Initial membrane voltage (mV)
        tempK=300,  # Temperature (Kelvin)
        rL=10000,  # Axial resistivity (Ω cm)
        cm=0.01,  # Membrane capacitance (F/m**2)
    )

    # set passive mechanism all over
    # passive mech w. leak reversal potential (mV)
    pas = arbor.mechanism('pas/e=-65')
    pas.set('g', 0.0001)  # leak conductivity (S/cm2)
    decor.paint('(all)', arbor.density(pas))

    # set number of CVs per branch
    policy = arbor.cv_policy_fixed_per_branch(cvs_per_branch)
    decor.discretization(policy)

    # place sinusoid input current
    iclamp = arbor.iclamp(
        5,  # stimulation onset (ms)
        1E8,  # stimulation duration (ms)
        -0.001,  # stimulation amplitude (nA)
        frequency=0.1,  # stimulation frequency (kHz)
        phase=0)  # stimulation phase)
    decor.place(str(clamp_location), iclamp, '"iclamp"')

    # create ``arbor.place_pwlin`` object
    p = arbor.place_pwlin(morphology)

    # create cell and set properties
    cell = arbor.cable_cell(morphology, labels, decor)

    return p, cell
예제 #6
0
파일: fixtures.py 프로젝트: halfflat/arbor
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)
예제 #7
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
예제 #8
0
    def simulate(self, traj):
        cell = arb.cable_cell(self.morphology, self.labels)
        cell.compartments_length(20)
        cell.set_properties(tempK=self.defaults.tempK,
                            Vm=self.defaults.Vm,
                            cm=self.defaults.cm,
                            rL=self.defaults.rL)
        for region, vs in self.regions:
            cell.paint(f'"{region}"',
                       tempK=vs.tempK,
                       Vm=vs.Vm,
                       cm=vs.cm,
                       rL=vs.rL)
        for region, ion, e in self.ions:
            cell.paint(f'"{region}"', ion, rev_pot=e)
        cell.set_ion('ca',
                     int_con=5e-5,
                     ext_con=2.0,
                     method=arb.mechanism('nernst/x=ca'))

        tmp = defaultdict(dict)
        for key, val in traj.individual.items():
            region, mech, valuename = key.split('.')
            tmp[(region, mech)][valuename] = val

        for (region, mech), values in tmp.items():
            cell.paint(f'"{region}"', arb.mechanism(mech, values))

        cell.place('"center"', arb.iclamp(200, 1000, 0.15))
        model = arb.single_cell_model(cell)
        model.probe('voltage', '"center"', frequency=200000)
        model.properties.catalogue = arb.allen_catalogue()
        model.properties.catalogue.extend(arb.default_catalogue(), '')
        model.run(tfinal=1400, dt=0.005)
        voltages = np.array(model.traces[0].value[:])
        return (((voltages - self.reference)**2).sum(), )
예제 #9
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.
예제 #10
0
decor = arbor.decor()

# Set initial membrane potential to -55 mV
decor.set_property(Vm=-55)
# Use Nernst to calculate reversal potential for calcium.
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)
예제 #11
0
decor.set_property(Vm =-55)

# Override the defaults.

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))
decor.place('"root"', arbor.iclamp(30, 1, current=2))
decor.place('"root"', arbor.iclamp(50, 1, current=2))
decor.place('"axon_terminal"', arbor.spike_detector(-10))

# 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)
예제 #12
0
print(cell.locations('axon_end'))

# 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=0.5))
cell.place('stim_site', arbor.iclamp(8, 1, current=1))
# Detect spikes at the soma with a voltage threshold of -10 mV.
cell.place('root', 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)
예제 #13
0
properties = fit['conditions'][0]
T  = properties['celsius'] + 273.15
Vm = properties['v_init']
    
# Run simulation
ts = []
volts = {}
counts = {}
for i in currents:
    morph = arbor.morphology(tree, spherical_root=True)

    # Build cell and attach Clamp and Detector
    cell = arbor.cable_cell(tree, labels)
    #cell.compartments_per_branch(1)
    cell.place('center', arbor.iclamp(100, 1000, 0.15))
    cell.place('center', arbor.spike_detector(-40))
    #cell.set_ion('ca', int_con=5e-5, ext_con=2.0, method=arbor.mechanism('nernst/x=ca'))
    cell.set_properties(tempK=T, Vm=Vm, rL=ra)

    print(' * Global Parameters')
    print(f"  * T  =  {T}K = {T - 273.15}C")    
    print(f"  * Vm =  {Vm}mV")    
    
    # Set reversal potentials
    print(" * Reversal Potential")
    for kv in properties['erev']:
        region = kv['section']
        for k, v in kv.items():
            if k == 'section':
                continue
예제 #14
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)
예제 #15
0
labels['stim_site'] = '(location 0 0.5)'  # site for the stimulus
#labels['axon_end']  = '(restrict (terminal) (region "axon_group"))' # end of the axon.
labels[
    'dend_end'] = '(restrict (terminal) (region "dendrite_group"))'  # end of the axon.
labels[
    'root'] = '(root)'  # the start of the soma in this morphology is at the root of the cell.

labels['soma'] = '(location 0 0.5)'
#labels['dend1'] = '(location 1 0.5)'
#labels['dend2'] = '(location 2 0.5)'

decor = arbor.decor()

decor.paint('"all"', arbor.mechanism('pas', dict(g=2.01e-05)))

decor.place('"stim_site"', arbor.iclamp(100, 200, 0.1))

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

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

m.probe('voltage', where='"root"', frequency=500)
m.probe('voltage', where='"dend_end"', frequency=500)

# Simulate the cell
print('Simulation start.')
tfinal = 1000  # ms
m.run(tfinal)
예제 #16
0
# Set the default properties of the cell (this overrides the model defaults).
decor.set_property(Vm=-55)
decor.set_ion('na', int_con=10, ext_con=140, rev_pot=50, method='nernst/na')
decor.set_ion('k', int_con=54.4, ext_con=2.5, rev_pot=-77)

# Override the cell defaults.
decor.paint('"custom"', tempK=270)
decor.paint('"soma"', Vm=-50)

# Paint density mechanisms.
decor.paint('"all"', density('pas'))
decor.paint('"custom"', density('hh'))
decor.paint('"dend"', density('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')

# Single CV for the "soma" region
soma_policy = arbor.cv_policy_single('"soma"')
# Single CV for the "soma" region
dflt_policy = arbor.cv_policy_max_extent(1.0)
# default policy everywhere except the soma
policy = dflt_policy | soma_policy
# Set cv_policy
decor.discretization(policy)

# (4) Create the cell.
예제 #17
0
decor = arbor.decor()

# Set initial membrane potential to -55 mV
decor.set_property(Vm=-55)
# Use Nernst to calculate reversal potential for calcium.
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))
decor.place('"stim_site"', arbor.iclamp(3, 1, current=0.5))
decor.place('"stim_site"', arbor.iclamp(10, 1, current=0.5))
decor.place('"stim_site"', arbor.iclamp(8, 1, current=4))
# Detect spikes at the soma with a voltage threshold of -10 mV.
decor.place('"axon_end"', arbor.spike_detector(-10))

# 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)
    decor.paint('"all"', 'k_slow')
    decor.paint('"all"', 'k_fast')
    decor.paint('"all"', 'CaPoolTH')
    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"')
예제 #19
0
print(cell.locations('"axon_end"'))

# 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)
예제 #20
0
    Vm=-65,  # Initial membrane voltage [mV]
    tempK=300,  # Temperature [Kelvin]
    rL=10000,  # Axial resistivity [Ω cm]
    cm=0.01,  # Membrane capacitance [F/m**2]
)

# set passive mechanism all over
# passive mech w. leak reversal potential (mV)
pas = arbor.mechanism('pas/e=-65')
pas.set('g', 0.0001)  # leak conductivity (S/cm2)
decor.paint('(all)', arbor.density(pas))

# set sinusoid input current at mid point of terminating CV (segment)
iclamp = arbor.iclamp(
    5,  # stimulation onset (ms)
    1E8,  # stimulation duration (ms)
    -0.001,  # stimulation amplitude (nA)
    frequency=0.1,  # stimulation frequency (kHz)
    phase=0)  # stimulation phase)
try:
    # arbor >= 0.5.2 fix
    decor.place('(location 4 0.16667)', iclamp, '"iclamp"')
except TypeError:
    decor.place('(location 4 0.16667)', iclamp)

# number of CVs per branch
policy = arbor.cv_policy_fixed_per_branch(nseg)
decor.discretization(policy)

# create cell and set properties
cell = arbor.cable_cell(morphology, labels, decor)
예제 #21
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 center
labels = arbor.label_dict({'soma': '(tag 1)', 'center': '(location 0 0.5)'})

# (3) Create cell and set properties
cell = arbor.cable_cell(tree, labels)
cell.set_properties(Vm=-40)
cell.paint('"soma"', 'hh')
cell.place('"center"', arbor.iclamp(10, 2, 0.8))
cell.place('"center"', arbor.spike_detector(-10))

# (4) Make single cell model.
m = arbor.single_cell_model(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=30)

# (7) Print spike times, if any.
if len(m.spikes) > 0:
    print('{} spikes:'.format(len(m.spikes)))
    for s in m.spikes:
예제 #22
0
import arbor

# Create a sample tree with a single sample of radius 3 μm
tree = arbor.sample_tree()
tree.append(arbor.sample(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 1 ms and current of 0.8 nA.
cell.place('center', arbor.iclamp( 10, duration=1, current=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 1 MHz.
m.probe('voltage', 'center',  1000000)

# Run simulation for tfinal ms with time steps of 1 μs.
tfinal=30
m.run(tfinal, dt=0.001)

# Print spike times.
if len(m.spikes)>0:
예제 #23
0
파일: example1.py 프로젝트: castigli/arbor
import arbor

# 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:
예제 #24
0
CaPoolTH = arbor.mechanism("CaPoolTH")


# 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)))
예제 #25
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
예제 #26
0
    morph = arbor.morphology(tree, spherical_root=True)

    # Label regions
    labels = arbor.label_dict({
        'soma': '(tag 1)',
        'axon': '(tag 2)',
        'dend': '(tag 3)',
        'apic': '(tag 4)',
        'center': '(location 0 0.5)'
    })

    # Build cell and attach Clamp and Detector
    cell = arbor.cable_cell(tree, labels)

    cell.place('center', arbor.iclamp(200, 1200, i))
    cell.place('center', arbor.spike_detector(-40))

    # read json file and proceed to set parameters and mechanisms
    with open('473561729/473561729_fit.json') as fd:
        fit = json.load(fd)

    # set global values
    print('Setting global parameters')
    properties = fit['conditions'][0]
    T = properties['celsius'] + 273.15
    print(f"  * T  =  {T}K = {T - 273.15}C")
    Vm = properties['v_init']
    print(f"  * Vm =  {Vm}mV")
    cell.set_properties(tempK=T, Vm=Vm, rL=ra)
예제 #27
0
b.add_label('dtips', '(terminal)')

# Extract the cable cell from the builder.
cell = b.build()

# 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)
예제 #28
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
decor.set_property(Vm=-55)

# Override the defaults.

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)
예제 #30
0
# Morphology
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)