---
include_toc: true
---

## Neural Component Model Specifications

### 1. Presynapse (Transmitter Release Unit)

**Internal State Variables:**

- `V_m`: Membrane potential
- `P_r`: Release probability (dynamic, 0.0-1.0)
- `[Ca²⁺]_i`: Intracellular Ca²⁺ concentration
- `vesicle_pool`: Available vesicles
- `residual_Ca²⁺`: Facilitation buffer

**Incoming Signals:**

- **Electrical:** AP from axon (spike train)
- **Chemical:** 
  - eCB (→ ↓ `P_r` via CB1)
  - NO/BDNF (→ ↑ `P_r` via cGMP/TrkB)
  - Astrocyte gliotransmitters (modulatory)
- **Metabolic:** Lactate (energy), glutamine (precursor)

**Outgoing Signals:**

- **Primary:** Glutamate quantal release (packet size ∝ `P_r` × `vesicle_pool`)
- **Spillover:** Ambient glutamate affecting astrocyte/volume transmission

**Modulation Gates:**

- **Short-term:** Residual Ca²⁺ → ↑ `P_r` (facilitation)
- **Long-term:** eCB/NO/BDNF retrograde signals modify baseline `P_r`
- **Homeostatic:** Vesicle pool depletion → ↓ release (depression)

**Update Rules:**

- AP arrival → VGCC opening → `[Ca²⁺]_i` spike → vesicle fusion probability = `P_r`
- `P_r` = baseline × STF_factor × LTD/LTP_factor × homeostatic_factor
- Vesicle recycling with time constant τ\_recycle (seconds)

### Complete Model

#### 1. Short-Term Facilitation (STF)

- **Mechanism:** Activity-dependent **increase in release probability (P<sub>r</sub>)** due to accumulation of `residual_Ca²⁺` in the active zone.
- **Model Implementation:**
  - `residual_Ca²⁺` is a state variable that acts as a short-term memory buffer.
  - Each presynaptic spike injects a fixed amount of Ca²⁺ into `[Ca²⁺]_i`, which then decays exponentially with a fast time constant (τ\_Ca_fast \~ 10-50 ms). A fraction of this is added to `residual_Ca²⁺`, which decays with a slower time constant (τ\_Ca_slow \~ 100-500 ms).
  - The **STF_factor** = `1 + F_max * (residual_Ca²⁺ / (K_d + residual_Ca²⁺))`
  - Where `F_max` is the maximum facilitation strength and `K_d` is the half-saturation constant.
  - **Effect:** High-frequency spike trains cause `residual_Ca²⁺` to summate, progressively increasing the `STF_factor` and therefore `P_r` for subsequent spikes.

#### 2. Short-Term Depression (STD)

- **Mechanism:** Activity-dependent **decrease in release** due to depletion of the readily `releasable vesicle_pool`.
- **Model Implementation:**
  - Each successful release event (a stochastic outcome with probability `P_r`) reduces the `vesicle_pool` by one quantum.
  - Vesicles are replenished from a reserve pool with a **recovery time constant τ\_recycle** (e.g., 0.5 - 10 seconds).
  - The **homeostatic_factor** (or depletion factor) is simply the fraction of the pool that is available: `vesicle_pool / vesicle_pool_max`.
  - **Effect:** High-frequency firing depletes the pool faster than τ\_recycle can refill it. The `homeostatic_factor` drops, decreasing the *effective* release rate (`P_r * vesicle_pool`), even if `P_r` itself is high.

#### 3. Long-Term Modulation (LTP/LTD of Release)

- **Mechanism:** Retrograde chemical signals (**eCB, NO, BDNF**) induce biochemical cascades that **modify the baseline** `P_r` on timescales of minutes to hours.
- **Model Implementation:**
  - These  are triggered by specific postsynaptic activity patterns (e.g.,  postsynaptic Ca²⁺ spikes for eCB, strong depolarization for NO).
  - They act as **scaling factors on the baseline** `P_r`:
    - **eCB (via CB1R):** `LTD_factor = α_ECB` (where α\_ECB < 1, e.g., 0.7).
    - **NO/BDNF (via cGMP/TrkB):** `LTP_factor = β_NO` (where β\_NO > 1, e.g., 1.5).
  - The **LTD/LTP_factor** in your update rule is the product of these active factors (e.g., `α_ECB * β_NO`).
  - **Effect:** These factors change slowly, providing a sustained, experience-dependent up- or down-regulation of synaptic strength.

#### 4. Neuromodulator & Astrocyte Gates

- **Mechanism:** Diffuse signals (**lactate, glutamine, astrocyte gliotransmitters**) modulate the synapse's metabolic state and precursor availability.
- **Model Implementation:**
  - These are often modeled as **modifiers of parameters**, not direct state changes.
  - **Lactate (energy):** Influences `τ_recycle` and pump activity (Ca²⁺ clearance). Low lactate → slower τ\_recycle → accentuates STD.
  - **Glutamine (precursor):** Limits the total `vesicle_pool_max`. Low glutamine → smaller pool → faster depletion.
  - **Astrocyte signals (e.g., D-serine, ATP):** Can act as a multiplicative **gate** on the `STF_factor` or directly on the `baseline P_r`.

#### Integrated Update Rule Synthesis

Putting it all together, the release probability for a given vesicle upon AP arrival at time \*t\* becomes:

**P_r(t) = baseline_P_r × STF_factor(t) × LTD/LTP_factor × homeostatic_factor(t)**

Where:

- `STF_factor(t) = 1 + F_max * ( rCa(t) / (K_d + rCa(t)) )` **(Dynamic; updates per spike)**
- `rCa(t)` is the `residual_Ca²⁺` buffer, driven by `[Ca²⁺]_i` spikes.
- `LTD/LTP_factor = α_ECB * β_NO * ...` **(Quasi-static; changes on long timescales)**
- `homeostatic_factor(t) = vesicle_pool(t) / vesicle_pool_max` **(Dynamic; updates per release event)**

