Regions & Locsets#
When you decorate a multi-compartment cell you must say where a mechanism
goes. braincell answers this with two kinds of selection expression, both
living in braincell.filter:
a region selects an extended set of cable — “the soma”, “all apical dendrites”, “everything within 100 µm of the root”. You
paintdensity mechanisms onto regions.a locset selects ordered point rows — “the root”, “all branch tips”, “every 50 µm”. You
placepoint mechanisms onto locsets.
import braincell.filter as f
Note
This mirrors the labels idea in simulators like Arbor: a small, composable algebra for naming parts of a morphology, kept separate from the mechanisms you attach to them.
Regions (paint targets)#
Expression |
Selects |
|---|---|
the entire cell |
|
nothing (useful as an identity in set operations) |
|
branches matching a property, e.g. |
|
a sub-interval along branches |
|
a branch and everything distal to it |
|
cable whose radius falls in a range |
|
cable within a straight-line / along-the-tree distance |
from braincell.filter import AllRegion, branch_in
cell.paint(AllRegion(), mech.Channel("IL", g_max=0.0003 * u.S / u.cm**2, E=-70. * u.mV))
cell.paint(branch_in("type", "soma"), mech.Channel("Na_Ba2002", g_max=0.12 * u.S / u.cm**2))
cell.paint(
branch_in("type", ("dendrite", "basal_dendrite", "apical_dendrite")),
mech.Channel("CaL_IS2008", g_max=0.002 * u.S / u.cm**2),
)
Locsets (place targets)#
Expression |
Selects |
|---|---|
a point on the root branch, e.g. |
|
all terminal tips |
|
topology junctions incident to at least three branches |
|
evenly / step-spaced points along the cell |
|
randomly sampled points |
|
a specific (branch, position) location |
from braincell.filter import RootLocation, Terminals
cell.place(RootLocation(0.5), mech.CurrentClamp(durations=50 * u.ms, amplitudes=0.2 * u.nA))
cell.place(Terminals(), mech.StateProbe("V"))
Composing selections#
Regions support set operations. Locsets are ordered and preserve repeated rows by
default: a + b concatenates, while a | b, a & b, and a - b perform
stable union, intersection, and difference. Use a.unique() for explicit stable
deduplication. Two equal rows produced by + remain two placement requests even
when they later map to the same CV or electrical point.
ForkPoints follows morphology attachment topology, not
coincident XYZ coordinates. BranchPoints remains a
compatibility alias. Resolved LocsetMask objects expose
read-only branch_id and branch_x columns plus the compatibility .points rows.
braincell.filter also caches selection results
(SelectionCache) so repeated paints over the same
region don’t recompute the membership.
See also#
Mechanisms — the things you paint and place.
Morphology — what the selections range over.
braincell.filter module — full selection API reference.