kmatrix¶
Pairwise integration analysis.
toric_spines_sim.kmatrix
¶
Pairwise synapse interaction (k-matrix) helpers.
For two synapses i and j driven at rates (λ_i, λ_j), run three simulations (i only, j only, both) and fit
V_{ij} - V_i - V_j = k * V_i * V_j
on the baseline-subtracted sink (or other probe) voltage. Uses
TSSimulator so custom NMODL synapses and gap junctions stay consistent
with the rest of the package.
simulation(swc_filepath, synpts_filepath, input_rates_hz, parameters, record_point, event_type='poisson', probe_label='probe_0')
¶
Run one TSSimulator job with per-synapse rates and a single probe.
Source code in toric_spines_sim/kmatrix.py
simulation_probe_dict(swc_filepath, synpts_filepath, input_rates_hz, parameters, record_point, event_type='poisson', probe_label='probe_0')
¶
Like simulation but returns the older {"probe": arbor-samples, ...} dict.
Notebooks that call add_time_series_from_arbor(results["probe"]) can
import this as simulation.
Source code in toric_spines_sim/kmatrix.py
compute_pairwise_voltages(total_synapses, active_synapse_pair, rate_pair, swc_filepath, synpts_filepath, parameter_bank, record_point, seeds, probe_label='probe_0', event_type='poisson')
¶
Baseline-subtracted voltages V(i), V(j), and V(i+j) over seeds.
Source code in toric_spines_sim/kmatrix.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
solve_k_linreg(v_1, v_2, v_12)
¶
Fit V_ij - V_i - V_j = k * V_i * V_j with a linear regression.
Flattened arrays from one or more seeds are pooled. The slope is k;
an intercept is also returned (usually near zero).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v_1
|
array_like
|
Baseline-subtracted voltages for synapse i, j, and both. |
required |
v_2
|
array_like
|
Baseline-subtracted voltages for synapse i, j, and both. |
required |
v_12
|
array_like
|
Baseline-subtracted voltages for synapse i, j, and both. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
|
Examples:
>>> import numpy as np
>>> v_1 = np.array([1.0, 2.0])
>>> v_2 = np.array([1.0, 2.0])
>>> v_12 = v_1 + v_2 + 0.5 * v_1 * v_2
>>> solve_k_linreg(v_1, v_2, v_12)["coeffs"][0]
np.float64(0.5)
Source code in toric_spines_sim/kmatrix.py
compute_k_matrix(total_synapses, active_synapse_pair, rate_list, swc_filepath, synpts_filepath, parameter_bank, record_location, seeds, probe_label='probe_0', event_type='poisson')
¶
Fill a symmetric k-matrix over an outer product of rates for one pair.
For each unordered rate pair (rate_list[i], rate_list[j]) with
j <= i, run compute_pairwise_voltages and store the fitted k.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
total_synapses
|
int
|
Length of the synapse points file (inactive synapses get rate 0). |
required |
active_synapse_pair
|
tuple of int
|
0-based indices |
required |
rate_list
|
list of float
|
Rates (Hz) whose outer product fills the matrix. |
required |
swc_filepath
|
str
|
Morphology and synapse-point files. |
required |
synpts_filepath
|
str
|
Morphology and synapse-point files. |
required |
parameter_bank
|
ParameterBank
|
Mutated in place for |
required |
record_location
|
tuple of float
|
Probe XYZ (often the sink tip). |
required |
seeds
|
list of int
|
Poisson seeds averaged in the linear fit. |
required |
probe_label
|
str
|
Column name in |
'probe_0'
|
event_type
|
('poisson', 'periodic')
|
|
'poisson'
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Examples:
>>> out = compute_k_matrix(
... total_synapses=25,
... active_synapse_pair=(0, 1),
... rate_list=[10.0, 50.0],
... swc_filepath="data/swc/microns/TS1_wsink_r10um.swc",
... synpts_filepath="data/pointsets/microns/TS1_synpts.txt",
... parameter_bank=bank,
... record_location=(0.0, 0.0, 0.0),
... seeds=[0, 1],
... )
>>> out["k_matrix"].shape
(2, 2)
Source code in toric_spines_sim/kmatrix.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | |