Connectome¶
btorch.connectome
¶
Functions:¶
simple_id_to_root_id(neurons, reverse=False)
¶
Build an id lookup from a neuron table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neurons
|
DataFrame
|
DataFrame with |
required |
reverse
|
bool
|
If False (default), return a |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Mapping dictionary in the requested direction. |
Source code in btorch/connectome/__init__.py
btorch.connectome.augment
¶
Data augmentation and sampling utilities for connectome data.
This module provides functions for manipulating neuron and connection DataFrames, including:
- Slicing neurons and their connections by ID subsets
- Sampling strategies for representative neuron subsets
- Downsampling connections while preserving network structure
- Dropping neurons/connections and computing degrees
- E/I connection matrix construction
Expected DataFrame schemas
neurons DataFrame: - root_id: Unique neuron identifier (64-bit int) - simple_id: Linear 0..N-1 index - flow, super_class, class, nt_type: Classification columns - area_nm: Surface area for capacitance computation
connections DataFrame: - pre_root_id, post_root_id: Root IDs - pre_simple_id, post_simple_id: Simple IDs - syn_count: Synapse count
Side effects
Functions may modify DataFrame indices, add new columns (e.g., original_simple_id for backup), or remap IDs to local ranges.
Attributes¶
IdType = Literal['root_id', 'simple_id']
module-attribute
¶
Functions:¶
downsample_neurons(neurons, connections, samples, random_state=42, method='random_sample_connections', **params)
¶
Source code in btorch/connectome/augment.py
drop_neurons(neurons, connections, root_id)
¶
Source code in btorch/connectome/augment.py
drop_no_conn(neurons, connections)
¶
Source code in btorch/connectome/augment.py
empirical_membrane_capacitance(neurons)
¶
find_neuron_inout_degree(neurons, connections)
¶
Source code in btorch/connectome/augment.py
make_ei_conn_mat(conn_mats, g=0.5)
¶
mask_neurons_in_conn_mat(conn_mat, ids, id_type, neurons=None)
¶
Source code in btorch/connectome/augment.py
sample_by_column_expand_none(df, group_cols, k=5, j=10, random_state=0, product_sample=False)
¶
Sample rows from DataFrame based on complete groupings and null columns.
Parameters¶
df : pd.DataFrame Input DataFrame.
list
List of column names to group on.
int
Number of samples to draw per fully-specified group (non-null in all group_cols).
int or dict
If int: number of samples from all partially-specified rows (non-product mode), or per partial group (product mode). If dict: mapping of column name to number of samples if that column is null.
int
Random seed.
bool
If True, group partially-specified rows by their non-null group_cols and sample
j per group (or per-column null if j is a dict). If False, sample globally.
Returns¶
pd.DataFrame Concatenated DataFrame of full group and partial samples.
Source code in btorch/connectome/augment.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 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 | |
sample_neuron_representative(neurons, k=1, j=2, random_state=None, product_sample=True)
¶
Sample representative neurons across canonical taxonomy columns.
This wrapper intentionally standardizes grouping to connectome taxonomy
fields used throughout this package: flow, super_class, class,
and nt_type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neurons
|
DataFrame
|
Neuron metadata table containing taxonomy columns. |
required |
k
|
int
|
Samples per fully specified taxonomy group. |
1
|
j
|
int | dict
|
Sampling budget for partially specified rows. |
2
|
random_state
|
int | None
|
Random seed for reproducibility. |
None
|
product_sample
|
bool
|
Whether to sample partial rows per product subgroup. |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Sampled neuron metadata as a DataFrame. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required taxonomy columns are missing. |
Source code in btorch/connectome/augment.py
simple_id_to_root_id(neurons, reverse=False)
¶
Build an id lookup from a neuron table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neurons
|
DataFrame
|
DataFrame with |
required |
reverse
|
bool
|
If False (default), return a |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Mapping dictionary in the requested direction. |
Source code in btorch/connectome/__init__.py
slice_neurons_connections(simple_id=None, root_id=None, neurons=None, connections=None, connection_mode='both', keep_original_ids=True)
¶
Slices neuron metadata and connections while preserving input sequence order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simple_id
|
int | list[int] | ndarray | None
|
Ordered linear IDs for slicing. |
None
|
root_id
|
int | list[int] | ndarray | None
|
Ordered non-linear IDs (requires |
None
|
neurons
|
DataFrame | None
|
Metadata containing 'simple_id' and 'root_id'. |
None
|
connections
|
DataFrame | None
|
Edge list containing 'pre_simple_id' and 'post_simple_id'. |
None
|
connection_mode
|
Literal['both', 'pre', 'post', 'any']
|
Filtering logic for edges relative to selected neurons. |
'both'
|
keep_original_ids
|
bool
|
Back up global IDs before remapping to local 0..N-1 range. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[DataFrame | None, DataFrame | None, ndarray]
|
(ordered_neurons, filtered_connections, original_indices) |
Source code in btorch/connectome/augment.py
btorch.connectome.connection
¶
Attributes¶
ConstraintMode = Literal['full', 'cell_only', 'cell_and_receptor']
module-attribute
¶
DropNaMode = Literal['error', 'filter', 'unknown']
module-attribute
¶
IdType = Literal['root_id', 'simple_id']
module-attribute
¶
ReceptorTypeMode = Literal['neuron', 'connection']
module-attribute
¶
Functions:¶
_aggregate_edges(connections, delay_col)
¶
Sum duplicated (pre, post) pairs into an edge table.
Duplicates occur when two neurons are connected in several neuropils. Delays of merged duplicates are averaged and truncated to integer steps.
Source code in btorch/connectome/connection.py
_assemble_hetersynapse(groups, shape, return_dict, n_delay_bins)
¶
Turn (key, edges) groups into a stacked matrix or a dict of
matrices.
Stacked: edge pre -> post of group i lands at column
post * n_groups + i. Dict: one shape matrix per non-empty group.
With n_delay_bins > 1 rows become pre * n_delay_bins + delay_bin.
Source code in btorch/connectome/connection.py
_connection_receptor_groups(connections, receptor_type_col, delay_col)
¶
Split connections by their own receptor type (possible cotransmission).
Source code in btorch/connectome/connection.py
_delay_rows(pre, delays, n_delay_bins)
¶
Row index pre * n_delay_bins + clip(delay) of each delayed edge.
Source code in btorch/connectome/connection.py
_neuron_receptor_groups(neurons, edges, receptor_type_col, dropna, ignore_post_type)
¶
Split edges by the receptor types of their pre/post neurons.
Returns (groups, index_df); groups[i] is (key, edges_i) where
key is the pre type (ignore_post_type) or (pre, post) type pair.
Source code in btorch/connectome/connection.py
_resolve_nan_receptors(neurons, edges, receptor_type_col, dropna)
¶
Apply the dropna policy to neurons without a receptor type.
Returns the (possibly relabelled) neurons and the (possibly filtered) edges.
Source code in btorch/connectome/connection.py
_validate_hetersynapse_args(connections, receptor_type_col, receptor_type_mode, return_dict, delay_col)
¶
Reject argument combinations that no branch can serve.
Source code in btorch/connectome/connection.py
expand_conn_for_delays(conn, delays, n_delay_bins=5)
¶
Expand connection matrix for delay dimension.
Expands the ROW dimension (pre-synaptic neurons) to accommodate spike history. Each pre-neuron gets n_delay_bins "virtual" neurons representing its spike at different delays.
The output matrix shape is (n_neurons * n_delay_bins, n_neurons), where row i * n_delay_bins + d corresponds to neuron i at delay d.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
sparray
|
Base connection matrix of shape (n_neurons, n_neurons). |
required |
delays
|
ndarray
|
Per-connection delay values in dt steps, array of length conn.nnz (number of non-zero connections). |
required |
n_delay_bins
|
int
|
Number of delay bins (0 to n_delay_bins-1). |
5
|
Returns:
| Type | Description |
|---|---|
sparray
|
Expanded sparse matrix of shape (n_neurons * n_delay_bins, n_neurons). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If delays contains negative values. |
Example
import scipy.sparse import numpy as np conn = scipy.sparse.coo_array( ... ([1.0, 2.0], ([0, 1], [1, 2])), ... shape=(3, 3) ... ) delays = np.array([1, 3]) # conn[0,1] has delay 1, conn[1,2] has delay 3 conn_d = expand_conn_for_delays(conn, delays, n_delay_bins=5) conn_d.shape (15, 3) # 3 neurons * 5 delays, 3 neurons
conn[0,1]=1.0 with delay 1 -> conn_d[0*5+1, 1] = 1.0¶
conn[1,2]=2.0 with delay 3 -> conn_d[1*5+3, 2] = 2.0¶
Source code in btorch/connectome/connection.py
groupby_to_dict(df, column_select=None, **groupby_args)
¶
Group DataFrame and return as dictionary mapping keys to subframes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input DataFrame to group. |
required |
column_select
|
Sequence[str] | None
|
Optional column subset to include in output values. |
None
|
**groupby_args
|
Any
|
Arguments passed to |
{}
|
Returns:
| Type | Description |
|---|---|
dict[Any, DataFrame]
|
Dictionary mapping group keys to DataFrame slices. |
Example
df = pd.DataFrame({"a": [1, 1, 2], "b": [3, 4, 5]}) groupby_to_dict(df, column_select=["b"], by="a") {1: b 0 3 1 4, 2: b 2 5}
Source code in btorch/utils/pandas_utils.py
make_constraint_by_neuron_type(neurons, connections, nan_in_same_group=True)
¶
Create a sparse constraint matrix where each non-zero entry represents a unique (pre_cell_type, post_cell_type) pair. This can be used to group connections based on cell types for constrained learning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neurons
|
DataFrame
|
Must contain 'root_id', 'cell_type'. |
required |
connections
|
DataFrame
|
Must contain 'pre_root_id', 'post_root_id', 'pre_simple_id', and 'post_simple_id'. |
required |
nan_in_same_group
|
bool
|
If True, missing cell types are grouped together. If False, missing values are assigned unique dummy types. |
True
|
Returns:
| Type | Description |
|---|---|
sparray
|
scipy.sparse.sparray: Sparse array with shape (num_neurons, num_neurons), where each non-zero value is a group ID for that connection. |
Source code in btorch/connectome/connection.py
make_hetersynapse_conn(neurons, connections, receptor_type_col='EI', receptor_type_mode='neuron', return_dict=False, dropna='error', ignore_post_type=False, delay_col=None, n_delay_bins=5)
¶
make_hetersynapse_conn(
neurons: pd.DataFrame,
connections: scipy.sparse.sparray | pd.DataFrame,
receptor_type_col: str | None = "EI",
receptor_type_mode: ReceptorTypeMode = "neuron",
return_dict: Literal[False] = False,
dropna: DropNaMode = "error",
ignore_post_type: bool = False,
delay_col: str | None = None,
n_delay_bins: int = 5,
) -> tuple[scipy.sparse.sparray, pd.DataFrame]
make_hetersynapse_conn(
neurons: pd.DataFrame,
connections: scipy.sparse.sparray | pd.DataFrame,
receptor_type_col: str | None = "EI",
receptor_type_mode: ReceptorTypeMode = "neuron",
return_dict: Literal[True] = ...,
dropna: DropNaMode = "error",
ignore_post_type: bool = False,
delay_col: str | None = None,
n_delay_bins: int = 5,
) -> tuple[OrderedDict, pd.DataFrame]
make_hetersynapse_conn(
neurons: pd.DataFrame,
connections: scipy.sparse.sparray | pd.DataFrame,
receptor_type_col: str | None = "EI",
receptor_type_mode: ReceptorTypeMode = "neuron",
return_dict: bool = ...,
dropna: DropNaMode = "error",
ignore_post_type: bool = False,
delay_col: str | None = None,
n_delay_bins: int = 5,
) -> (
tuple[scipy.sparse.sparray, pd.DataFrame]
| tuple[OrderedDict, pd.DataFrame]
)
Transforms a connectivity matrix to represent hetersynaptic connections based on receptor types, with optional delay support.
This function can handle two modes:
1. 'neuron' mode: Receptor types are properties of the pre- and post-synaptic
neurons. The output matrix will have num_neurons rows and num_neurons
* num_receptor_pairs columns, where each block of n_receptor_type columns
corresponds to all receptors of a specific neuron. (e.g., 'E' to 'I').
2. 'connection' mode: Receptor types are properties of the connections
themselves (possible cotransmission). The output matrix will have
num_neurons rows and num_neurons * num_receptor_types columns, where
each block of n_receptor_type columns corresponds to all receptors of a
single neuron.
When delay_col is provided (DataFrame only), the output matrix rows are expanded to include delay bins: shape becomes (n_neurons * n_delay_bins, n_neurons * n_receptors).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neurons
|
DataFrame
|
DataFrame with neuron information. It must contain the
|
required |
connections
|
sparray | DataFrame
|
A |
required |
receptor_type_col
|
str | None
|
The column name in the |
'EI'
|
receptor_type_mode
|
ReceptorTypeMode
|
Specifies whether receptor types are associated with 'neuron' or 'connection'. |
'neuron'
|
return_dict
|
bool
|
If True, returns OrderedDict mapping receptor types (pre
type with |
False
|
dropna
|
DropNaMode
|
How to handle NaN receptor types. Options: - 'error' (default): Raise ValueError if NaN found - 'filter': Remove connections involving NaN neurons (preserves neuron count) - 'unknown': Treat NaN as a separate receptor type category |
'error'
|
ignore_post_type
|
bool
|
If True, clusters connections only by pre-synaptic receptor type, ignoring post-synaptic receptor type. Resulting matrix will have fewer columns. Only valid for 'neuron' mode. |
False
|
delay_col
|
str | None
|
Optional column name in connections DataFrame containing
delay values (in dt steps). If provided, expands matrix rows for
delays. Only works with DataFrame connections. Delays of
duplicated (pre, post) pairs are averaged (truncated to int);
values above |
None
|
n_delay_bins
|
int
|
Number of delay bins when delay_col is provided (default: 5; a value of 1 means no delay expansion). |
5
|
Returns:
| Type | Description |
|---|---|
tuple[sparray, DataFrame] | tuple[OrderedDict, DataFrame]
|
A tuple containing:
- The transformed sparse array ( |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Note
receptor_type_col=None with delay_col builds a delays-only matrix
of shape (n_neurons * n_delay_bins, n_neurons) and returns it with an
index frame of simple_id (plus delay_index when expanded).
dropna and ignore_post_type only apply to 'neuron' mode.
The neuron count is always preserved (based on simple_id indexing).
When dropna='filter', only connections are removed, not neurons.
When dropna='unknown', NaN becomes a valid receptor type.
Source code in btorch/connectome/connection.py
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 | |
make_hetersynapse_constrained_conn(neurons, connections, cell_type_col='cell_type', receptor_type_col='EI', receptor_type_mode='neuron', constraint_mode='full', nan_in_same_group=True, dropna='error', ignore_post_type=False)
¶
Create both hetersynaptic connection and constraint matrices.
This is a convenience function that combines make_hetersynapse_conn and
make_hetersynapse_constraint to produce outputs ready for a constrained
:class:~btorch.models.connection.SparseConnection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neurons
|
DataFrame
|
Must contain 'root_id', cell_type_col, and receptor_type_col. |
required |
connections
|
DataFrame
|
Must contain 'pre_root_id', 'post_root_id', 'pre_simple_id', and 'post_simple_id'. |
required |
cell_type_col
|
str
|
Column name for cell type information. |
'cell_type'
|
receptor_type_col
|
str
|
Column name for receptor type information. |
'EI'
|
receptor_type_mode
|
ReceptorTypeMode
|
Whether receptor types are per 'neuron' or 'connection'. |
'neuron'
|
constraint_mode
|
ConstraintMode
|
Controls constraint granularity (see make_hetersynapse_constraint). |
'full'
|
nan_in_same_group
|
bool
|
If True, missing cell types are grouped together. |
True
|
dropna
|
DropNaMode
|
How to handle NaN receptor types ('error', 'filter', or 'unknown'). |
'error'
|
ignore_post_type
|
bool
|
If True, ignore post-synaptic receptor distinction. |
False
|
Returns:
| Type | Description |
|---|---|
sparray
|
Tuple of (conn_matrix, constraint_matrix, receptor_type_index). |
sparray
|
Both matrices are in the |
DataFrame
|
sources) with columns expanded to |
tuple[sparray, sparray, DataFrame]
|
Can be used directly with |
tuple[sparray, sparray, DataFrame]
|
``SparseConnection.from_adjacency(conn_matrix, |
tuple[sparray, sparray, DataFrame]
|
Synapse(weight=ConstrainedWeight(group=constraint_matrix)))`` |
tuple[sparray, sparray, DataFrame]
|
(expanded layout) or ``SparseConnection.from_hetersynapse( |
tuple[sparray, sparray, DataFrame]
|
conn_matrix, Synapse(weight=ConstrainedWeight( |
tuple[sparray, sparray, DataFrame]
|
group=constraint_matrix)), |
tuple[sparray, sparray, DataFrame]
|
receptor_type_index=receptor_type_index)`` (per-edge receptor |
tuple[sparray, sparray, DataFrame]
|
attributes). The |
tuple[sparray, sparray, DataFrame]
|
module of that connection; create a new one per connection. |
Source code in btorch/connectome/connection.py
make_hetersynapse_constraint(neurons, connections, cell_type_col='cell_type', receptor_type_col='EI', receptor_type_mode='neuron', constraint_mode='full', nan_in_same_group=True, ignore_post_type=False)
¶
Create constraint matrix for hetersynaptic connections grouped by cell and receptor types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neurons
|
DataFrame
|
Must contain 'root_id', cell_type_col, and receptor_type_col. |
required |
connections
|
DataFrame
|
Must contain 'pre_root_id', 'post_root_id', 'pre_simple_id', and 'post_simple_id'. |
required |
cell_type_col
|
str
|
Column name for cell type information. |
'cell_type'
|
receptor_type_col
|
str
|
Column name for receptor type information. |
'EI'
|
receptor_type_mode
|
ReceptorTypeMode
|
Whether receptor types are per 'neuron' or 'connection'. |
'neuron'
|
constraint_mode
|
ConstraintMode
|
|
'full'
|
nan_in_same_group
|
bool
|
If True, missing cell types are grouped together. |
True
|
ignore_post_type
|
bool
|
If True, constraints ignore post-receptor type. |
False
|
Returns:
| Type | Description |
|---|---|
sparray
|
scipy.sparse.sparray: Sparse array matching hetersynapse connection shape, where each non-zero value is a group ID for that connection. |
Source code in btorch/connectome/connection.py
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 | |
make_sparse_mat(connections, shape, field='syn_count')
¶
Source code in btorch/connectome/connection.py
make_spatial_localised_conn(neurons, mode='num', num=5, radius=5.0, include_self=True)
¶
Constructs a spatially localized connection matrix.
Source code in btorch/connectome/connection.py
neuron_subset_to_conn_mat(subset, id_type, size, neurons=None, remove_nan=False, return_mode='scatter')
¶
neuron_subset_to_conn_mat(
subset: Sequence[int] | pd.Series | pd.DataFrame,
id_type: IdType,
size: int,
neurons: pd.DataFrame | None = None,
remove_nan: bool = False,
return_mode: Literal["scatter"] = "scatter",
) -> np.ndarray
Convert a neuron subset to simple ids or a selection matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subset
|
Sequence[int] | Series | DataFrame
|
Neuron ids (sequence or Series), or a DataFrame with a
|
required |
id_type
|
IdType
|
Kind of ids in |
required |
size
|
int
|
Total number of neurons (columns of the selection matrix). |
required |
neurons
|
DataFrame | None
|
Neuron table with |
None
|
remove_nan
|
bool
|
Drop (with a warning) ids that cannot be mapped instead of raising. |
False
|
return_mode
|
Literal['sparray', 'scatter']
|
|
'scatter'
|
Returns:
| Type | Description |
|---|---|
sparray | ndarray
|
Array of simple ids, or a sparse selection matrix. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in btorch/connectome/connection.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
simple_id_to_root_id(neurons, reverse=False)
¶
Build an id lookup from a neuron table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neurons
|
DataFrame
|
DataFrame with |
required |
reverse
|
bool
|
If False (default), return a |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Mapping dictionary in the requested direction. |
Source code in btorch/connectome/__init__.py
stack_hetersynapse(conn_dict, receptor_type_index, ignore_receptor_type=None)
¶
Convert dict of receptor-specific matrices back to stacked matrix format.
This is the inverse of make_hetersynapse_conn with return_dict=True. Useful after modifying individual receptor type matrices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn_dict
|
dict
|
OrderedDict mapping receptor type pairs to sparse matrices. Keys are (pre_receptor, post_receptor) tuples for neuron mode, or receptor_type strings for connection mode. |
required |
receptor_type_index
|
DataFrame
|
DataFrame with receptor type mappings, must include 'receptor_index' column and either ('pre_receptor_type', 'post_receptor_type') for neuron mode or 'receptor_type' for connection mode. |
required |
ignore_receptor_type
|
Literal['pre', 'post', 'all'] | None
|
Optional collapse strategy to reduce receptor distinctions. None keeps full indexing. "post" collapses only post-receptor types in neuron mode (treated as "all" in connection mode). "pre" is accepted for connection mode and behaves like "all". "all" sums all receptor channels into one. |
None
|
Returns:
| Type | Description |
|---|---|
sparray | tuple[sparray, DataFrame]
|
Stacked sparse matrix with shape (N, N * n_receptor_types). When |
sparray | tuple[sparray, DataFrame]
|
collapsing, also returns a new receptor_type_index describing the |
sparray | tuple[sparray, DataFrame]
|
reduced mapping. |
Source code in btorch/connectome/connection.py
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 | |