Connectors API Reference
This page provides API reference documentation for the Connectors module, which contains classes and functions for creating complex connectivity patterns in BMTK networks.
Utility Functions
bmtool.connectors.num_prop(ratio, N)
Calculate numbers of total N in proportion to ratio.
Parameters:
ratio : array-like Proportions to distribute N across. N : int Total number to distribute.
Returns:
numpy.ndarray Array of integers that sum to N, proportionally distributed according to ratio.
Source code in bmtool/connectors.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
bmtool.connectors.decision(prob, size=None)
Make random decision(s) based on input probability.
Parameters:
prob : float Probability threshold between 0 and 1. size : int or tuple, optional Size of the output array. If None, a single decision is returned.
Returns:
bool or numpy.ndarray Boolean result(s) of the random decision(s). True if the random number is less than prob, False otherwise.
Source code in bmtool/connectors.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
bmtool.connectors.decisions(prob)
Make multiple random decisions based on input probabilities.
Parameters:
prob : array-like Array of probability thresholds between 0 and 1.
Returns:
numpy.ndarray Boolean array with the same shape as prob, containing results of the random decisions.
Source code in bmtool/connectors.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
bmtool.connectors.euclid_dist(p1, p2)
Euclidean distance between two points p1, p2: Coordinates in numpy array
Source code in bmtool/connectors.py
79 80 81 82 83 84 85 |
|
bmtool.connectors.spherical_dist(node1, node2)
Spherical distance between two input nodes
Source code in bmtool/connectors.py
88 89 90 |
|
bmtool.connectors.cylindrical_dist_z(node1, node2)
Cylindircal distance between two input nodes (ignoring z-axis)
Source code in bmtool/connectors.py
93 94 95 |
|
Probability Functions
bmtool.connectors.ProbabilityFunction
Bases: ABC
Abstract base class for connection probability function
Source code in bmtool/connectors.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
__call__(*arg, **kwargs)
abstractmethod
Return probability within [0, 1] for single input
Source code in bmtool/connectors.py
107 108 109 110 |
|
decisions(*arg, **kwargs)
abstractmethod
Return bool array of decisions according probability
Source code in bmtool/connectors.py
112 113 114 115 |
|
probability(*arg, **kwargs)
abstractmethod
Allow numpy array input and return probability in numpy array
Source code in bmtool/connectors.py
102 103 104 105 |
|
bmtool.connectors.DistantDependentProbability
Bases: ProbabilityFunction
Base class for distance dependent probability
Source code in bmtool/connectors.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
__call__(dist, *arg, **kwargs)
Return probability for single distance input
Source code in bmtool/connectors.py
125 126 127 128 129 130 |
|
decisions(dist)
Return bool array of decisions given distance array
Source code in bmtool/connectors.py
132 133 134 135 136 137 138 139 140 141 |
|
bmtool.connectors.UniformInRange
Bases: DistantDependentProbability
Constant probability within a distance range
Source code in bmtool/connectors.py
144 145 146 147 148 149 150 151 152 153 154 |
|
bmtool.connectors.gaussian(x, mean=0.0, stdev=1.0, pmax=NORM_COEF)
Gaussian function. Default is the PDF of standard normal distribution
Source code in bmtool/connectors.py
159 160 161 162 |
|
bmtool.connectors.GaussianDropoff
Bases: DistantDependentProbability
Connection probability class that follows a Gaussian function of distance.
This class calculates connection probabilities using a Gaussian function of the distance between cells, with options for spherical or cylindrical metrics.
Parameters:
mean : float, optional Mean parameter of the Gaussian function, typically 0 for peak at origin. stdev : float, optional Standard deviation parameter controlling the width of the Gaussian. min_dist : float, optional Minimum distance for connections. Below this distance, probability is zero. max_dist : float, optional Maximum distance for connections. Above this distance, probability is zero. pmax : float, optional Maximum probability value at the peak of the Gaussian function. ptotal : float, optional Overall connection probability within the specified distance range. If provided, pmax is calculated to achieve this overall probability. ptotal_dist_range : tuple, optional Distance range (min_dist, max_dist) for calculating pmax when ptotal is provided. dist_type : str, optional Distance metric to use, either 'spherical' (default) or 'cylindrical'.
Notes:
When ptotal is specified, the maximum probability (pmax) is calculated to achieve the desired overall connection probability within the specified distance range, assuming homogeneous cell density.
Source code in bmtool/connectors.py
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 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
calc_pmax_from_ptotal()
Calculate the pmax value such that the expected overall connection
probability to all possible targets within the distance range [r1, r2]=
ptotal_dist_range
equals ptotal, assuming homogeneous cell density.
That is, integral_r1^r2 {g(r)p(r)dr} = ptotal, where g is the Gaussian
function with pmax, p(r) is the cell density per unit distance at r
normalized by total cell number within the distance range.
For cylindrical distance, p(r) = 2 * r / (r2^2 - r1^2)
For spherical distance, p(r) = 3 * r^2 / (r2^3 - r1^3)
The solution has a closed form except that te error function erf is in
the expression, but only when resulting pmax <= 1.
Caveat: When the calculated pmax > 1, the actual overall probability will be lower than expected and all cells within certain distance will be always connected. This usually happens when the distance range is set too wide. Because a large population will be included for evaluating ptotal, and there will be a significant drop in the Gaussian function as distance gets further. So, a large pmax will be required to achieve the desired ptotal.
Source code in bmtool/connectors.py
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 240 241 242 243 244 245 246 247 248 |
|
set_probability_func()
Set up function for calculating probability
Source code in bmtool/connectors.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
bmtool.connectors.NormalizedReciprocalRate
Bases: ProbabilityFunction
Reciprocal connection probability given normalized reciprocal rate. Normalized reciprocal rate is defined as the ratio between the reciprocal connection probability and the connection probability for a randomly connected network where the two unidirectional connections between any pair of neurons are independent. NRR = pr / (p0 * p1)
Parameters: NRR: a constant or distance dependent function for normalized reciprocal rate. When being a function, it should be accept vectorized input. Returns: A callable object that returns the probability value.
Source code in bmtool/connectors.py
277 278 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 |
|
__call__(dist, p0, p1, *arg, **kwargs)
Return probability for single distance input
Source code in bmtool/connectors.py
298 299 300 |
|
decisions(dist, p0, p1, cond=None)
Return bool array of decisions dist: distance (scalar or array). Will be ignored if NRR is constant. p0, p1: forward and backward probability (scalar or array) cond: A tuple (direction, array of outcomes) representing the condition. Conditional probability will be returned if specified. The condition event is determined by connection direction (0 for forward, or 1 for backward) and outcomes (bool array of whether connection exists).
Source code in bmtool/connectors.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
|
probability(dist, p0, p1)
Allow numpy array input and return probability in numpy array
Source code in bmtool/connectors.py
294 295 296 |
|
Connector Base Classes
bmtool.connectors.AbstractConnector
Bases: ABC
Abstract base class for connectors
Source code in bmtool/connectors.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|
constant_function(val)
staticmethod
Convert a constant to a constant function
Source code in bmtool/connectors.py
338 339 340 341 342 343 |
|
edge_params(**kwargs)
abstractmethod
Create the arguments for BMTK add_edges() method including the
connection_rule
method.
Source code in bmtool/connectors.py
332 333 334 335 336 |
|
setup_nodes(source=None, target=None)
abstractmethod
After network nodes are added to the BMTK network. Pass in the Nodepool objects of source and target nodes using this method. Must run this before building connections.
Source code in bmtool/connectors.py
325 326 327 328 329 330 |
|
bmtool.connectors.is_same_pop(source, target, quick=False)
Check whether two NodePool objects direct to the same population
Source code in bmtool/connectors.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
|
bmtool.connectors.Timer
Bases: object
Source code in bmtool/connectors.py
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
|
bmtool.connectors.pr_2_rho(p0, p1, pr)
Calculate correlation coefficient rho given reciprocal probability pr
Source code in bmtool/connectors.py
387 388 389 390 391 392 |
|
bmtool.connectors.rho_2_pr(p0, p1, rho)
Calculate reciprocal probability pr given correlation coefficient rho
Source code in bmtool/connectors.py
395 396 397 398 399 400 401 402 403 404 405 |
|
Connector Implementations
bmtool.connectors.ReciprocalConnector
Bases: AbstractConnector
Object for buiilding connections in bmtk network model with reciprocal probability within a single population (or between two populations).
Algorithm: Create random connection for every pair of cells independently, following a bivariate Bernoulli distribution. Each variable is 0 or 1, whether a connection exists in a forward or backward direction. There are four possible outcomes for each pair, no connection, unidirectional connection in two ways, and reciprocal connection. The probability of each outcome forms a contingency table. b a c k w a r d f --------------- o | | 0 | 1 | The total forward connection probability is r |---|-----|-----| p0 = p10 + p11 w | 0 | p00 | p01 | The total backward connection probability is a |---|-----|-----| p1 = p01 + p11 r | 1 | p10 | p11 | The reciprocal connection probability is d --------------- pr = p11 The distribution can be characterized by three parameters, p0, p1, pr. pr = p0 * p1 when two directions are independent. The correlation coefficient rho between the two has a relation with pr as follow. rho = (pr-p0p1) / (p0(1-p0)p1(1-p1))^(1/2) Generating random outcome consists of two steps. First draw random outcome for forward connection with probability p0. Then draw backward outcome following a conditional probability given the forward outcome, represented by p0, p1, and either pr or rho.
Use with BMTK: 1. Create this object with parameters.
connector = ReciprocalConnector(**parameters)
2. After network nodes are added to the BMTK network. Pass in the
Nodepool objects of source and target nodes using setup_nodes() method.
source = net.nodes(**source_filter)
target = net.nodes(**target_filter)
connector.setup_nodes(source, target)
3. Use edge_params() method to get the arguments for BMTK add_edges()
method including the `connection_rule` method.
net.add_edges(**connector.edge_params(),
**other_source_to_target_edge_properties)
If the source and target are two different populations, do this again
for the backward connections (from target to source population).
net.add_edges(**connector.edge_params(),
**other_target_to_source_edge_properties)
4. When executing net.build(), BMTK uses built-in `one_to_all` iterator
that calls the make_forward_connection() method to build connections
from source to target. If the two are different populations,
`all_to_one` iterator that calls the make_backward_connection() method
is then used to build connections from target to source.
During the initial iteration when make_forward_connection() is called,
the algorithm is run to generate a connection matrix for both forward
and backward connections. In the iterations afterward, it's only
assigning the generated connections in BMTK.
Parameters: p0, p1: Probability of forward and backward connection. It can be a constant or a deterministic function whose value must be within range [0, 1], otherwise incorrect value may occur in the algorithm. When p0, p1 are constant, the connection is homogenous. symmetric_p1: Whether p0 and p1 are identical. When the probabilities are equal for forward and backward connections, set this to True, Argument p1 will be ignored. This is forced to be True when the population is recurrent, i.e., the source and target are the same. This is forced to be False if symmetric_p1_arg is False. p0_arg, p1_arg: Input argument(s) for p0 and p1 function, e.g., p0(p0_arg). It can be a constant or a deterministic function whose input arguments are two node objects in BMTK, e.g., p0_arg(src_node,trg_node), p1_arg(trg_node,src_node). The latter has reversed order since it's for backward connection. They are usually distance between two nodes which is used for distance dependent connection probability, where the order does not matter. When p0 and p1 does not need inputs arguments, set p0_arg and p1_arg to None as so by default. Functions p0 and p1 need to accept one unused positional argument as placeholder, e.g., p0(args), so it does not raise an error when p0(None) is called. symmetric_p1_arg: Whether p0_arg and p1_arg are identical. If this is set to True, argument p1_arg will be ignored. This is forced to be True when the population is recurrent. pr, pr_arg: Probability of reciprocal connection and its first input argument when it is a function, similar to p0, p0_arg, p1, p1_arg. It can be a function when it has an explicit relation with some node properties such as distance. A function pr requires two additional positional arguments p0 and p1 even if they are not used, i.e., pr(pr_arg, p0, p1), just in case pr is dependent on p0 and p1, e.g., when normalized reciprocal rate NRR = pr/(p0p1) is given. When pr_arg is a string, the same value as p1_arg will be used for pr_arg if the string contains '1', e.g., '1', 'p1'. Otherwise, e.g., '', '0', 'p0', p0_arg will be used for pr_arg. Specifying this can avoid recomputing pr_arg when it's given by p0_arg or p1_arg. estimate_rho: Whether estimate rho that result in an overall pr. This is forced to be False if pr is a function or if rho is specified. To estimate rho, all the pairs with possible connections, meaning p0 and p1 are both non-zero for these pairs, are used to estimate a value of rho that will result in an expected number of reciprocal connections with the given pr. Note that pr is not over all pairs of source and target cells but only those has a chance to connect, e.g., for only pair of cells within some distance range. The estimation is done before generating random connections. The values of p0, p0_arg, p1, p1_arg can be cached during estimation of rho and retrieved when generating random connections for performance. dist_range_forward: If specified, when estimating rho, consider only cell pairs whose distance (p0_arg) is within the specified range. dist_range_backward: Similar to dist_range_forward but consider backward distance range (p1_arg) instead. If both are specified, consider only cell pairs whose both distances are within range. If neither is specified, infer valid pairs by non-zero connection probability. rho: The correlation coefficient rho. When specified, do not estimate it but instead use the given value throughout, pr will not be used. In cases where both p0 and p1 are simple functions, i.e., are constant on their support, e.g., function UniformInRange(), the estimation of rho will be equal to pr_2_rho(p0, p1, pr) where p0, p1 are non-zero. Estimation is not necessary. Directly set rho. n_syn0, n_syn1: Number of synapses in the forward and backward connection if connected. It can be a constant or a (deterministic or random) function whose input arguments are two node objects in BMTK like p0_arg, p1_arg. n_syn1 is force to be the same as n_syn0 when the population is recurrent. Warning: The number must not be greater than 255 since it will be converted to uint8 when written into the connection matrix to reduce memory consumption. autapses: Whether to allow connecting a cell to itself. Default: False. This is ignored when the population is not recurrent. quick_pop_check: Whether to use quick method to check if source and target populations are the same. Default: False. Quick method checks only whether filter conditions match. Strict method checks whether all node id's match considering order. cache_data: Whether to cache the values of p0, p0_arg, p1, p1_arg during estimation of rho. This improves performance when estimate_rho is True while not creating a significant overhead in the opposite case. However, it requires large memory allocation as the population size grows. Set it to False if there is a memory issue. verbose: Whether show verbose information in console.
Returns: An object that works with BMTK to build edges in a network.
Important attributes: vars: Dictionary that stores part of the original input parameters. source, target: NodePool objects for the source and target populations. recurrent: Whether the source and target populations are the same. callable_set: Set of arguments that are functions but not constants. cache: ConnectorCache object for caching data. conn_mat: Connection matrix stage: Indicator of stage. 0 for forward and 1 for backward connection. conn_prop: List of two dictionaries that stores properties of connected pairs, for forward and backward connections respectively. In each dictionary, each key is the source node id and the value is a dictionary, where each key is the target node id that the source node connects to, and the value is the value of p0_arg or p1_arg. Example: [{sid0: {tid0: p0_arg0, tid1: p0_arg1, ...}, sid1: {...}, sid2: {...}, ... }, {tid2: {sid3: p1_arg0, sid4: p1_arg1, ...}, tid3: {...}, tid4: {...}, ... }] This is useful when properties of edges such as distance is used to determine other edge properties such as delay. So the distance does not need to be calculated repeatedly. The connector can be passed as an argument for the functions that generates additional edge properties, so that they can access the information here.
Source code in bmtool/connectors.py
408 409 410 411 412 413 414 415 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 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 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 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 |
|
add_conn_prop(src, trg, prop, stage=0)
Store p0_arg and p1_arg for a connected pair
Source code in bmtool/connectors.py
819 820 821 822 823 824 825 826 827 |
|
calc_pair(i, j)
Calculate intermediate data that can be cached
Source code in bmtool/connectors.py
769 770 771 772 773 774 775 776 777 |
|
connection_number()
Return the number of the following: n_conn: connected pairs [forward, (backward,) reciprocal] n_poss: possible connections (prob>0) [forward, (backward, reciprocal)] n_pair: pairs of cells proportion: of connections in possible and total pairs
Source code in bmtool/connectors.py
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 |
|
connection_number_info()
Print connection numbers after connections built
Source code in bmtool/connectors.py
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 |
|
edge_params()
Create the arguments for BMTK add_edges() method
Source code in bmtool/connectors.py
657 658 659 660 661 662 663 664 665 666 667 668 |
|
free_memory()
Free up memory after connections are built
Source code in bmtool/connectors.py
1043 1044 1045 1046 1047 1048 1049 |
|
get_conn_prop(sid, tid)
Get stored value given node ids in a connection
Source code in bmtool/connectors.py
829 830 831 |
|
get_nodes_info()
Get strings with source and target population information
Source code in bmtool/connectors.py
1052 1053 1054 1055 1056 |
|
initial_all_to_all()
The major part of the algorithm run at beginning of BMTK iterator
Source code in bmtool/connectors.py
917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 |
|
iterate_pairs()
Generate indices of source and target for each case
Source code in bmtool/connectors.py
753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 |
|
make_backward_connection(targets, source, *args, **kwargs)
Function to be called by BMTK iterator for backward connection
Source code in bmtool/connectors.py
1035 1036 1037 1038 1039 1040 1041 |
|
make_connection()
Assign number of synapses per iteration. Use iterator one_to_all for forward and all_to_one for backward.
Source code in bmtool/connectors.py
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 |
|
make_forward_connection(source, targets, *args, **kwargs)
Function to be called by BMTK iterator for forward connection
Source code in bmtool/connectors.py
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 |
|
node_2_idx_input(var_func, reverse=False)
Convert a function that accept nodes as input to accept indices as input
Source code in bmtool/connectors.py
742 743 744 745 746 747 748 749 750 751 |
|
save_connection_report()
Save connections into a CSV file to be read from later
Source code in bmtool/connectors.py
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 |
|
setup_conditional_backward_probability()
Create a function that calculates the conditional probability of backward connection given the forward connection outcome 'cond'
Source code in bmtool/connectors.py
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 |
|
setup_nodes(source=None, target=None)
Must run this before building connections
Source code in bmtool/connectors.py
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 |
|
bmtool.connectors.UnidirectionConnector
Bases: AbstractConnector
Object for building unidirectional connections in bmtk network model with given probability within a single population (or between two populations).
Parameters: p, p_arg: Probability of forward connection and its input argument when it is a function, similar to p0, p0_arg in ReciprocalConnector. It can be a constant or a deterministic function whose value must be within range [0, 1]. When p is constant, the connection is homogenous. n_syn: Number of synapses in the forward connection if connected. It can be a constant or a (deterministic or random) function whose input arguments are two node objects in BMTK like p_arg. verbose: Whether show verbose information in console.
Returns: An object that works with BMTK to build edges in a network.
Important attributes: vars: Dictionary that stores part of the original input parameters. source, target: NodePool objects for the source and target populations. conn_prop: A dictionaries that stores properties of connected pairs. Each key is the source node id and the value is a dictionary, where each key is the target node id that the source node connects to, and the value is the value of p_arg. Example: {sid0: {tid0: p_arg0, tid1: p_arg1, ...}, sid1: {...}, sid2: {...}, ... } This is useful in similar manner as in ReciprocalConnector.
Source code in bmtool/connectors.py
1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 |
|
add_conn_prop(sid, tid, prop)
Store p0_arg and p1_arg for a connected pair
Source code in bmtool/connectors.py
1195 1196 1197 1198 |
|
connection_number_info()
Print connection numbers after connections built
Source code in bmtool/connectors.py
1261 1262 1263 1264 1265 1266 1267 1268 1269 |
|
edge_params()
Create the arguments for BMTK add_edges() method
Source code in bmtool/connectors.py
1186 1187 1188 1189 1190 1191 |
|
get_conn_prop(sid, tid)
Get stored value given node ids in a connection
Source code in bmtool/connectors.py
1200 1201 1202 |
|
get_nodes_info()
Get strings with source and target population information
Source code in bmtool/connectors.py
1255 1256 1257 1258 1259 |
|
make_connection(source, target, *args, **kwargs)
Assign number of synapses per iteration using one_to_one iterator
Source code in bmtool/connectors.py
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 |
|
save_connection_report()
Save connections into a CSV file to be read from later
Source code in bmtool/connectors.py
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 |
|
setup_nodes(source=None, target=None)
Must run this before building connections
Source code in bmtool/connectors.py
1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 |
|
setup_variables()
Make constant variables constant functions
Source code in bmtool/connectors.py
1204 1205 1206 1207 1208 1209 1210 |
|
bmtool.connectors.GapJunction
Bases: UnidirectionConnector
Object for buiilding gap junction connections in bmtk network model with given probabilities within a single population which is uncorrelated with the recurrent chemical synapses in this population.
Parameters: p, p_arg: Probability of forward connection and its input argument when it is a function, similar to p0, p0_arg in ReciprocalConnector. It can be a constant or a deterministic function whose value must be within range [0, 1]. When p is constant, the connection is homogenous. verbose: Whether show verbose information in console.
Returns: An object that works with BMTK to build edges in a network.
Important attributes:
Similar to UnidirectionConnector
.
Source code in bmtool/connectors.py
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 |
|
make_connection(source, target, *args, **kwargs)
Assign gap junction per iteration using one_to_one iterator
Source code in bmtool/connectors.py
1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 |
|
save_connection_report()
Save connections into a CSV file to be read from later
Source code in bmtool/connectors.py
1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 |
|
bmtool.connectors.CorrelatedGapJunction
Bases: GapJunction
Object for buiilding gap junction connections in bmtk network model with given probabilities within a single population which could be correlated with the recurrent chemical synapses in this population.
Parameters:
p_non, p_uni, p_rec: Probabilities of gap junction connection for each
pair of cells given the following three conditions of chemical
synaptic connections between them, no connection, unidirectional,
and reciprocal, respectively. It can be a constant or a
deterministic function whose value must be within range [0, 1].
p_arg: Input argument for p_non, p_uni, or p_rec, when any of them is a
function, similar to p0_arg, p1_arg in ReciprocalConnector.
connector: Connector object used to generate the chemical synapses of
within this population, which contains the connection information
in its attribute conn_prop
. So this connector should have
generated the chemical synapses before generating the gap junction.
verbose: Whether show verbose information in console.
Returns: An object that works with BMTK to build edges in a network.
Important attributes:
Similar to UnidirectionConnector
.
Source code in bmtool/connectors.py
1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 |
|
make_connection(source, target, *args, **kwargs)
Assign gap junction per iteration using one_to_one iterator
Source code in bmtool/connectors.py
1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 |
|
bmtool.connectors.OneToOneSequentialConnector
Bases: AbstractConnector
Object for buiilding one to one correspondence connections in bmtk network model with between two populations. One of the population can consist of multiple sub-populations. These sub-populations need to be added sequentially using setup_nodes() and edge_params() methods followed by BMTK add_edges() method. For example, to connect 30 nodes in population A to 30 nodes in populations B1, B2, B3, each with 10 nodes, set up as follows. connector = OneToOneSequentialConnector(parameters) connector.setup_nodes(source=A, target=B1) net.add_edges(connector.edge_params()) connector.setup_nodes(target=B2) net.add_edges(connector.edge_params()) connector.setup_nodes(target=B3) net.add_edges(connector.edge_params()) After BMTK executes net.build(), the first 10 nodes in A will connect one- to-one to the 10 nodes in B1, then the 11 to 20-th nodes to those in B2, finally the 21 to 30-th nodes to those in B3. This connector is useful for creating input drives to a population. Each node in it receives an independent drive from a unique source node.
Parameters: n_syn: Number of synapses in each connection. It accepts only constant for now. partition_source: Whether the source population consists of multiple sub-populations. By default, the source has one population, and the target can have multiple sub-populations. If set to true, the source can have multiple sub-populations and the target has only one population. verbose: Whether show verbose information in console.
Returns: An object that works with BMTK to build edges in a network.
Important attributes: source: NodePool object for the single population. targets: List of NodePool objects for the multiple sub-populations.
Source code in bmtool/connectors.py
1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 |
|
edge_params(target_pop_idx=-1)
Create the arguments for BMTK add_edges() method
Source code in bmtool/connectors.py
1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 |
|
get_nodes_info(target_pop_idx=-1)
Get strings with source and target population information
Source code in bmtool/connectors.py
1628 1629 1630 1631 1632 1633 |
|
make_connection(source, targets, *args, **kwargs)
Assign one connection per iteration using all_to_one iterator
Source code in bmtool/connectors.py
1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 |
|
setup_nodes(source=None, target=None)
Must run this before building connections
Source code in bmtool/connectors.py
1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 |
|
Synapse Helper Functions
bmtool.connectors.syn_const_delay(source=None, target=None, dist=100, min_delay=SYN_MIN_DELAY, velocity=SYN_VELOCITY, fluc_stdev=FLUC_STDEV, delay_bound=(DELAY_LOWBOUND, DELAY_UPBOUND), connector=None)
Synapse delay constant with some random fluctuation.
Source code in bmtool/connectors.py
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 |
|
bmtool.connectors.syn_dist_delay_feng(source, target, min_delay=SYN_MIN_DELAY, velocity=SYN_VELOCITY, fluc_stdev=FLUC_STDEV, delay_bound=(DELAY_LOWBOUND, DELAY_UPBOUND), connector=None)
Synpase delay linearly dependent on distance. min_delay: minimum delay (ms) velocity: synapse conduction velocity (micron/ms) fluc_stdev: standard deviation of random Gaussian fluctuation (ms) delay_bound: (lower, upper) bounds of delay (ms) connector: connector object from which to read distance
Source code in bmtool/connectors.py
1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 |
|
bmtool.connectors.syn_section_PN(source, target, p=0.9, sec_id=(1, 2), sec_x=(0.4, 0.6), **kwargs)
Synapse location follows a Bernoulli distribution, with probability p to obtain the former in sec_id and sec_x
Source code in bmtool/connectors.py
1678 1679 1680 1681 1682 1683 |
|
bmtool.connectors.syn_const_delay_feng_section_PN(source, target, p=0.9, sec_id=(1, 2), sec_x=(0.4, 0.6), **kwargs)
Assign both synapse delay and location with constant distance assumed
Source code in bmtool/connectors.py
1686 1687 1688 1689 1690 1691 |
|
bmtool.connectors.syn_dist_delay_feng_section_PN(source, target, p=0.9, sec_id=(1, 2), sec_x=(0.4, 0.6), **kwargs)
Assign both synapse delay and location
Source code in bmtool/connectors.py
1694 1695 1696 1697 1698 1699 |
|
bmtool.connectors.syn_uniform_delay_section(source, target, low=DELAY_LOWBOUND, high=DELAY_UPBOUND, **kwargs)
Source code in bmtool/connectors.py
1702 1703 1704 |
|