# Single Cell Models¶

Building and testing detailed models of individual cells, then optimizing their parameters is usually the first step in building models with multi-compartment cells. Arbor supports a single cell model workflow for this purpose, which is a good way to introduce Arbor’s cell modeling concepts and approach.

This guide will walk through a series of single cell models of increasing complexity that the reader is encouraged to follow along with in Python. Links are provide to separate documentation that covers relevant topics in more detail.

## Example 1: Single compartment cell with HH dynamics¶

The most trivial representation of a cell in Arbor is to model the entire cell as a sphere. The following model shows the steps required to construct a model of a spherical cell with radius 3 μm, Hodgkin–Huxley dynamics and a current clamp stimulus, then run the model for 30 ms.

The first step is to construct the cell. In Arbor, the abstract representation used to define a cell with branching “cable” morphology is a cable_cell, which holds a description of the cell’s morphology, named regions and locations on the morphology, and descriptions of ion channels, synapses, spike detectors and electrical properties.

Our “single-compartment HH cell” has a trivial morphology and dynamics, so the steps to create the cable_cell that represents it are quite straightforward:

import arbor

# (1) Create a morphology with a single 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))


Arbor’s cell morphologies are constructed from a segment tree, which is a list of segments, which are tapered cones with a tag. Step (1) above shows how the spherical cell is represented using a single segment.

Cell builders need to refer to regions and locations on a cell morphology. Arbor uses a domains specific language (DSL) to describe regions and locations, which are given labels. In step (2) a dictionary of labels is created with two labels:

• soma defines a region with (tag  2). Note that this corresponds to the tag parameter that was used to define the single segment in step (1).

• center defines a location at (location 0 0.5), which is the mid point 0.5 of branch 0, which corresponds to the center of the soma on the morphology defined in Step (1).

In step (3) the cable cell is constructed by combining the segment tree with the named regions and locations.

• Set initial membrane potential everywhere on the cell to -40 mV.

• Use HH dynamics on soma.

• Attach stimuli with duration of 2 ms and current of 0.8 nA.

• Add a spike detector with threshold of -10 mV.

Arbor can simulate networks with multiple individual cells, connected together in a network. Single cell models do not require the full recipe interface used to describing such network models, with many unique cells, network and gap junctions. Arbor provides a single_cell_model helper that wraps a cell description, and provides an interface for recording

# (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 100 ms of simulated activity.
m.run(tfinal=100)


Step (4) instantiates the single cell model using our single-compartment cell. To record variables from the model three pieces of information are provided.

## Morphology¶

Warning

The flat cell builder documented below is likely to change before version 0.4 is released. It is a wrapper around a segment tree that simplifies morphology construction when the spatial location of segments is not important (for example, when we only need to describe the length, radius and parent-child relationship of branches in the morphology).

The first step in building a cell model is to define the cell’s morphology. Conceptually, Arbor treats morphologies as a tree of truncated frustums. These are represented as a tree of segments, where each segment is defined by two end points with radius, and a tag, and a parent segment to which it is attached.

Let’s start with a simple “ball and stick” model cell, with a spherical soma (the ball, treated as a cylinder with length=with) and a y-shaped dendritic tree (the sticks).

import arbor
builder = arbor.flat_cell_builder()

# Start with the soma, which is a cylinder with the same area as
# a sphere of radius 5 μm. Label this segment 'soma'.

There are two approaches available for building a morphology: construct it manually using segment tree or flat_cell_builder, or load from a file. The flat_cell_builder is a helper tool, that internally constructs a segment tree.