**Final Release Decision:** A random number is drawn. If it is `< P_r(t)`, a vesicle fuses, `vesicle_pool` is decremented, and glutamate is released. The `vesicle_pool` then recovers toward its maximum with the time constant `τ_recycle`.

This model captures the core **tension between facilitation (driven by Ca²⁺) and depression (driven by depletion)**,  while allowing for slower, homeostatic and Hebbian adjustments, making  it a powerful framework for simulating synaptic dynamics.

---

---

---

### **2. Postsynapse (Spine - Integration & Plasticity Unit)**

**Internal State Variables:**

- `V_m`: Local membrane potential
- `N_AMPA`: AMPA receptor count
- `N_NMDA`: NMDA receptor count
- `[Ca²⁺]_i`: Intracellular Ca²⁺
- `plasticity_tag`: Binary flag for eligibility
- `spine_volume`: Structural size

**Incoming Signals:**

- **Chemical:** Glutamate from presynapse
- **Electrical:** Dendritic voltage (for NMDA unblocking)
- **Backpropagating:** bAP from soma (timing signal)
- **Modulatory:** D-serine (astrocyte), neuromodulators
- **Structural:** BDNF, actin regulators

**Outgoing Signals:**

- **Primary:** EPSP current = `g_AMPA` × `(V_m - E_Na)` + `g_NMDA` × `(V_m - E_Ca)`
- **Retrograde:** eCB/NO/BDNF synthesis when `[Ca²⁺]_i` exceeds thresholds
- **Local:** Ca²⁺ signals to dendrite for spike initiation

**Modulation Gates:**

- **Voltage:** Mg²⁺ block on NMDA (relieved at depolarization)
- **Metabotropic:** mGluR → second messengers → receptor trafficking
- **Structural:** Actin polymerization ↔ spine growth/shrinkage

**Plasticity Rules:**

- **LTP:** `ΔN_AMPA` ∝ `[Ca²⁺]_i`^2 × `plasticity_tag` × kinase_activity
- **LTD:** `ΔN_AMPA` ∝ moderate `[Ca²⁺]_i` × phosphatase_activity
- **Scaling:** Global adjustment of all `N_AMPA` based on soma firing rate

### Complete Model

#### 1. Voltage-Dependent Gate (NMDA Receptor)

- **Mechanism:** The `NMDA_conductance` (`g_NMDA`) is not constant. It is *gated* by both glutamate binding and the relief of a voltage-dependent Mg²⁺ block.
- **Model Implementation (Instantaneous):**
  - `g_NMDA(t) = N_NMDA * γ * B(V_m(t))`
  - Where `γ` is the single-channel conductance, and `B(V_m)` is the magnesium unblock fraction.
  - `B(V_m) = 1 / (1 + η * [Mg²⁺] * exp(-ζ * V_m(t)))`
  - **Effect:** This function ensures NMDA receptors are only significant **coincidence detectors**. They pass current only when presynaptic glutamate release (`N_NMDA` is bound) AND postsynaptic depolarization (from `V_m` or bAP) occurs simultaneously.

#### 2. Biochemical Integration & Plasticity Triggers

- **Core Signal:** The key trigger for all plasticity is the postsynaptic **calcium transient** `[Ca²⁺]_i(t)`, which integrates multiple sources:
  - `[Ca²⁺]_i(t) = J_NMDA(t) + J_VGCC(t) + J_IP3(t)`
  - Where `J_NMDA` is Ca²⁺ influx through NMDA receptors, `J_VGCC` is from voltage-gated channels opened by bAPs, and `J_IP3` is from mGluR/second-messenger pathways.
- **LTP/LTD Decision Rule (Classic BCM-like Rule):**
  - A `plasticity_tag` is set to `1` if `[Ca²⁺]_i` crosses a moderate threshold (`θ_tag`) within a short time window (\~100ms). This marks the spine as "eligible."
  - The final change in `N_AMPA` is then determined by the peak/amplitude of the calcium signal:
    - **LTP:** If peak `[Ca²⁺]_i > θ_LTP` (a high threshold), then `ΔN_AMPA = +A_LTP * plasticity_tag`. This typically requires **strong, coincident** presynaptic glutamate AND a bAP.
    - **LTD:** If `θ_LTD < peak [Ca²⁺]_i < θ_LTP` (a moderate, sustained level), then `ΔN_AMPA = -A_LTD`. This can be triggered by presynaptic activity alone or weak pairing.
  - The **kinase_activity** and **phosphatase_activity** in your rule are functions of `[Ca²⁺]_i` (e.g., `kinase ∝ ([Ca²⁺]_i - θ_LTP)^2` for LTP).

#### 3. Retrograde Signal Synthesis

- **Mechanism:** The postsynaptic spine functions as a **signal interpreter and broadcaster**. Based on the calcium signal, it synthesizes specific retrograde messengers.
- **Model Implementation (Threshold Logic):**
  - **eCB synthesis:** Triggered if `[Ca²⁺]_i > θ_eCB`. eCB is then released, diffusing back to inhibit the presynaptic terminal (lowering `baseline P_r` via your presynaptic `LTD_factor`). This is often a form of heterosynaptic LTD.
  - **NO synthesis:** Triggered by a similar high `[Ca²⁺]_i` threshold coupled with activation of specific enzymes (e.g., nNOS). NO diffuses to the presynapse to increase `P_r` (your `LTP_factor`).
  - **BDNF synthesis:**  Slower, triggered by sustained calcium signals or specific gene  activation pathways. BDNF acts both presynaptically and postsynaptically  to promote structural changes.

#### 4. Structural & Metaplastic Modulation

- **Metabotropic (mGluR) Pathway:** Activated by sustained or spillover glutamate. It doesn't directly cause plasticity but **modulates the plasticity thresholds** (`θ_LTP`, `θ_LTD`). For example, mGluR activation can lower `θ_LTD`, making LTD easier to induce (metaplasticity).
- **Spine Volume (**`spine_volume`**):** This is a slow variable that couples to receptor counts.
  - `spine_volume(t+Δt) = spine_volume(t) + τ_vol * (N_AMPA(t) - κ * spine_volume(t))`
  - **Growth:** A sustained increase in `N_AMPA` (from LTP) promotes actin polymerization, increasing `spine_volume`.
  - **Shrinkage/Stabilization:** Conversely, a large, stable `spine_volume` creates slots for more `N_AMPA`, stabilizing the potentiation. This creates a positive feedback loop for strong, stable synapses.

