-
Notifications
You must be signed in to change notification settings - Fork 222
Proposal for morphologies
Note: Only the first section (core structures) should be considered mature, the rest is work in progress.
Morphology are used for simulation, access and plotting. For simulation, the geometry doesn't actually matter, only the electrical properties do. For access, the Morphology class is used to return the index of the compartment. Plotting should also be dealt with by the Morphology class.
I propose 1) to clearly separate properties that are relevant for simulation (i.e. electrically relevant) from others, 2) to make geometrical and electrical properties independent (ie not compute electrical properties from geometrical properties as is done currently), the relation being dealt with by the Morphology class, depending on specific implied geometry (eg truncated cone).
A morphology is a tree, each node being a branch. Each branch is a set of compartments. For each compartment, properties are:
-
area (to calculate transmembrane currents)
-
volume (for diffusion)
-
curved length
-
resistive length (for axial currents)
-
x,y,z coordinates of electrical midpoint
Some explanations for the last two properties (4 and 5). Since the resistance depends on intracellular resistivity, which is only specified later, we instead calculate an effective length, that is, so that resistance is intracellular resistivity divided by effective length (for a cylinder, pi * d**2/4L). This gives a quantity that has units of meter, which we call the resistive length. Then, (x,y,z) coordinates correspond to the actual coordinates of all properties such as V, Im and others, i.e., the midpoint of the compartment. It makes sense (and is simpler) to choose the midpoint of the compartment as the point that splits the resistive length in two equal parts. For a cylinder, this would simply be the geometrical midpoint, but for a truncated cone, it would be biased towards the smaller end. This way, it is very easy to calculate the resistance between two successive compartments, which is just the average resistance of the two compartments. In the same way, the resistances at the two ends of the branch are just half-resistances of the corresponding compartments.
Curved length (3) is the geometrical length of the compartment, but not the Euclidian distance between the two end points. It is rather the total length along the possibly curved compartment. It is therefore decoupled from coordinates. This will make it easier for resegmenting a tree.
We may add, for convenience, a distance
properties, which is the distance from the origin of the branch to the midpoint (derived from curved length). This can be useful when setting channel properties (point to think about; we might rather want distance from the soma than from origin, for example). Alternatively, we could also have a position
property, which would indicate the distance relative to the total curved length (between 0 and 1). But in all cases, all properties that are state variables of the spatial neuron are meant at the electrical point.
All these properties above are considered independent. Diameter and end point coordinates are not core properties, but depend on the specific geometry (cylinder, truncated cone, sphere). The old 'distance' (in the previous version) is only used internally for access (i.e. to determine which compartment is meant when specifying a distance). We only need distance from branch origin, not from soma origin.
The properties should not be directly modifiable by the user; rather, set at construction time.
Note: I am just realizing that the electrical equivalent circuit at branches might be a bit inaccurate (to check; maybe not).
I propose the following two basic morphologies for branches:
- Isopotential sphere. This corresponds to the
Soma
class. It has zero resistive length but positive area. - Sequence of truncated cones. This is better than a sequence of cylinders for two reasons: it is more compatible with other tools and formats, and diameter is continuous (and so we don't have the problem of what to do with the surface at junctions). This implies that n+1 diameters are needed. A cylinder is a sequence of truncated cones and therefore can simply be a subclass.
I propose that the basic Morphology class does not have a specific geometry. This might reduce some confusions. Instead, maybe we could define a Branch class, and a morphology is plotted by recursively plotting branches. Only branches have a specific geometry. This might be cleaner. Therefore we would have:
- Branch as the base class, no implied geometry. But it could possibly be plotted by using the coordinates, although it would just be segments, and the tree would not be connected. Or we do not define plotting methods at all.
- Soma (isopotential sphere) inherits from Branch.
- Sequence of truncated cones inherits from Branch (but we need a name!).
- Cylinder inherits from truncated cones.
Alternatively, Branch is a sequence of truncated cones, and then Soma redefines the relevant methods. We probably don't need other types of geometries.
One issue is what to do with the surface at the two ends of a cylinder or truncated cones. Physically, those should be included in the calculation of area for the two compartments. I propose to do that, and when a branch is connected, the area of the end compartment of the parent branch of and of the start compartment of the child are updated. This means that Branch must define two methods that are called when either end is connected, with argument the section area of the connecting branch.
However, this needs some thought, because there is the case of branching (ie the branch divides in two or more branches). In that case, it is possible that the total section area of the children exceeds the section area of the parent. In fact, I am wondering whether the standard treatment of branching in cable theory might not be inaccurate, since there can be continuity at branching with circular sections (should we think about that?).
As far as I know, current tools ignore this point and simply assume that no current passes through free boundary surfaces. So we could start in this way. A third option is to add a boundary surface only when the surface is not bound (i.e. leaves of the tree).
There are basically two ways of building morphologies: by loading a file, and by assembling blocks, mainly soma and truncated cones (or cylinders). In the current system, a morphology can be added as a child of another morphology, which means at the end of the main branch. This uses setattr
. For example: soma.axon = Cylinder(...)
.
This is normally fine except when the soma has several compartments (ie is not an isopotential compartment) (first of all, it should be checked that the simulation does not assume that the first compartment is an isopotential soma). How to connect branches at different ends (or even in the middle)?
There are different options. One is to define an arbitrary root, as a compartment of negligible area and length. From there, branches can be inserted. The soma is then itself a tree. It is not very elegant. Otherwise, we need to consider 1) a nice syntax, 2) a new data structure. For simulation, the data must be a tree (unless we change the simulation core quite a bit). At least, there cannot be branches stemming from a midpoint of the soma (we have only boundary conditions at the two ends). So in any case, if we allow it, then the soma cannot be a single branch. This suggests that Soma should be a special class (see below). No other branch would exhibit this kind of issue.
There is a general question of modeling here. Does it make sense to break up the soma in a sequence of little cylinders? Cable theory is based on the assumption that the neuron is isopotential in the radial direction. But in the case of the soma, we would end up with little cylinders that have large diameter and small length.
To allow multicompartmental soma with branches at different points, we need a special class. The soma has the following particularities:
- It is made of several branches of the underlying tree, where one branch is an isopotential compartment considered the root (alternatively, one branch is a root, but we need to take this into account in the simulation - possible but needs probably some rewriting).
- These branches are connected sequentially.
- There are morphologies stemming from the junctions.
- These morphologies can be accessed directly by their name (eg axon, dendrite, etc). This can simply take the form of a dictionary.
- A morphology can be inserted at any point in the soma. When this happens, a branch of the soma is split in two (hidden from the user).
In other words, the Soma is a kind of sub-tree.
The main problem we have is with the issue of multicompartmental soma mentioned above.
Resegmenting is not difficult in the context of general geometrical parameters (area, electric length), it is more challenging for coordinates. That is, to split a compartment in two, we might divide electric length, area etc by two (we should check what Neuron does). Coordinate interpolation is done independently (ie we do not enforce consistence).
I propose that resegmenting is done by producing a new Morphology object. We might want to keep a link to the original one for plotting (i.e. each compartment in the new morphology maps to a subbranch in the old morphology). In that case, simulation is done on the new morphology, but the compartments are mapped to old one for plotting.