blue_cwl.connectome¶
Connectome assembly of macro and micro connectome matrices.
All matrices are comprised of columns, a subset of which is the index columns and the rest the values.
The index columns are used to build dataframe indices and perform pathway comparisons and update.
Macro Matrix¶
- The macro matrix consists of the following columns:
side (category)
source_region (category)
target_region (category)
value (float32)
- where:
index columns: [side, source_region, target_region] values : [value]
Micro Matrices¶
The micro connectome configuration consists of the following matrices:
- Variant matrix:
index columns: [side, source_region, target_region, source_mtype, target_mtype]
value columns: [variant]
- Variant parameter matrices:
- placeholder__erdos_renyi:
index columns: [side, source_region, target_region, source_mtype, target_mtype] value columns: [weight, nsynconn_mean, nsynconn_std, delay_velocity, delay_offset]
- placeholder__distance_dependent:
index columns: [side, source_region, target_region, source_mtype, target_mtype] value columns: [weight, exponent, nsynconn_mean, nsynconn_std, delay_velocity, delay_offset]
Steps, assembly & conformity¶
step 1: Macro assembly
The macro matrix is assembled by taking the initial et of rows and connecting them w/ the overrides. See _assemble for more details.
Step 2: Micro variants assembly & conformity to step 1
The variant matrix is assembled and then it is conformed to the macro matrix so that additional pathways in the macro are added with default values and pathways not in it are removed. See _conform for more details.
step 3: Micro variant parameters assembly & conformity to step 2
Each variant parameters matrix is assembled and conformed to the subset of the pathways that will be built with the respective variant. Pathways in variant matrix that are not in the micro variant one are added with default values, whereas pathways not in it are removed.
Functions
|
Assemble macro connectome dataframe from the materialized macro config. |
|
Assemble micro connectome dataframe from the materialized micro config. |
|
Load and resolve micro matrices from materialized micro config. |
Classes
Connectome related Constants. |
- class blue_cwl.connectome.Constants¶
Connectome related Constants.
- blue_cwl.connectome.assemble_macro_matrix(macro_config: dict) DataFrame¶
Assemble macro connectome dataframe from the materialized macro config.
The macro matrix is assembled by combining the initial pathways and the overrides if any.
- macro_config arrow files are expected to have the following columns:
side (category)
source_region (category)
target_region (category)
value (float32)
where the ‘side’ is the compact form of the source and target hemispheres, e.g. ‘LR’.
- Parameters:
macro_config –
Materialized macro config with the arrow file paths.
Example:
{ "initial": {"connection_strength": "path/to/arrow/file"}, "overrides": {"connection_strength": "path/to/arrow/file"}, }
- Returns:
source_hemisphere (category)
target_hemisphere (category)
source_region (category)
target_region (category)
value (float32)
- Return type:
DataFrame with the following categorical columns
Note
‘overrides’ can be empty and rows with zero ‘value’ are removed.
Duplicate pathways will be dropped keeping the last entry.
- blue_cwl.connectome.assemble_micro_matrix(micro_config: dict, variant_name: str) DataFrame¶
Assemble micro connectome dataframe from the materialized micro config.
- Parameters:
micro_config –
Materialized macro config with the arrow file paths.
Example:
{ "initial": { "placeholder__erdos_renyi": "path/to/initial/arrow/er_file", "placeholder__distance_dependent": "path/to/initial/arrow/dd_file", }, "overrides": { "placeholder__erdos_renyi": "path/to/overrides/arrow/er_file", "placeholder__distance_dependent": "path/to/overrides/arrow/dd_file", }, }
variant_name – Name of the variant algorithm. One of - placeholder__erdos_renyi - placeholder__distance_dependent
- Returns:
source_hemisphere (category)
target_hemisphere (category)
source_region (category)
target_region (category)
weight (float32)
nsynconn_mean (float32)
nsynconn_std (float32)
delay_velocity (float32)
delay_offset (float32)
# placeholder__distance_dependent matrix only - exponent (float32)
- Return type:
DataFrame with the following columns
Note
‘overrides’ can be empty.
Duplicate pathways will be dropped keeping the last entry.
- blue_cwl.connectome.resolve_micro_matrices(micro_config: dict, macro_matrix: DataFrame, population, region_volumes) dict[str, DataFrame]¶
Load and resolve micro matrices from materialized micro config.
- Parameters:
micro_config –
Materialized macro config with the arrow file paths.
Example:
{ "initial": { "placeholder__erdos_renyi": path / to / initial / arrow / er_file, "placeholder__distance_dependent": path / to / initial / arrow / dd_file, }, "overrides": { "placeholder__erdos_renyi": path / to / overrides / arrow / er_file, "placeholder__distance_dependent": path / to / overrides / arrow / dd_file, }, }
macro_matrix – DataFrame with RangeIndex and the following columns: - source_hemisphere (category) - target_hemisphere (category) - source_region (category) - target_region (category) - value (float32)
population – Cells node population
region_volumes – A series of volumes indexed by brain region acronym.
Returns: A dictionary the keys of which are variant names and the values micro matrices.