#### 5. Homeostatic Scaling

- **Mechanism:** A global, cell-wide feedback mechanism to maintain the soma's average firing rate within a target range.
- **Model Implementation (Multiplicative):**
  - Periodically (e.g., every few hours of simulation time), the soma calculates its average firing rate `r_avg`.
  - If `r_avg` deviates from a target `r_target`, all `N_AMPA` on all synapses are scaled uniformly:
    - If `r_avg < r_target`: `N_AMPA = N_AMPA * β_up` (where `β_up > 1`). This is **up-scaling**.
    - If `r_avg > r_target`: `N_AMPA = N_AMPA * β_down` (where `β_down < 1`). This is **down-scaling**.
  - This rule is applied **independently** of the Hebbian `plasticity_tag`. It ensures network stability.

#### Integrated Synaptic Current & Update Cycle

The **EPSP current** driving the local `V_m` is:  
`I_syn(t) = (N_AMPA * g_unit_AMPA * B_AMPA(t)) * (V_m(t) - E_Na) + (g_NMDA(t)) * (V_m(t) - E_Ca)`

Where `B_AMPA(t)` is the fraction of AMPARs bound by glutamate (a transient pulse upon release).

**Simulation Cycle for a Spine:**

1. **Input:** Glutamate binds. bAP may arrive.
2. **Integration:** `V_m` depolarizes locally. Mg²⁺ block is relieved → `g_NMDA(t)` computed.
3. **Calcium:** `[Ca²⁺]_i(t)` is calculated from all sources.
4. **Decision:**
   - Set `plasticity_tag`.
   - Compute instantaneous `ΔN_AMPA` via the LTP/LTD calcium rule.
   - Trigger retrograde signal synthesis if thresholds crossed.
5. **Update:** Apply `ΔN_AMPA`. Slowly update `spine_volume`. Periodically apply global scaling.

This model captures the spine as a **coincidence detector, integrator, biochemical decoder, and structural adaptor**—a fundamental unit of learning and memory.

---

---

---

### **3. Dendrite (Branch - Pattern Detector)**

**Internal State Variables:**

- `V_m(z)`: Space-dependent membrane potential
- `[Ca²⁺]_i(z)`: Local Ca²⁺ concentration
- `NaV_density(z)`: Sodium channel distribution
- `VGCC_density(z)`: Calcium channel distribution
- `branch_excitability`: Global gain factor

**Incoming Signals:**

- **Local:** EPSPs from spines (summed spatially/temporally)
- **Global:** bAP from soma (teaching signal)
- **Modulatory:** Dopamine, acetylcholine (branch-specific)
- **Inhibitory:** GABA from interneurons

**Outgoing Signals:**

- **Active:** Dendritic spikes (Na⁺/Ca²⁺/NMDA) to soma
- **Passive:** Integrated voltage to soma
- **Local:** Retrograde signals to spines

**Integration Algorithm:**

```
if (sum(EPSPs) > threshold_local && bAP_within_window):
    generate_dendritic_spike()
    update_synaptic_tags(spikes_nearby)
else:
    passive_spread_to_soma()
```

**Branch-Specific Computation:**

- **Coincidence detection:** EPSP × bAP timing → STDP
- **Pattern separation:** Different branches learn different input combinations
- **Signal amplification:** Local spikes overcome cable attenuation

### Complete Model

#### 1. Integration Algorithm & Spike Generation

The decision logic can be formalized as a **multi-mechanism spike detector**:

text

```
function compute_branch_output(t):
    # 1. Local Integration (Spatio-temporal)
    V_local(t) = Σ_i Σ_τ EPSP_i(t - τ) * w_i(z)  # Sum over all spines i, with spatial weighting w_i based on distance z
    I_Ca_local(t) = VGCC_density(z) * g_Ca(V_local(t) - V_Ca_thresh) # Local calcium current

    # 2. Active Spike Generation (Threshold Logic)
    if (V_local(t) > θ_Na) and (NaV_density(z) > 0):
        generate_dendritic_Na_spike() # Fast, propagating
        dendritic_spike_amplitude = branch_excitability * NaV_density(z)

    elif ( [Ca²⁺]_i(z, t) > θ_Ca_spike ) and ( I_Ca_local(t) > 0 ):
        generate_dendritic_Ca_spike() # Slow, localized
        dendritic_spike_amplitude = branch_excitability * VGCC_density(z)

    # 3. Coincidence & Teaching Signal Integration
    bAP_signal = bAP(t) * attenuation_factor(z) # bAP strength decays with distance z from soma

    if dendritic_spike_occurs and (abs(t_dend_spike - t_bAP) < window_COINCIDENCE):
        # CRITICAL: Strong teaching signal for plasticity
        global_teaching_signal = bAP_signal * dendritic_spike_amplitude
        tag_eligible_spikes(spines_within_radius_R, global_teaching_signal)
        forward_output = dendritic_spike_amplitude # Active transmission

    else if V_local(t) > θ_passive:
        forward_output = V_local(t) * cable_properties(z) # Passive spread
    else:
        forward_output = 0
```

#### 2. Modulation of Branch Excitability & Pattern Separation

Branch-specific modulators (**dopamine, acetylcholine**) reconfigure the branch's **global gain and plasticity thresholds**:

- **Dopamine (D1 receptor):** Increases `branch_excitability` (↑ `NaV_density` sensitivity) and **lowers θ\_Na**. It also gates plasticity: `plasticity_enabled = dopamine_present and coincidence_detected`. This primes the branch for learning salient, reward-predicting patterns.
- **Acetylcholine (muscarinic):** Enhances `VGCC_density(z)` efficacy and NMDA conductance. It promotes **Ca²⁺ spike generation** over Na⁺ spikes, favoring slower, integrative pattern detection over fast propagation.
- **GABA Inhibition:** This is crucial for pattern separation. A GABAergic input onto the branch shunts `V_local(t)`:
  - `V_local_shunted(t) = V_local(t) / (1 + g_GABA(t) * R_input)`
  - By selectively inhibiting specific branches, interneurons **prevent those branches from reaching spike threshold**,  ensuring only the most strongly activated, distinct input combinations  generate output. This forces different branches to learn and respond to  different patterns.

