31
+ 29
+ 30
+ 31
32
33
34
@@ -13243,9 +13245,7 @@
268
269
270
-271
-272
-273 | | class Cell(Module):
"""Cell class.
This class defines a single cell that can be simulated by itself or
@@ -13586,7 +13586,9 @@
Source code in jaxley/modules/cell.py
- 42
+ 40
+ 41
+ 42
43
44
45
@@ -13676,9 +13678,7 @@
129
130
131
-132
-133
-134 | | def __init__(
self,
branches: Optional[Union[Branch, List[Branch]]] = None,
parents: Optional[List[int]] = None,
diff --git a/dev/reference/utils/index.html b/dev/reference/utils/index.html
index fe565842..a5d4a09b 100644
--- a/dev/reference/utils/index.html
+++ b/dev/reference/utils/index.html
@@ -753,6 +753,15 @@
+
+
+
+
+
+ build_radiuses_from_xyzr
+
+
+
@@ -1014,33 +1023,6 @@
-
-
-
-
-
- swc
-
-
-
-
-
-
-
-
- build_radiuses_from_xyzr
-
-
-
-
-
-
-
-
- swc_to_jaxley
-
-
-
@@ -1166,6 +1148,15 @@
+
+
+
+
+
+ build_radiuses_from_xyzr
+
+
+
@@ -1427,33 +1418,6 @@
-
-
-
-
-
- swc
-
-
-
-
-
-
-
-
- build_radiuses_from_xyzr
-
-
-
-
-
-
-
-
- swc_to_jaxley
-
-
-
@@ -1536,6 +1500,168 @@ Utils
+
+
+
+
+ build_radiuses_from_xyzr(radius_fns, branch_indices, min_radius, nseg)
+
+
+
+
+
+
+ Return the radiuses of branches given SWC file xyzr.
+ Returns an array of shape (num_branches, nseg) .
+
+
+ Parameters:
+
+
+
+ Name |
+ Type |
+ Description |
+ Default |
+
+
+
+
+
+ radius_fns
+ |
+
+ List[Callable]
+ |
+
+
+ Functions which, given compartment locations return the radius.
+
+ |
+
+ required
+ |
+
+
+
+ branch_indices
+ |
+
+ List[int]
+ |
+
+
+ The indices of the branches for which to return the radiuses.
+
+ |
+
+ required
+ |
+
+
+
+ min_radius
+ |
+
+ Optional[float]
+ |
+
+
+ If passed, the radiuses are clipped to be at least as large.
+
+ |
+
+ required
+ |
+
+
+
+ nseg
+ |
+
+ int
+ |
+
+
+ The number of compartments that every branch is discretized into.
+
+ |
+
+ required
+ |
+
+
+
+
+
+ Source code in jaxley/utils/cell_utils.py
+ 254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284 | def build_radiuses_from_xyzr(
+ radius_fns: List[Callable],
+ branch_indices: List[int],
+ min_radius: Optional[float],
+ nseg: int,
+) -> jnp.ndarray:
+ """Return the radiuses of branches given SWC file xyzr.
+
+ Returns an array of shape `(num_branches, nseg)`.
+
+ Args:
+ radius_fns: Functions which, given compartment locations return the radius.
+ branch_indices: The indices of the branches for which to return the radiuses.
+ min_radius: If passed, the radiuses are clipped to be at least as large.
+ nseg: The number of compartments that every branch is discretized into.
+ """
+ # Compartment locations are at the center of the internal nodes.
+ non_split = 1 / nseg
+ range_ = np.linspace(non_split / 2, 1 - non_split / 2, nseg)
+
+ # Build radiuses.
+ radiuses = np.asarray([radius_fns[b](range_) for b in branch_indices])
+ radiuses_each = radiuses.ravel(order="C")
+ if min_radius is None:
+ assert np.all(
+ radiuses_each > 0.0
+ ), "Radius 0.0 in SWC file. Set `read_swc(..., min_radius=...)`."
+ else:
+ radiuses_each[radiuses_each < min_radius] = min_radius
+
+ return radiuses_each
+
|
+
+
+
+
+
@@ -1553,68 +1679,68 @@
Source code in jaxley/utils/cell_utils.py
- 416
-417
-418
-419
-420
-421
-422
-423
-424
-425
-426
-427
-428
-429
-430
-431
-432
-433
-434
-435
-436
-437
-438
-439
-440
-441
-442
-443
-444
-445
-446
-447
-448
-449
-450
-451
-452
-453
-454
-455
-456
-457
-458
-459
-460
-461
-462
-463
-464
-465
-466
-467
-468
-469
-470
-471
-472
-473
-474
-475
-476
-477 | def compute_axial_conductances(
+ 688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749 | def compute_axial_conductances(
comp_edges: pd.DataFrame, params: Dict[str, jnp.ndarray]
) -> jnp.ndarray:
"""Given `comp_edges`, radius, length, r_a, cm, compute the axial conductances.
@@ -1697,15 +1823,15 @@
Source code in jaxley/utils/cell_utils.py
- 480
-481
-482
-483
-484
-485
-486
-487
-488 | def compute_children_and_parents(
+ 752
+753
+754
+755
+756
+757
+758
+759
+760 | def compute_children_and_parents(
branch_edges: pd.DataFrame,
) -> Tuple[jnp.ndarray, jnp.ndarray, jnp.ndarray, int]:
"""Build indices used during `._init_morph_custom_spsolve()."""
@@ -1739,20 +1865,20 @@
Source code in jaxley/utils/cell_utils.py
- 167
-168
-169
-170
-171
-172
-173
-174
-175
-176
-177
-178
-179
-180 | def compute_children_indices(parents) -> List[jnp.ndarray]:
+ 439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452 | def compute_children_indices(parents) -> List[jnp.ndarray]:
"""Return all children indices of every branch.
Example:
@@ -1792,18 +1918,18 @@
Source code in jaxley/utils/cell_utils.py
- 227
-228
-229
-230
-231
-232
-233
-234
-235
-236
-237
-238 | def compute_coupling_cond(rad1, rad2, r_a1, r_a2, l1, l2):
+ 499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510 | def compute_coupling_cond(rad1, rad2, r_a1, r_a2, l1, l2):
"""Return the coupling conductance between two compartments.
Equations taken from `https://en.wikipedia.org/wiki/Compartmental_neuron_models`.
@@ -1846,27 +1972,27 @@
Source code in jaxley/utils/cell_utils.py
- 241
-242
-243
-244
-245
-246
-247
-248
-249
-250
-251
-252
-253
-254
-255
-256
-257
-258
-259
-260
-261 | def compute_coupling_cond_branchpoint(rad, r_a, l):
+ 513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533 | def compute_coupling_cond_branchpoint(rad, r_a, l):
r"""Return the coupling conductance between one compartment and a comp with l=0.
From https://en.wikipedia.org/wiki/Compartmental_neuron_models
@@ -1915,19 +2041,19 @@
Source code in jaxley/utils/cell_utils.py
- 264
-265
-266
-267
-268
-269
-270
-271
-272
-273
-274
-275
-276 | def compute_impact_on_node(rad, r_a, l):
+ 536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548 | def compute_impact_on_node(rad, r_a, l):
r"""Compute the weight with which a compartment influences its node.
In order to satisfy Kirchhoffs current law, the current at a branch point must be
@@ -1962,25 +2088,25 @@
Source code in jaxley/utils/cell_utils.py
- 360
-361
-362
-363
-364
-365
-366
-367
-368
-369
-370
-371
-372
-373
-374
-375
-376
-377
-378 | def compute_morphology_indices_in_levels(
+ 632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650 | def compute_morphology_indices_in_levels(
num_branchpoints,
child_belongs_to_branchpoint,
par_inds,
@@ -2089,24 +2215,24 @@
Source code in jaxley/utils/cell_utils.py
- 325
-326
-327
-328
-329
-330
-331
-332
-333
-334
-335
-336
-337
-338
-339
-340
-341
-342 | def convert_point_process_to_distributed(
+ 597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614 | def convert_point_process_to_distributed(
current: jnp.ndarray, radius: jnp.ndarray, length: jnp.ndarray
) -> jnp.ndarray:
"""Convert current point process (nA) to distributed current (uA/cm2).
@@ -2177,15 +2303,15 @@
Source code in jaxley/utils/cell_utils.py
- 15
-16
-17
-18
-19
-20
-21
-22
-23 | def equal_segments(branch_property: list, nseg_per_branch: int):
+ 287
+288
+289
+290
+291
+292
+293
+294
+295 | def equal_segments(branch_property: list, nseg_per_branch: int):
"""Generates segments where some property is the same in each segment.
Args:
@@ -2215,20 +2341,20 @@
Source code in jaxley/utils/cell_utils.py
- 183
-184
-185
-186
-187
-188
-189
-190
-191
-192
-193
-194
-195
-196 | def get_num_neighbours(
+ 455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468 | def get_num_neighbours(
num_children: jnp.ndarray,
nseg_per_branch: int,
num_branches: int,
@@ -2265,24 +2391,24 @@
Source code in jaxley/utils/cell_utils.py
- 381
-382
-383
-384
-385
-386
-387
-388
-389
-390
-391
-392
-393
-394
-395
-396
-397
-398 | def group_and_sum(
+ 653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670 | def group_and_sum(
values_to_sum: jnp.ndarray, inds_to_group_by: jnp.ndarray, num_branchpoints: int
) -> jnp.ndarray:
"""Group values by whether they have the same integer and sum values within group.
@@ -2373,21 +2499,21 @@
Source code in jaxley/utils/cell_utils.py
- 291
-292
-293
-294
-295
-296
-297
-298
-299
-300
-301
-302
-303
-304
-305 | def interpolate_xyzr(loc: float, coords: np.ndarray):
+ 563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577 | def interpolate_xyzr(loc: float, coords: np.ndarray):
"""Perform a linear interpolation between xyz-coordinates.
Args:
@@ -2470,30 +2596,30 @@
Source code in jaxley/utils/cell_utils.py
- 26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49 | def linear_segments(
+ 298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321 | def linear_segments(
initial_val: float, endpoint_vals: list, parents: jnp.ndarray, nseg_per_branch: int
):
"""Generates segments where some property is linearly interpolated.
@@ -2538,12 +2664,12 @@
Source code in jaxley/utils/cell_utils.py
- 219
-220
-221
-222
-223
-224 | def loc_of_index(global_comp_index, global_branch_index, nseg_per_branch):
+ 491
+492
+493
+494
+495
+496 | def loc_of_index(global_comp_index, global_branch_index, nseg_per_branch):
"""Return location corresponding to global compartment index."""
cumsum_nseg = cumsum_leading_zero(nseg_per_branch)
index = global_comp_index - cumsum_nseg[global_branch_index]
@@ -2657,24 +2783,24 @@
Source code in jaxley/utils/cell_utils.py
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|