inm-6 / viziphant Goto Github PK
View Code? Open in Web Editor NEWVisualization of electrophysiological data from Elephant
Home Page: https://viziphant.readthedocs.io/en/latest/
License: BSD 3-Clause "New" or "Revised" License
Visualization of electrophysiological data from Elephant
Home Page: https://viziphant.readthedocs.io/en/latest/
License: BSD 3-Clause "New" or "Revised" License
Unitary events are displayed outside of the region where the analytical significance crosses the p-value threshold. The issue persists in the old UEA plots, so it's not a regression bug introduced by the recent changes in #32.
The figure is a zoomed-in part of the UEA tutorial.
Updated the plot.
Even if the events are not spurious, they look as such. What should we do about it?
BTW, the bottom axis 5 is not shifted by win_size / 2
in the X direction as in axis 4, for example.
Otherwise its easy to pass up this project because the results are unseen.
The plotting of array grids (currently: array_data module
) should utilize information of the Neo object to plot itself, e.g., which electrode is which channel, etc. Currently this is not well solved. This is related to work of @rgutzen in trying to find a nice way to encode this (e.g., using array annotations or even modifications in Neo), but also is related to the imagesequence objects introduced in Neo 0.8.
Generating the plot for UEA occasionally results in multiple instances of the following warning:
RuntimeWarning: invalid value encountered in greater_equal
sig_idx_win = numpy.where(Js_dict['Js'] >= Js_sig)[0]
To Recreate:
import elephant.unitary_event_analysis as ue
import numpy as np
import quantities as pq
from elephant.spike_train_generation import homogeneous_poisson_process as hpp
from viziphant import unitary_event_analysis
np.random.seed(10)
spiketrains1 = [hpp(10 * pq.Hz, t_start=0.0*pq.ms, t_stop=2000*pq.ms) for _
in range(5)]
spiketrains2 = [hpp(50 * pq.Hz, t_start=0.0*pq.ms, t_stop=2000*pq.ms) for _
in range(5)]
data = np.vstack((spiketrains1, spiketrains2)).T
winsize = 100 * pq.ms
bin_size = 5 * pq.ms
winstep = 20 * pq.ms
pattern_hash = [3]
ue_dict = ue.jointJ_window_analysis(data, bin_size, winsize,
winstep, pattern_hash)
significance_level = 0.05
plot_params = {'events': {}}
fig = unitary_event_analysis.plot_ue(
data, ue_dict, significance_level, bin_size, winsize,
winstep, pattern_hash, plot_params
)
Currently, Viziphant can plot triple correlations, but the labeling is somewhat off, and only the hash [1 1 1] is correctly plotted. For other hashes non-involved neurons should not get a rectangle, e.g., for [1 0 1] no rectangles in cyan or red should be plotted for the middle neuron.
Looking into the code for the rasterplot_rates
function, the computation of the population histogram uses the matplotlib
hist
function (lines 465 and 469 of rasterplot.py
).
It would be useful to reuse the time_histogram
function from Elephant, which provides more options to control the histogram, especially the ability to normalize by either mean or density.
For viziphant version 0.1.0 the usage of the default parameters for the plot_isi_histogram
results in
'numpy.float64' object has no attribute 'rescale'
Here is a minimal breaking example
st = neo.SpikeTrain([1,2,3]*pq.s,t_stop=10*pq.s)
viziphant.statistics.plot_isi_histogram(spiketrains)
Tested with:
The following example:
import numpy as np
import quantities as pq
from elephant.gpfa import GPFA
from elephant.spike_train_generation import StationaryPoissonProcess
from viziphant.gpfa import plot_trajectories
from matplotlib import pyplot as plt
data = []
for trial in range(50):
n_channels = 20
firing_rates = np.random.randint(low=1, high=100, size=n_channels) * pq.Hz
spike_times = [StationaryPoissonProcess(rate=rate).generate_spiketrain()
for rate in firing_rates]
data.append(spike_times)
gpfa = GPFA(bin_size=20*pq.ms, x_dim=8)
gpfa.fit(data)
results = gpfa.transform(data, returned_data=['latent_variable_orth',
'latent_variable'])
trial_id_lists = np.arange(50).reshape(5, 10)
trial_group_names = ['A', 'B', 'C', 'D', 'E']
trial_grouping_dict = {}
for trial_group_name, trial_id_list in zip(trial_group_names, trial_id_lists):
trial_grouping_dict[trial_group_name] = trial_id_list
plot_trajectories(results,
gpfa,
dimensions=[0, 1, 2],
trial_grouping_dict=trial_grouping_dict,
plot_group_averages=True)
plt.show()
gives the following error:
line 572, in plot_trajectories
axes = fig.gca(projection=projection, aspect='auto')
TypeError: gca() got an unexpected keyword argument 'projection'
The plot_patterns
function apparently only works for synchronous patterns, but not when there is a lag between the spikes.
The code below illustrates that
import numpy as np
import quantities as pq
import neo
from elephant.spade import spade
from elephant.spike_train_generation import homogeneous_poisson_process
from copy import deepcopy
import viziphant
# Generate two types of pattern: one synchronous and other with lags
np.random.seed(123)
sync_spiketrains = [homogeneous_poisson_process(rate=3*pq.Hz, t_stop=1*pq.s) for _ in range(50)]
lag_spiketrains = deepcopy(sync_spiketrains)
pattern_times = pq.Quantity([212, 574, 876], units=pq.ms)
pattern_neurons = []
pattern = neo.SpikeTrain(pattern_times, t_stop=1*pq.s)
for st in sync_spiketrains[:4]:
pattern_st = st.merge(pattern)
pattern_neurons.append(pattern_st)
sync_spiketrains[:4] = pattern_neurons
pattern_neurons = []
for idx, st in enumerate(lag_spiketrains[:4]):
pattern = neo.SpikeTrain(pattern_times + idx * (10 * pq.ms), t_stop=1*pq.s)
pattern_st = st.merge(pattern)
pattern_neurons.append(pattern_st)
lag_spiketrains[:4] = pattern_neurons
Run SPADE using the synchronous patterns and plot:
sync_patterns = spade(sync_spiketrains, bin_size=5*pq.ms, winlen=10, min_spikes=3,
n_surr=100, dither=5*pq.ms, psr_param=[0,0,0], alpha=0.05)
print(sync_patterns['patterns'])
viziphant.patterns.plot_patterns(sync_spiketrains, sync_patterns['patterns'])
Output:
[{'itemset': (20, 0, 10, 30),
'windows_ids': (42, 114, 175),
'neurons': [2, 0, 1, 3],
'lags': array([0., 0., 0.]) * ms,
'times': array([210., 570., 875.]) * ms,
'signature': (4, 3),
'pvalue': 0.01}]
Run SPADE using the pattern with lags and plot:
lag_patterns = spade(lag_spiketrains, bin_size=5*pq.ms, winlen=10, min_spikes=3,
n_surr=100, dither=5*pq.ms, psr_param=[0,0,0], alpha=0.05)
print(lag_patterns['patterns'])
viziphant.patterns.plot_patterns(lag_spiketrains, lag_patterns['patterns'])
Output:
[{'itemset': (24, 36, 12, 0),
'windows_ids': (42, 114, 175),
'neurons': [0, 1, 2, 3],
'lags': array([10., 20., 30.]) * ms,
'times': array([210., 570., 875.]) * ms,
'signature': (4, 3),
'pvalue': 0.0}]
Expected output
Spikes in the second plot would be shown with the lags, overlapping with the original spike trains in gray.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.