#### 3. Spatial Computation & Weight Updates

The **pattern separation** emerges from the interaction of localized synaptic inputs and branch-wide thresholds:

1. **Input Pattern:** A set of active spines delivers EPSPs to `V_local(t)`.
2. **Branch Filter:** The combination of `NaV_density(z)`, `VGCC_density(z)`, `branch_excitability`, and local inhibition determines a **unique activation threshold** for that branch.
3. **Pattern Detection:** Only input combinations whose summed `V_local(t)` exceeds this threshold generate a dendritic spike. Slightly different patterns may fail, especially with GABAergic tuning.
4. **Synaptic Tagging (Credit Assignment):** When a dendritic spike coincides with a bAP, it generates a `global_teaching_signal`. This signal is broadcast **retrogradely** but **locally**, tagging all *recently active* spines within a spatial radius `R`. The tag's strength decays with distance from the spike initiation zone.
   - `spine[i].plasticity_tag += global_teaching_signal * exp(-distance(spine[i], spike_zone)/λ)`

#### 4. Internal State Variable Updates

- `[Ca²⁺]_i(z)`**:** Integrates from:
  - NMDA receptors at active spines.
  - `VGCC_density(z)` opened by `V_local(t)`.
  - Internal stores (IP3R) triggered by modulators.
  - Cleared by pumps with time constant `τ_Ca`.
- **Channel Densities (**`NaV_density(z)`**,** `VGCC_density(z)`**):** Can undergo slow, activity-dependent homeostatic plasticity.
  - `NaV_density(z) += η * (target_activity - dendritic_spike_rate)`
  - This allows branches to self-tune their excitability over long timescales.
- `branch_excitability`**:** A slow variable modulated by neuromodulators (↑ by DA) and metaplasticity rules.

#### Summary: The Branch as a Feature Detector

In this model, a dendritic branch is not a passive cable. It is an **active feature detector** with tunable properties:

- **Input:** A vector of synaptic inputs (spatially arranged).
- **Nonlinearity:** A double-threshold operation (Na⁺/Ca²⁺ spike generation) determined by its ion channel makeup and modulatory state.
- **Output:** Either a large, propagating dendritic spike (a **binary feature detection event**) or graded subthreshold voltage.
- **Learning:** Synapses on the branch are updated based on a **three-factor rule**:
  1. Presynaptic activity (glutamate release).
  2. Postsynaptic dendritic spike (local).
  3. Global teaching signal (bAP coincidence, modulated by DA).
- **Function:** Different branches, through their unique channel densities and inhibition, become selective for **different combinations of inputs**, implementing a powerful form of **dendritic pattern separation** that vastly expands the computational capacity of a single neuron.

---

---

---

### **4. Soma (Global Integrator & Policy Center)**

**Internal State Variables:**

- `V_m`: Global membrane potential
- `firing_rate_avg`: Moving average (hours scale)
- `[Ca²⁺]_i`: Somatic Ca²⁺ (integration of activity)
- `Ih_current`: HCN-mediated stabilizing current
- `sAHP`: Afterhyperpolarization magnitude
- `excitability_state`: Neuromodulator-dependent

**Incoming Signals:**

- **Convergent:** Summed dendritic inputs (EPSPs, dendritic spikes)
- **Inhibitory:** Direct perisomatic inhibition
- **Metabolic:** Lactate (energy), oxygen status
- **Global:** Neuromodulators (dopamine, serotonin, etc.)
- **Hormonal:** Corticosterone, estrogen, etc.

**Outgoing Signals:**

- **Primary:** Action potential (if `V_m` > threshold_AIS)
- **Backpropagating:** bAP to dendrites (teaching signal)
- **Homeostatic:** Scaling factors to all synapses
- **Transcriptional:** Nuclear signals for gene expression

**Integration Algorithm:**

```
V_m = integrate(dendritic_inputs, somatic_inputs, intrinsic_currents)
if V_m > threshold_AIS:
    fire_AP()
    send_bAP_to_dendrites()
    update_firing_rate_history()
    trigger_sAHP()
    
if firing_rate_avg deviates_from_target:
    calculate_scaling_factor()
    broadcast_to_all_synapses()
```

**Policy Functions:**

- **Gain control:** Adjust input resistance via K⁺ channels
- **Frequency adaptation:** sAHP limits sustained firing
- **State-dependent processing:** Neuromodulators reconfigure integration rules
- **Homeostasis:** Global scaling maintains firing rate setpoint

### Complete Model

#### 1. Integration & Spike Generation Algorithm

The soma's membrane potential `V_m(t)` is governed by a differential equation integrating all currents, not a simple sum:

text

```
function update_soma(V_m, t, dt):

    # 1. CURRENT INTEGRATION
    I_total = 0

    # Active Dendritic Inputs (Weighted)
    I_dend = Σ (dendritic_spike_i(t) * weight_i) + Σ (passive_EPSP_i(t) * cable_filter_i)
    I_total += I_dend

    # Perisomatic Inhibition (Fast, Powerful)
    I_GABA = g_GABA(t) * (V_m - E_GABA)  # Often Cl- based, E_GABA ~ -70 mV
    I_total += I_GABA

    # Intrinsic Somatic Currents (State-Dependent)
    I_Na_leak = g_Na_leak * (V_m - E_Na)
    I_K_leak = g_K_leak * (V_m - E_K)
    I_h = Ih_current * (V_m - E_h)  # HCN channel, depolarizing, activated by hyperpolarization
    I_sAHP = g_sAHP(t) * (V_m - E_K)  # Slow Ca²⁺-activated K⁺ current (builds up with spiking)

    I_total += I_Na_leak + I_K_leak + I_h + I_sAHP

    # Neuromodulator Effects (Instantiated as parameter changes)
    if dopamine_high:
        I_total *= (1 + gain_DA)          # Global gain increase
        threshold_AIS *= (1 - threshold_shift_DA) # Lowered firing threshold

    # 2. MEMBRANE POTENTIAL UPDATE
    dV_m/dt = (I_total) / C_m  # Standard membrane equation
    V_m(t+dt) = V_m(t) + dV_m/dt * dt

    # 3. SPIKE DECISION & POST-SPIKE ACTIONS
    if V_m(t+dt) > threshold_AIS:
        fire_AP()  # All-or-none event at Axon Initial Segment (AIS)
        
        # CRITICAL OUTPUTS:
        send_bAP_to_all_dendrites(amplitude = bAP_strength) # Primary teaching signal
        increment_spike_counter()
        
        # ADAPTATION MECHANISMS:
        [Ca²⁺]_i_soma += ΔCa_per_spike  # Somatic calcium accumulates
        g_sAHP(t) += Δg_sAHP  # Increment slow afterhyperpolarization conductance
        trigger_refractory_period(τ_refractory)

    # 4. SLOW VARIABLE UPDATES (Homeostasis)
    firing_rate_avg = exponential_moving_average(spike_counter, τ_avg_hours)
    update_excitability_state(neuromodulator_levels)
```

#### 2. Policy Functions: Specific Implementations

**A. Gain Control (Input Resistance Modulation):**

- Modulated via **leak potassium channels** (e.g., KCNQ, TASK).
- `g_K_leak = baseline_g_K_leak * (1 - α_ACh - β_Serotonin + γ_Corticosterone)`
- **ACh (muscarinic):** Decreases `g_K_leak` → increases input resistance `R_input` → **same synaptic current causes larger V_m depolarization** (↑ gain).
- **Effect:** The soma's responsiveness to dendritic inputs is dynamically scaled.

**B. Frequency Adaptation (sAHP - Slow AfterHyperPolarization):**

- A **calcium-dependent potassium current** that builds up with activity.
- `g_sAHP(t)` dynamics: `τ_sAHP * d(g_sAHP)/dt = -g_sAHP + β * [Ca²⁺]_i_soma`
- Each spike adds to somatic `[Ca²⁺]_i`, which slowly increases `g_sAHP`. This hyperpolarizes the cell, making it harder to reach threshold for subsequent spikes. **Prevents runaway excitation and encodes temporal derivatives.**

**C. State-Dependent Processing (Neuromodulator Reconfiguration):**  
This is the core "policy" shift. Neuromodulators don't just scale parameters; they switch operational modes:

- **Dopamine (via D1 receptors):**
  - ↑ `gain_DA` (as above).
  - ↓ `threshold_AIS` (easier to fire).
  - ↑ `bAP_strength` (enhances teaching signal to dendrites).
  - **Policy:** "EXPLORE/LEARN" mode. Increases sensitivity to inputs and reinforces active pathways.
- **Acetylcholine (ACh - cortical):**
  - ↓ `g_K_leak` (↑ gain, as above).
  - ↑ `I_h` current (stabilizes V_m, improves temporal integration).
  - **Policy:** "ATTENTION" mode. Enhances signal-to-noise ratio for salient, ongoing inputs.
- **Serotonin (5-HT):**
  - ↑ `g_K_leak` (↓ gain).
  - Modulates `I_h`.
  - **Policy:** "STABILITY/CAUTION" mode. Tones down overall excitability, promotes rhythmic activity.

**D. Homeostatic Set-Point Control (Firing Rate Stabilization):**

- The `firing_rate_avg` is compared to a `target_rate` (a genetically/inherently set point).
- If `|firing_rate_avg - target_rate| > tolerance` over a long window (hours):

  text

```
scaling_factor = target_rate / firing_rate_avg
broadcast_to_all_synapses({command: "scale_AMPA", factor: scaling_factor})
```

- This is the **global synaptic scaling** command sent to all synapses (as referenced in your postsynaptic model). It multiplicatively adjusts `N_AMPA` everywhere, a slow, cell-wide negative feedback loop.

#### 3. Soma as Transcriptional & Metabolic Hub

- **Somatic** `[Ca²⁺]_i` **Integration:** Sustained high `firing_rate_avg` leads to sustained elevated somatic `[Ca²⁺]_i`. This activates transcription factors (e.g., CREB).
- **Nuclear Signaling:** Triggers gene expression programs for:
  - **Structural proteins** (to grow dendrites/spines).
  - **More ion channels** (long-term excitability changes).
  - **Neurotrophic factors** (e.g., BDNF) released to further modify network.
- **Metabolic Gatekeeping:** The `lactate` and `oxygen` signals directly influence ATP production. Low energy → upregulate `I_h` and `g_K_leak` to **reduce metabolic cost** by lowering firing rate—a direct link from metabolism to excitability policy.

#### Summary: The Soma as Central Processor

In this model, the soma is not a simple point neuron. It is a **dynamic policy engine** that:

1. **Integrates** spatially and temporally filtered inputs from dendritic subunits.
2. **Generates** all-or-none output decisions (APs) based on a modifiable threshold.
3. **Broadcasts** teaching signals (bAPs) back to the dendritic computational layers.
4. **Adapts** its own sensitivity on short (sAHP) and long (channel expression) timescales.
5. **Reconfigures** its entire input-output function based on neuromodulatory state (gain, threshold, integration window).
6. **Orchestrates** whole-cell homeostasis via global scaling commands and transcriptional programs.

This transforms the classic "integrate-and-fire" unit into a **biological central processing unit (CPU) with dynamic clock speed, adjustable gain, and multiple feedback control systems**, all dedicated to maintaining stability while allowing for state-dependent, plastic computation.

---

---

---

### **5. Axon Initial Segment (Binary Decision Point)**

**Internal State Variables:**

- `V_m`: Local potential (lower threshold than soma)
- `NaV_availability`: Fraction of non-inactivated channels
- `refractory_state`: Absolute/relative refractory timing
- `threshold`: Dynamic spike threshold

**Incoming Signals:**

- **Somatic:** Integrated voltage
- **Modulatory:** Phosphorylation states (affecting NaV kinetics)

**Outgoing Signals:**

- **Primary:** All-or-none AP to axon
- **Backward:** bAP initiation to soma/dendrites

**Decision Algorithm:**

```
if (V_m > threshold && NaV_availability > 0.5 && !refractory):
    generate_AP()  # Stereotyped, high reliability
    NaV_availability = 0  # Begin inactivation
    start_refractory_timer()
```

**Dynamic Properties:**

- **Threshold plasticity:** Activity-dependent adjustment via channel phosphorylation
- **Reliability:** High safety factor ensures 1:1 input-output
- **Timing precision:** Submillisecond jitter

### Complete Model

#### 1. Decision Algorithm: State Machine Implementation

The AIS is modeled as a deterministic **state machine with dynamic thresholds**, not a simple `if` statement.

text

```
# STATE VARIABLES
V_m_AIS          # Local membrane potential (driven by somatic V_m with small delay & attenuation)
NaV_availability # Fraction of Nav channels NOT inactivated (0.0 to 1.0)
h_inf            # Steady-state inactivation (voltage-dependent)
τ_h              # Inactivation time constant
refractory_timer # Counts down from absolute refractory period
threshold_dynamic # Instantaneous firing threshold (can vary)
threshold_baseline # Resting threshold (e.g., -50 mV)

# DECISION CYCLE at time t
function evaluate_AIS(V_m_soma, t):

    # 1. UPDATE LOCAL STATE
    # Electrical coupling from soma (simplified)
    V_m_AIS = V_m_soma * coupling_factor_AIS - I_K_accumulated

    # Nav channel availability (recovery from inactivation)
    if refractory_timer <= 0:
        # Voltage-dependent steady-state inactivation
        h_inf = 1 / (1 + exp((V_m_AIS - V_half_inact) / k_inact))
        # Recovery towards h_inf
        dNaV_availability/dt = (h_inf - NaV_availability) / τ_h
        NaV_availability += dNaV_availability * dt
    else:
        refractory_timer -= dt

    # 2. DYNAMIC THRESOLD CALCULATION (critical for modulation)
    # Threshold adapts based on recent activity (Na channel phosphorylation state)
    threshold_dynamic = threshold_baseline + β * (1 - NaV_availability) + γ * I_K_accumulated
    # β: factor for inactivation-dependent increase
    # γ: factor for K⁺ current influence

    # 3. SPIKE GENERATION DECISION
    # The "high safety factor" is modeled as a steep, deterministic function
    if (V_m_AIS > threshold_dynamic) and (NaV_availability > θ_availability) and (refractory_timer <= 0):

        # GENERATE ACTION POTENTIAL (All-or-none)
        AP_amplitude = AP_max * NaV_availability  # Slightly smaller if not fully recovered
        send_AP_down_axon(velocity = f(axon_properties))
        initiate_bAP_to_soma_dendrites(amplitude = bAP_strength)

        # POST-SPIKE STATE RESETS
        NaV_availability = 0.0  # Immediate absolute inactivation
        refractory_timer = τ_abs_refractory  # e.g., 1-2 ms
        I_K_accumulated += ΔI_K_spike  # Accumulate slow K⁺ current (affects threshold)

        # THRESHOLD PLASTICITY UPDATE (Activity-dependent)
        threshold_baseline += η_thresh * (target_activity - recent_spike_rate)
        # Makes threshold higher if cell is too active, lower if too quiet (homeostatic)
```

#### 2. Dynamic Properties: Specific Mechanisms

**A. Threshold Plasticity & Modulation**  
This is a key regulatory point. The `threshold_baseline` is not fixed; it's a **homeostatically regulated variable** and a **target for neuromodulation**.

- **Activity-Dependent (Homeostatic):** As shown above, sustained high `recent_spike_rate` increases `threshold_baseline`, making the neuron harder to fire (negative feedback).
- **Phosphorylation-Dependent (Modulatory):** Kinases activated by neuromodulators (PKA, PKC, CK2) phosphorylate specific sites on Nav channels (e.g., Naᵥ1.6).
  - **PKA Phosphorylation (e.g., via DA/NE):** Shifts `V_half_inact` to more **depolarized** voltages → increases `h_inf` at resting V_m → effectively **increases NaV_availability** and **lowers effective threshold**. **Policy:** *Lower threshold, increase excitability.*
  - **CK2 Phosphorylation:** Can shift activation `V_half_act` to more **hyperpolarized** voltages → channels open easier → **lowers threshold**. **Policy:** *Increase temporal precision and reliability.*

**B. Reliability (High Safety Factor)**  
This is modeled implicitly by the steepness of the Nav activation curve and the high channel density.

- The condition `(V_m_AIS > threshold_dynamic)` is not a linear probability. It's a **step function** because the activation variable `m` of Nav channels is a steep sigmoid:
  - `m_inf = 1 / (1 + exp((V_half_act - V_m_AIS)/k_act))`
  - With a high density of channels, once `V_m_AIS` crosses `threshold_dynamic` (where `m_inf` becomes significant), the positive feedback of Na⁺ influx is explosive and deterministic. There is no stochastic "maybe" spike.

**C. Timing Precision (Submillisecond Jitter)**  
Jitter is minimized by three model features:

1. **Rapid Kinetics:** Very small `τ_m` (activation time constant) for AIS Nav channels (\~0.1 ms).
2. **High dV/dt:** The somatic `V_m`  must rise rapidly to cross the AIS threshold. Slow ramps will not  trigger a precise spike. This is enforced by the requirement for a  strong, synchronous dendritic input to create a fast somatic  depolarization.
3. **Refractory State Clarity:** The absolute refractory period (`τ_abs_refractory`) is a hard lockout. The relative refractory period is modeled by the recovery of `NaV_availability` and the elevated `threshold_dynamic` post-spike, which together sharply define the earliest possible next spike time.

