viziphant.patterns.plot_patterns_hypergraph¶
- viziphant.patterns.plot_patterns_hypergraph(patterns, num_neurons=None)[source]¶
Hypergraph visualization of spike patterns.
The spike patterns are interpreted as a hypergraph. Neurons are interpreted as vertices of the hypergraph while patterns are interpreted as hyperedges. Thus, every pattern connects multiple neurons.
Neurons are depicted as circles on a 2D diagram. A graph layout algorithm is applied to the hypergraph in order to determine suitable positions for the neurons. Neurons participating in common patterns are placed close to each other while neurons not sharing a common pattern are placed further apart.
Each pattern is drawn, based on this diagram of neurons, in such a way that it illustrates which neurons participated in the pattern. The method used for this is called the subset standard. The pattern is drawn as a smooth shape around all neurons that participated in it.
The shapes of the patterns are colored such that every pattern has its own color. This makes distinguishing between different patterns easier, especially if their drawings overlap.
- Parameters:
- patternsdict or list of dict
One or more patterns from a list of found patterns returned by
elephant.spade.spade()
orelephant.cell_assembly_detection.cell_assembly_detection()
pattern detectors.- num_neurons: None or int
If None, only the neurons that are part of a pattern are shown. If an integer is passed, it identifies the total number of recorded neurons including non-pattern neurons to be additionally shown in the graph. Default: None
- Returns:
- A handle to a matplotlib figure containing the hypergraph.
Examples
Here, we show an example of plotting random patterns from the CAD method:
import matplotlib.pyplot as plt import numpy as np import quantities as pq from elephant.cell_assembly_detection import cell_assembly_detection from elephant.conversion import BinnedSpikeTrain from elephant.spike_train_generation import compound_poisson_process import viziphant np.random.seed(30) spiketrains = compound_poisson_process(rate=15 * pq.Hz, amplitude_distribution=[0, 0.95, 0, 0, 0, 0, 0.05], t_stop=5*pq.s) bst = BinnedSpikeTrain(spiketrains, bin_size=10 * pq.ms) bst.rescale('ms') patterns = cell_assembly_detection(bst, max_lag=2) fig = viziphant.patterns.plot_patterns_hypergraph(patterns) plt.show()