# Analysis of Sequences of Synchronous EvenTs (ASSET)¶

ASSET is a statistical method [asset1] for the detection of repeating sequences of synchronous spiking events in parallel spike trains.

## ASSET analysis class object of finding patterns¶

`ASSET` (spiketrains_i[, spiketrains_j, ...]) |
Analysis of Sequences of Synchronous EvenTs class. |

## Patterns post-exploration¶

`synchronous_events_intersection` (sse1, sse2) |
Given two sequences of synchronous events (SSEs) sse1 and sse2, each consisting of a pool of positions (iK, jK) of matrix entries and associated synchronous events SK, finds the intersection among them. |

`synchronous_events_difference` (sse1, sse2[, ...]) |
Given two sequences of synchronous events (SSEs) sse1 and sse2, each consisting of a pool of pixel positions and associated synchronous events (see below), computes the difference between sse1 and sse2. |

`synchronous_events_identical` (sse1, sse2) |
Given two sequences of synchronous events (SSEs) sse1 and sse2, each consisting of a pool of pixel positions and associated synchronous events (see below), determines whether sse1 is strictly contained in sse2. |

`synchronous_events_no_overlap` (sse1, sse2) |
Given two sequences of synchronous events (SSEs) sse1 and sse2, each consisting of a pool of pixel positions and associated synchronous events (see below), determines whether sse1 and sse2 are disjoint. |

`synchronous_events_contained_in` (sse1, sse2) |
Given two sequences of synchronous events (SSEs) sse1 and sse2, each consisting of a pool of pixel positions and associated synchronous events (see below), determines whether sse1 is strictly contained in sse2. |

`synchronous_events_contains_all` (sse1, sse2) |
Given two sequences of synchronous events (SSEs) sse1 and sse2, each consisting of a pool of pixel positions and associated synchronous events (see below), determines whether sse1 strictly contains sse2. |

`synchronous_events_overlap` (sse1, sse2) |
Given two sequences of synchronous events (SSEs) sse1 and sse2, each consisting of a pool of pixel positions and associated synchronous events (see below), determines whether the two SSEs overlap. |

## Examples¶

In this example we

- simulate two noisy synfire chains;
- shuffle the neurons to destroy visual appearance;
- run ASSET analysis to recover the original neurons arrangement.

Simulate two noise synfire chains, shuffle the neurons to destroy the pattern visually, and store shuffled activations in neo.SpikeTrains.

>>> import neo >>> import numpy as np >>> import quantities as pq >>> np.random.seed(10) >>> spiketrain = np.linspace(0, 50, num=10) >>> np.random.shuffle(spiketrain) >>> spiketrains = np.c_[spiketrain, spiketrain + 100] >>> spiketrains += np.random.random_sample(spiketrains.shape) * 5 >>> spiketrains = [neo.SpikeTrain(st, units='ms', t_stop=1 * pq.s) ... for st in spiketrains]

Create ASSET class object that holds spike trains.

ASSET requires at least one argument - a list of spike trains. If spiketrains_y is not provided, the same spike trains are used to build an intersection matrix with.

>>> from elephant import asset >>> asset_obj = asset.ASSET(spiketrains, bin_size=3*pq.ms)

Build the intersection matrix imat:

>>> imat = asset_obj.intersection_matrix()

Estimate the probability matrix pmat, using the analytical method:

>>> pmat = asset_obj.probability_matrix_analytical(imat, ... kernel_width=50*pq.ms)

Compute the joint probability matrix jmat, using a suitable filter:

>>> jmat = asset_obj.joint_probability_matrix(pmat, filter_shape=(5, 1), ... n_largest=3)

Create the masked version of the intersection matrix, mmat, from pmat and jmat:

>>> mmat = asset_obj.mask_matrices([pmat, jmat], thresholds=.9)

Cluster significant elements of imat into diagonal structures:

>>> cmat = asset_obj.cluster_matrix_entries(mmat, max_distance=11, ... min_neighbors=3, stretch=5)

Extract sequences of synchronous events:

>>> sses = asset_obj.extract_synchronous_events(cmat)

The ASSET found the following sequences of synchronous events:

```
>>> sses
{1: {(36, 2): {5},
(37, 4): {1},
(40, 6): {4},
(41, 7): {8},
(43, 9): {2},
(47, 14): {7},
(48, 15): {0},
(50, 17): {9}}}
```

To visualize them, refer to Viziphant documentation and an example plot
`viziphant.asset.plot_synchronous_events()`

.

## References¶

[asset1] | E. Torre, C. Canova, M. Denker, G. Gerstein, M. Helias, and S. Grün. Asset: analysis of sequences of synchronous events in massively parallel spike trains. PLoS Comp. Biol., 12(7):e1004939, 2016. doi:10.1371/journal.pcbi.1004939. |