#### 3. Role in Backpropagation (bAP) Initiation

The AIS is the **source** of the backpropagating action potential.

- Upon AIS spike generation, the depolarizing current not only propagates down the axon but also **actively back-invades** the soma and dendrites.
- `bAP_strength`  in the model can be modulated (e.g., increased by dopamine signaling),  affecting the amplitude of this critical teaching signal throughout the  dendritic tree.

#### Summary: The AIS as a Programmable Binary Converter

In this model, the Axon Initial Segment is the **final, decisive policy layer**:

- **Input:** Graded somatic membrane potential (`V_m_soma`).
- **Processing:** A dynamic threshold function, gated by channel availability and phosphorylation state.
- **Output:** A stereotyped action potential (or not) with high temporal fidelity.
- **Key Modulation:** Its **excitability is tunable** via:
  - **Homeostatic Threshold Plasticity:** Keeps average firing rate in check.
  - **Phosphorylation States:** Allow neuromodulators (DA, NE, ACh) to directly adjust the "trigger happiness" of the neuron on fast timescales.
  - **Refractory Kinetics:** Control maximum firing frequency and temporal precision.

This transforms the AIS from a passive fuse into an **active, tunable decision node**  that finalizes the neuron's output based on integrated somatic  potential, while itself being subject to meta-level policy controls that  set the neuron's overall responsiveness and reliability.

---

---

---

### **6. Astrocyte (Metabolic Hub & Environment Manager)**

**Internal State Variables:**

- `[Ca²⁺]_i`: Cytosolic Ca²⁺ (can exhibit waves)
- `[glutamate]_cleft`: Synaptic glutamate concentration
- `[K⁺]_ext`: Extracellular K⁺
- `glycogen_stores`: Energy reserves
- `lactate_production_rate`: Metabolic output
- `adenosine_level`: Sleep pressure signal

**Incoming Signals:**

- **Glutamate spillover:** From synapses (via EAAT1/2)
- **K⁺ efflux:** From neuronal firing
- **Neuromodulators:** Noradrenaline, ATP
- **Metabolic:** Glucose from blood, oxygen status

**Outgoing Signals:**

- **Recycling:** Glutamine to neurons
- **Energy:** Lactate to neurons
- **Modulatory:** D-serine, ATP, glutamate (gliotransmitters)
- **Vasomodulatory:** Prostaglandins to blood vessels
- **Homeostatic:** Adenosine (sleep pressure)
- **Waste removal:** Aβ clearance facilitation

**Multi-Timescale Integration:**

```
# Milliseconds: 
uptake_glutamate_and_K⁺()

# Seconds: 
if [Ca²⁺]_i > threshold:
    release_gliotransmitters(D_serine, ATP)

# Minutes: 
glycogen → lactate → export_to_neurons()
adjust_blood_flow(based_on_activity)

# Hours: 
accumulate_adenosine(proportional_to_activity_history)
orchestrate_glymphatic_clearance(during_sleep)
```

**Core Functions:**

- **Ion homeostasis:** K⁺ buffering, pH regulation
- **Metabolic coupling:** Lactate shuttle during high demand
- **Synaptic modulator:** D-serine for NMDA function
- **Network stabilizer:** Adenosine accumulation enforces sleep
- **Waste manager:** Glymphatic clearance coordination

### Complete Model

#### 1. Multi-Timescale Integration Algorithm

The astrocyte is a **hybrid continuous/discrete controller** that operates on four distinct timescales. Its core logic can be modeled as:

text

```
# ASTROCYTE STATE MACHINE - Update at each simulation timestep dt (e.g., 1 ms)
function update_astrocyte(t, dt, local_activity):

    # ---- MILLISECOND SCALE (Continuous, Fast Feedback) ----
    # 1. ION & TRANSMITTER HOMEOSTASIS (Instantaneous uptake)
    glutamate_cleft[t] -= (EAAT_rate * glutamate_cleft[t]) * dt
    K_ext[t] -= (NKCC1_rate * (K_ext[t] - K_target)) * dt
    [Ca²⁺]_i[t] += (leak - SERCA_pump * [Ca²⁺]_i[t]) * dt

    # 2. FAST CHEMICAL DETECTION (Triggers for slower processes)
    if glutamate_cleft[t] > θ_glu_high:  # Detects spillover (excessive activity)
        trigger_IP3_production()
    if K_ext[t] > θ_K_high:               # Detects high extracellular K+ (seizure risk)
        activate_KIR_channels() # Immediate buffering

    # ---- SECOND TO MINUTE SCALE (Discrete Events, State Changes) ----
    # 3. CALCIUM-DEPENDENT GLIOTRANSMITTER RELEASE (Slow, phasic)
    if [Ca²⁺]_i[t] > θ_Ca_release and !cooldown_active:
        # Release is a discrete packet, not continuous
        release_gliotransmitter_packet("D_serine", amount = f([Ca²⁺]_i))
        release_gliotransmitter_packet("ATP", amount = g([Ca²⁺]_i))
        start_cooldown_timer(τ_cooldown) # Prevent constant release

    # 4. METABOLIC COUPLING (Activity-dependent energy supply)
    energy_demand_estimate = integrate(glutamate_uptake_rate, window=60s)
    lactate_production_rate[t] = (glycogen_stores / τ_glycogen) * tanh(energy_demand_estimate)
    export_lactate_to_local_neurons(lactate_production_rate[t] * dt)

    # ---- MINUTE TO HOUR SCALE (Integrative, Tonic Signals) ----
    # 5. VASOMODULATION & BLOOD FLOW CONTROL
    activity_integral_5min = moving_average(local_neuronal_firing, τ=5min)
    if t % (1*minute) == 0: # Update blood flow signal periodically
        prostaglandin_release = α * activity_integral_5min
        dilate_local_vasculature(prostaglandin_release)

    # 6. SLEEP PRESSURE ACCUMULATION (Adenosine - Very Slow Integrator)
    # Adenosine accumulates proportional to total glutamate uptake (proxy for neural work)
    adenosine_production_rate = β * glutamate_uptake_total
    adenosine_level[t] += (adenosine_production_rate - clearance_rate_adenosine) * dt

    # 7. WASTE MANAGEMENT CYCLE (Linked to sleep state)
    if is_sleep_cycle(t): # External circadian/sleep signal
        switch_to_glymphatic_mode() # Increase Aβ clearance rate 10x
        glycogen_stores += replenish_rate * dt
    else:
        switch_to_synaptic_support_mode()
```

