Example #1
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)'
    # 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"', arbor.density('hh'))
    decor.paint('"dend"', arbor.density('pas'))

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

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

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

    return cell
Example #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
Example #3
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)
Example #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
Example #5
0
    def __init__(self):
        arb.recipe.__init__(self)
        self.tree = arb.segment_tree()
        self.tree.append(arb.mnpos, (0, 0, 0, 10), (1, 0, 0, 10), 1)
        self.props = arb.neuron_cable_properties()
        try:
            self.cat = arb.default_catalogue()
            self.props.register(self.cat)
        except:
            print("Catalogue not found. Are you running from build directory?")
            raise

        d = arb.decor()
        d.paint('(all)', arb.density('pas'))
        d.set_property(Vm=0.0)
        self.cell = arb.cable_cell(self.tree, arb.label_dict(), d)
Example #6
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()
Example #7
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
Example #8
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)
Example #9
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 in [0, 1]

        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({
            'cell': '(tag 1)',
            'gj_site': '(location 0 0.5)'
        })

        decor = arbor.decor()
        decor.set_property(Vm=self.Vms[gid])
        decor.set_property(cm=self.cm)
        decor.set_property(rL=self.rL)

        # add a gap junction mechanism at the "gj_site" location and label that specific mechanism on that location "gj_label"
        junction_mech = arbor.junction('gj', {"g": self.gj_g})
        decor.place('"gj_site"', junction_mech, 'gj_label')
        decor.paint('"cell"',
                    arbor.density(f'pas/e={self.Vms[gid]}', {'g': self.g}))

        if self.cv_policy_max_extent is not None:
            policy = arbor.cv_policy_max_extent(self.cv_policy_max_extent)
            decor.discretization(policy)
        else:
            decor.discretization(arbor.cv_policy_single())

        return arbor.cable_cell(tree, labels, decor)
Example #10
0
    def _cc_insert_mechs(cls, decor, label, mechs):
        import arbor

        catalogue = cls.get_catalogue()
        prefix = cls.get_catalogue_prefix()
        for mech_def, mech_attrs in mechs.items():
            if isinstance(mech_def, tuple):
                mech_name = "_".join(mech_def)
            else:
                mech_name = mech_def
                mech_def = (mech_name, )
            mech_name = prefix + mech_name
            try:
                mech_info = catalogue[mech_name]
            except KeyError:
                raise MechanismNotFoundError(
                    f"Could not find '{mech_name}' in catalogue. Catalogue mechanisms: "
                    + ", ".join(catalogue),
                    *mech_def,
                )
            # Params need to be sorted into globals and others, see
            # https://github.com/arbor-sim/arbor/issues/1226
            mi_globals = mech_info.globals
            params = {}
            sep = "/"
            mech_derivation = mech_name
            for k, v in mech_attrs.items():
                if k in mi_globals:
                    mech_derivation += f"{sep}{k}={v}"
                    sep = ","
                else:
                    params[k] = v
            # Examples:
            #   arbor.density("pas/e=55,x=-2", params)
            #   arbor.density("pas", params)
            mech = arbor.density(mech_derivation, params)
            decor.paint(f'"{label}"', mech)
Example #11
0
# (3) Create and populate the decor.

decor = arbor.decor()

# 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
Example #12
0
import sys

# (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')

# (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)
Example #13
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
Example #14
0
labels['axon_end']  = '(restrict (terminal) (region "axon"))' # end of the axon.
labels['root']      = '(root)' # the start of the soma in this morphology is at the root of the cell.

# Optional: print out the regions and locsets available in the label dictionary.
print("Label dictionary regions: ", labels.regions, "\n")
print("Label dictionary locsets: ", labels.locsets, "\n")

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"', arbor.density('hh'))
decor.paint('"axon"', arbor.density('hh'))
# pas mechanism the dendrites.
decor.paint('"dend"', arbor.density('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.
Example #15
0
# 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 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