connectome_manipulator.model_building.conn_props

Module for building connection/synapse properties models

connectome_manipulator.model_building.conn_props.build(syns_per_conn_data, conn_prop_data, m_types, m_type_class, m_type_layer, syn_props, distr_types={}, data_types={}, data_bounds={}, shared_within={}, **_)[source]

Fit model distribution to data, incl. missing values interpolated at different levels of granularity.

Parameters:
  • syns_per_conn_data (dict) – Dictionary with entries for all statistics (see Notes under extract()) estimated for #synapses/connection, each of which contains a numpy.ndarray of size <#source-mtypes x #target-mtypes> for all pairs of m-types, as returned by extract()

  • conn_prop_data (dict) – Dictionary with entries for all statistics (see Notes under extract()) estimated for all synaptic properties, each of which contains a numpy.ndarray of size <#source-mtypes x #target-mtypes x #properties> for all pairs of m-types and synapse properties, as returned by extract()

  • m_types (list) – Two-element list of lists of source (pre-synaptic) and target (post-synaptic) m-types, as returned by extract()

  • m_type_class (list) – Two-element list of lists of synapse classes (i.e., EXC, INH) belonging to each source and target m-type (assuming that each m-type corresponds to exactly one synapse class), as returned by extract()

  • m_type_layer (list) – Two-element list of lists of layers belonging to each source and target m-type (assuming that each m-type corresponds to exactly one cortical layer), as returned by extract()

  • syn_props (list-like) – List of synaptic property names stored in conn_prop_data, as returned by extract()

  • distr_types (dict) – Optional dictionary specifying the distribution type (dict value) for each property (dict key); if omitted, a “normal” distribution is assumed (and will raise a warning); see Notes for available distribution types

  • data_types (dict) – Optional dictionary specifying the output data type (dict value; e.g., “int”, “float”, …) for each property (dict key) when drawing values from the fitted model

  • data_bounds (dict) – Optional dictionary specifying the output data bounds (dict value; list-like with two elements for lower/upper bounds) for each property (dict key) when drawing values from the fitted model

  • shared_within (dict) – Optional dictionary specifying if the same values are shared among synapses belonging to the same connections (boolean dict value) for each property (dict key) when drawing values from the fitted model; can be used to manually overwrite the data-derived value

Returns:

Fitted connection/synapse properties model

Return type:

connectome_manipulator.model_building.model_types.ConnPropsModel

Note

The property name “n_syn_per_conn” (defined by model_types.N_SYN_PER_CONN_NAME) can be used in distr_types, data_types, and data_bounds dicts to specify distribution types, data types, and bounds for the #synapses/connection property.

Note

The following distribution types are supported:

  • “constant”: Constant value (define by “mean”)

  • “normal”: Gaussian normal distribution (define by “mean”, “std”)

  • “truncnorm”: Truncated normal distribution (define by “norm_loc”, “norm_scale”, “min”, “max”)

  • “gamma”: Gamma distribution (define by “mean”, “std”)

  • “poisson”: Poisson distribution (define by “mean”)

  • “ztpoisson”: Zero-truncated poisson distribution (define by “mean”)

  • “discrete”: Discrete distribution (define by “val”, “p”)

  • “zero”: Empty distribution always returning zero; can be used to model unused parameters

connectome_manipulator.model_building.conn_props.extract(circuit, min_sample_size_per_group=None, max_sample_size_per_group=None, hist_bins=51, sel_props=None, sel_src=None, sel_dest=None, edges_popul_name=None, CV_dict=None, **_)[source]

Extracts statistics (like mean, std, min, max, histogram, …) for synapse properties of samples of connections between each pair of m-types.

Parameters:
  • circuit (bluepysnap.Circuit) – Input circuit

  • min_sample_size_per_group (int) – Minimum number of samples (connections) required based on which to estimate statistics for a given pair of m-types; otherwise, no statistics will be estimated

  • max_sample_size_per_group (int) – Maximum number of samples (connections) based on which to estimate statistics for a given pair of m-types; if more samples are available, a random subset is used

  • hist_bins (int) – Number of bins for extracting histograms

  • sel_props (list-like) – List of synaptic property names to extract statistics from; None to select default properties

  • sel_src (str/list-like/dict) – Source (pre-synaptic) neuron selection

  • sel_dest (str/list-like/dict) – Target (post-synaptic) neuron selection

  • edges_popul_name (str) – Name of SONATA egdes population to extract data from

  • CV_dict (dict) – Optional cross-validation dictionary, containing “n_folds” (int), “fold_idx” (int), “training_set” (bool) keys; will be automatically provided by the framework if “CV_folds” are specified

Returns:

Dictionary containing the extracted data elements

Return type:

dict

Note

The following statistics will be extracted:

  • “mean” (float): Data mean

  • “std” (float): Standard deviation

  • “min” (float): Minimum value

  • “max” (float): Maximum value

  • “hist” (tuple): Histogram with hist_bins bins; stored as (counts, edges) tuple as returned by numpy.histogram()

  • “norm_loc” (float): Location estimate for truncnorm distributions

  • “norm_scale” (float): Scale estimate for truncnorm distributions

  • “val” (list-like): List of unique values for discrete distributions (*)

  • “cnt” (list-like): List of unique value counts for discrete distributions (*)

  • “p” (list-like): List of unique value probabilities for discrete distributions (*)

  • “shared_within” (bool): Flag indicating that all synapses within a connection share the same value for a given property; not applicable for #synapses/connection

(*) Discrete statistics (i.e., “val”/”cnt”/”p”) are only stored if there are not too many (less or equal MAX_UNIQUE_COUNT=100).

Note

Statistics for #synapses/connection will always be extracted, even if no properties are selected under sel_props (i.e., empty list).

connectome_manipulator.model_building.conn_props.plot(out_dir, syns_per_conn_data, conn_prop_data, m_types, syn_props, model, plot_sample_size=1000, **_)[source]

Visualizes extracted data vs. actual model output.

Parameters:
  • out_dir (str) – Path to output directory where the results figures will be stored

  • syns_per_conn_data (dict) – Dictionary with entries for all statistics (see Notes under extract()) estimated for #synapses/connection, each of which contains a numpy.ndarray of size <#source-mtypes x #target-mtypes> for all pairs of m-types, as returned by extract()

  • conn_prop_data (dict) – Dictionary with entries for all statistics (see Notes under extract()) estimated for all synaptic properties, each of which contains a numpy.ndarray of size <#source-mtypes x #target-mtypes x #properties> for all pairs of m-types and synapse properties, as returned by extract()

  • m_types (list) – Two-element list of lists of source (pre-synaptic) and target (post-synaptic) m-types, as returned by extract()

  • syn_props (list-like) – List of synaptic property names stored in conn_prop_data, as returned by extract()

  • model (connectome_manipulator.model_building.model_types.ConnPropsModel) – Fitted connection/synapse properties model, as returned by build()

  • plot_sample_size (int) – Number of samples to draw when plotting model distributions