#### 2. Core Functions: Specific Models

**A. Ion Homeostasis (K⁺ & pH Buffer)**

- **K⁺ Buffering (Spatial K⁺ Siphoning):**
  - `d[K⁺]_ext/dt = neuronal_K⁺_release - KIR_uptake([K⁺]_ext) - diffusion`
  - **KIR Channel Model:** `I_KIR = g_KIR_max * sqrt([K⁺]_ext/3) * (V_m - E_K)` (nonlinear uptake).
  - Astrocytes form a **spatial network**; elevated K⁺ in one area is siphoned through gap junctions to areas with lower \[K⁺\].

**B. Metabolic Coupling (Lactate Shuttle)**

- **Energy Demand Sensing:** `glutamate_uptake_flux = EAAT_rate * [glu]_cleft`
  - EAATs co-transport Na⁺, requiring ATP to restore gradients → direct link between glutamate and energy demand.
- **Astrocyte-Neuron Lactate Shuttle (ANLS) Model:**
  - `lactate_production = (glycogen_stores / (K_M + glycogen_stores)) * (1 + sigmoid(glutamate_uptake_flux))`
  - Lactate is exported via **MCT1/4 transporters** proportional to neuronal activity.

**C. Synaptic Modulation (D-serine Release)**

- **D-serine as a Volumetric Neuromodulator:**
  - D-serine is the primary co-agonist for **synaptic NMDA receptors**.
  - Release model: `[D_serine]_release = R_max * ([Ca²⁺]_i^4 / (K_D^4 + [Ca²⁺]_i^4))` (highly nonlinear, cooperative).
  - This effectively **gates synaptic plasticity**: only synapses under active astrocytic "supervision" (high Ca²⁺ in astrocyte) have fully functional NMDARs and can undergo LTP.

**D. Network Stabilizer (Adenosine Accumulation)**

- **Sleep Pressure as a Leaky Integrator:**
  - `d[adenosine]/dt = k_production * ∫(glutamate_uptake) - k_clearance * [adenosine]`
  - Adenosine acts on neuronal **A1 receptors**, universally inhibiting synaptic release (presynaptic) and excitability.
  - **This is a global negative feedback loop:** High network activity → more astrocytic glutamate uptake → more adenosine → stronger network-wide inhibition → enforced **activity quota** leading to sleep.

**E. Waste Manager (Glymphatic Coordination)**

- **State-Dependent Clearance:**
  - During sleep/wake cycle, astrocyte **aquaporin-4 (AQP4)** polarization changes.
  - `clearance_rate_Aβ = baseline_clearance * (1 + 10 * sleep_state)`
  - Astrocytes dynamically regulate **perivascular space** volume to facilitate convective flow of cerebrospinal fluid during sleep, clearing metabolites like Aβ.

#### 3. Modulation of the Astrocyte

The astrocyte itself is modulated by:

- **Noradrenaline (from locus coeruleus):** ↑ `IP3 production` → ↑ `[Ca²⁺]_i` waves → potentiates gliotransmitter release. **Policy:** *Alertness mode* – enhances astrocytic support for heightened neural activity.
- **ATP/Purinergic Signaling:** From active neurons or other astrocytes. Can propagate **Ca²⁺ waves** across the astrocyte syncytium, enabling long-range coordination of homeostatic states.

#### Summary: The Astrocyte as a Multi-Scale Regulator

This model presents the astrocyte as a **biological real-time operating system (RTOS)** for the brain microenvironment:

1. **Fast (ms):** I/O manager – buffers ions, clears neurotransmitters.
2. **Medium (s-min):** Resource manager – allocates energy (lactate), modulates synapses (D-serine).
3. **Slow (hrs):**  System administrator – enforces sleep quotas (adenosine), schedules  garbage collection (glymphatics), manages long-term resources  (glycogen).

It introduces **critical non-neuronal constraints** into the neural network model:

- **Energy is limited and dynamically allocated.**
- **Waste products accumulate and must be cleared.**
- **Ionic balance must be maintained to prevent instability (seizures).**
- **Synaptic plasticity is chemically gated by glial oversight.**

In the full system model, the astrocyte is the **homeostatic backdrop**  against which the neuron's computational drama plays out—a dynamic  environment that both supports and constrains neural activity,  ultimately ensuring the system's long-term stability and health.

---

---

---

## System-Wide Integration Principles

### Signal Flow Architecture:

```
Presynapse → Postsynapse → Dendrite → Soma → AIS → AP
      ↑          ↓           ↑        ↓      ↑
      ←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←
      Retrograde Signals & Global Modulation
      ↓          ↑           ↓        ↑      ↓
Astrocyte ←→ Environment ←→ Blood Flow ←→ Systemic
```

### Timescale Integration:

- **Fast (ms):** Electrical → chemical → electrical transformation
- **Medium (s-min):** Retrograde modulation, metabolic support
- **Slow (hrs-days):** Structural change, homeostatic scaling
- **Very slow (days-lifetime):** Epigenetic, system consolidation

### Key Cross-Component Dependencies:

1. **Activity → Metabolism:** Neuronal firing → glutamate/K⁺ release → astrocyte activation → lactate production
2. **Metabolism → Plasticity:** Lactate availability → ATP production → protein synthesis → structural change
3. **Structure → Function:** Spine growth → more AMPA receptors → larger EPSPs → easier dendritic spike initiation
4. **Past → Future:** Firing history → somatic Ca²⁺ integration → gene expression → receptor changes → future excitability

This model architecture creates a **recursive optimization system** where each component's behavior adjusts based on both immediate inputs and long-term trends, with astrocytes providing the essential metabolic and environmental context that makes sustained neural computation possible.
