Semantics of Neuronal Cascades

class Geometric_Brain_Network.Geometric_Brain_Network(size, geometric_degree=1, nongeometric_degree=0, manifold='Ring', noise_type='k-regular', matrix=None, perturb=0, higher_order=False)

Bases: object

Geometric Brain Network object to run simplicial cascades on.

N

Size, number of nodes in the network.

Type

int

GD

Geometric degree of the network.

Type

int

nGD

non-Geometric degree of the network.

Type

int

manifold

The geometric topology of the network. Only ‘Ring’ is available currently.

Type

str

text

Summary of the network.

Type

str

A

Adjacency matrix of the graph.

Type

array n x n

nodes

A list of neuron objects that corresponds to the nodes of the network in which IDs of the neurons match with the IDs of the nodes.

Type

List

time

An intrinsic time property to keep track of number of iterations of the experiments.

Type

int

triangles

A dictionay of the triangles of the network where keys are node ids and values are lists of pairs of node ids that makes up a triangle together with the key value.

Type

dict

higher_order

Flag if a higher-order experiment is to be run, that is K>0.

Type

Boolean

Parameters
  • size (int) – Size of the network to be initialized.

  • geometric_degree (int) – Uniform number of local neighbors that every node has.

  • nongeometric_degree (int) – Fixed number of distant neighbors that every node has.

  • manifold (str) – Type of the network to be created. If ‘Ring’ or ‘random_Ring’ then a syntehtic ring network will be created, if ‘lattice’ then matrix argument can be used to input any adjacency matrix.

  • noise_type (str) – k-regular or er-like

  • matrix (array-like) – Argument for inputting and adjacency matrix, ff manifold is ‘lattice’.

  • perturb (int) – Number of edges per vertex that the local manifold is to be perturbed.

  • higher_order (Boolean) – Flag for higher-order experiments. Since extracting the triangles is costly, when running an edge-based model, we don’t have to compute them.

ablate_geo_triangles(A)

Helper to remove links from the geometric strata. self.perturb many links per vertex will be removed. :param A: Adjacency matrix of the network. :type A: array

Returns

A – Perturbed adjacency matrix.

Return type

array

add_noise_to_geometric()

This method adds non-geometric edges to the network that are long range. Every node will have nGD many nongeometric, long range, edges. Options are ‘k-regular’, ‘ER_like’ and ‘2D_k-regular’.

compute_persistence(distances, dimension, spy)

Helper to compute persistent homology using the distance matrix by building a Rips filtration up to given dimension(topological features to be observed are going to be one less dimensional at max). First normalizes the distances before the computation.

Parameters
  • distances (n x n array) – distance matrix. First output of the make_distance_matrix.

  • dimension (int) – Max dimension of the topological features to be computed.

  • spy (bool, optional) – Take a peak at the persistence diagram.

Returns

  • Delta_min (array) – Difference of the lifetimes between longest and second longest living two 1-cycles.

  • Delta_max (array) – Difference of the lifetimes between longest and shortest living two 1-cycles.

display_comm_sizes(Q, labels, TIME, C, threshold, K)

Helper to visualize the size of the active nodes during the contagion. Shades are indicating the max and min values of the spread starting from different nodes, seed node variations.

Parameters
  • Q (list, [n x T+1 array]) – Output of the make_distance_matrix appended in a list

  • labels (list) – Figure labels corresponding to every list element for different thresholds.

  • TIME (int) – A limit on the number of iterations.

  • C (int) – Constant for tuning stochasticity. Higher values yield a deterministic model whereas lower values yield a stochastic model.

  • K (float) – Constant for weighing the edge and triangle activations.

Returns

  • fig (matplotlib object) – Figure to be drawn.

  • ax (matplotlib object) – Axis object for the plots.

get_neurons(neurons)

Sometimes we want to run experiments on a fixed network without changing the network connectivity. In this case, we can initialize a new set of neurons and use this method to inherit them in the network– changing only the neuronal properties but not the connectivity. :param neurons: A list of neuron objects. :type neurons: list

Raises

ValueError – If the number of neurons and the size of the network doesn’t match.

get_nodes_unique_triangles(nonunique_triangle_list, i)

Helper function for finding triangles that flags if a triangle is repeated.

Parameters
  • nonunique_triangle_list (array) – Output of get_nonunique_triangle_list.

  • i (int) – Index of the triangle whose repeated triangle neighbors to be removed.

Returns

  • nonunique_triangle_list[tri_flag,1 (] : array) – Removed triangles for a given node.

  • tri_flag (int) – flag

get_nonunique_triangle_list(A)

Helper method finding all of the triangles in the network including the repeated ones.

Parameters

A (array) – Adjacency matrix of the network

Returns

triangle_list – All triangles in the network.

Return type

array

initial_spread(seed)

Helper method to activate the neighbors of the seed node with probablity 1.

Parameters

seed (int) – Node ID of the seed node.

make_distance_matrix(TIME, C, K)

