connections¶
champalimaud.connections
¶
Columns of a connection table: the cells and types at its ends.
A connection table has one row per pair of cells, with the root ids
pre_pt_root_id and post_pt_root_id and the synapse count
weight.
reversed_connections(connections)
¶
Swap the presynaptic and postsynaptic cell of each connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connections
|
DataFrame
|
Has |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Examples:
>>> import polars as pl
>>> connections = pl.DataFrame(
... {
... "pre_pt_root_id": [1],
... "post_pt_root_id": [2],
... "weight": [7],
... }
... )
>>> reversed_connections(connections).row(0, named=True)
{'post_pt_root_id': 1, 'pre_pt_root_id': 2, 'weight': 7}
Source code in champalimaud/connections.py
with_cell_columns(connections, cells, *, end='pre')
¶
Add the columns of a cell table for one end of each connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connections
|
DataFrame
|
Has |
required |
cells
|
DataFrame
|
Has |
required |
end
|
(pre, post)
|
Which end of each connection to look up. |
"pre"
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
For any other |
Examples:
>>> import polars as pl
>>> connections = pl.DataFrame(
... {"pre_pt_root_id": [1, 2], "post_pt_root_id": [2, 9]}
... )
>>> cells = pl.DataFrame({"root_id": [1, 2], "side": ["L", "R"]})
>>> with_cell_columns(connections, cells)["pre_side"].to_list()
['L', 'R']
Source code in champalimaud/connections.py
with_post_type(connections, cells_by_type)
¶
Add post_type, the type of the postsynaptic cell.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connections
|
DataFrame
|
Has |
required |
cells_by_type
|
dict of str to list
|
Maps a type name to the ids of its cells; a cell may belong to only one type. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
See Also
with_pre_type : The same for the presynaptic cell.
Examples:
>>> import polars as pl
>>> connections = pl.DataFrame(
... {"pre_pt_root_id": [1, 5], "post_pt_root_id": [2, 2]}
... )
>>> with_post_type(connections, {"B": [2]})["post_type"].to_list()
['B', 'B']
Source code in champalimaud/connections.py
with_pre_type(connections, cells_by_type)
¶
Add pre_type, the type of the presynaptic cell.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connections
|
DataFrame
|
Has |
required |
cells_by_type
|
dict of str to list
|
Maps a type name to the ids of its cells; a cell may belong to only one type. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
See Also
with_post_type : The same for the postsynaptic cell.
Examples:
>>> import polars as pl
>>> connections = pl.DataFrame(
... {"pre_pt_root_id": [1, 5], "post_pt_root_id": [2, 2]}
... )
>>> with_pre_type(connections, {"A": [1]})["pre_type"].to_list()
['A', None]