Main function if you are running experiments for a full set of seed nodes. This creates an activation matrix by running the contagion on starting from every node and encoding the first activation times of each node. Then, finding the euclidean distances between the columns of this matrix, creating a distance matrix so that the (i,j) entry corresponds to the average time(over the trials) that a contagion reaches node j starting from node i.

Parameters
  • TIME (int) – A limit on the number of iterations.

  • C (int) – Constant for tuning stochasticity. Higher values yield a deterministic model whereas lower values yield a stochastic model.

  • K (float) – Constant for weighing the edge and triangle activations.

Returns

  • distance_matrix (array) – n x n array with entries the activation times of contagions starting from node i reaching to node j.

  • Q (array) – n x t array with entries number of active nodes at every time step for contagions starting at different seeds.

make_geometric()

Method for creating a geometric ring network. Options are either ‘Ring’ or ‘random_Ring’. This will be called upon initialization automatically.

neighbor_input(node_id, K)

This is a key function as it computes the current input from neighbors of a given node, v_{i}.

Parameters
  • node_id (int) – ID of the node whose input is going to be calculated.

  • K (float) – Constant for weighing the edge and triangle activations.

Returns

F – Neighboring neuronal input.

Return type

float

refresh()

Helper method for setting the network time and tolerance to 0. This is necessary between different experiments for any set of parameters including seed. Also, calls refresh_history which clears neuoron histories.

Returns

tolerance – Tolerance for experiments getting stuck at some point during contagion. Set to 0 at every trial.

Return type

int

return_triangles()

Function for getting the triangles in the network. This will be automatically called upon initialization of Geometric_Brain_Network.

Returns

triangles – A dictionay of the triangles of the network where keys are node ids and values are lists of pairs of node ids that makes up a triangle together with the key value.

Return type

dict

run_dynamic(seed, TIME, C, K)

Core function that runs the experiments. There are couple control flags for computational efficiency. If self.time exceeds TIME, flag. If there is no active neurons left in the network, flag. If everything gets activated once, flag. If tolerance exceeds 10, flag i.e. network repeats the exact state of itself 10 times.

Parameters
  • seed (int) – Node ID of the seed node.

  • TIME (int) – A limit on the number of iterations.

  • C (int) – Constant for tuning stochasticity. Higher values yield a deterministic model whereas lower values yield a stochastic model.

  • K (float) – Constant for weighing the edge and triangle activations.

Returns

  • activation_times (array) – Activation times of all the nodes for contagions starting from seed.

  • size_of_contagion (array) – Number of active nodes at every iteration.

  • number_of_clusters – Number of distinct cascade clusters.

sigmoid(node_id, C, K)

Sigmoid function which adjusts the stochasticity of the neurons depending on C.

Parameters
  • node_id (int) – ID of the node whose input is going to be calculated.

  • C (int) – Constant for tuning stochasticity. Higher values yield a deterministic model whereas lower values yield a stochastic model.

  • K (float) – Constant for weighing the edge and triangle activations.

Returns

Z – Probability of firing.

Return type

float

stack_histories(TIME)

Helper function for equalizing, stacking, the lengths of histories of ``neuron``s. Comes handy for visualizing single experiments.

Parameters

TIME (int) – Number of discrete time steps for neuron histories to be visualized

Returns

all_historyN x TIME matrix encoding histories of neurons.

Return type

array

update_history(node_id, C, K)

Helper method to update the history of the neuron objects at every iteration.

Parameters
  • node_id (int) – ID of the node whose history is going to be updates.

  • C (int) – Constant for tuning stochasticity. Higher values yield a deterministic model whereas lower values yield a stochastic model.

  • K (float) – Constant for weighing the edge and triangle activations.

update_states()

Helper method to update the states of neuron objects at every iteration.

Returns

  • excited (list) – List of active neurons at the current time.

  • ready_to_fire (list) – List of neurons that are in the inactive state and ready to fire at time+1`.

  • rest (list) – List of neurons that doesn’t belong to either of those categories. This is empty as long as there are no refractory period.

class Geometric_Brain_Network.neuron(name, state, memory, rest, thresold)

Bases: Geometric_Brain_Network.Geometric_Brain_Network

Neuron objects corresponding to the nodes of Geometric_Brain_Network. This is a subclass of Geometric_Brain_Network.

name

Neuron ID.

Type

int

state

State of a neuron, can be 0,1 (or -1 if rest is nonzero).

Type

int

memory

Memeory of a neuron. Once a neuron is activated, it is going to stay active memory many more discrete time steps(so memory + 1 in total).

Type

int

rest

Refractory peiod of a neuron in terms of discrete time steps.

Type

int

threshold

Threshold of a neuron, resistance to excitibility.

Type

int

history

History of a neuron encoding the states that it has gone through.

Type

list

Parameters
  • name (str) – Neuron ID

  • state (int) – State of a neuron(1 Active, 0 Inactive and -1 rest, refractory).

  • memory (int) – Number of discrete time steps a neuron is going to stay active once it is activated.

  • rest (int) – Refractory period of a neuron in discrete time steps.

  • threshold (float) – Threshold of a neuron.

refresh_history()

Helper method that sets the history of every neuron to an empty list. It is called after refresh.