Git Product home page Git Product logo

viziphant's Introduction

Viziphant

Documentation Status ![PyPi] Viziphant-tests

A Python module for easy visualization of Neo objects and Elephant results.

Viziphant provides a high-level API to easily generate plots and interactive visualizations of neuroscientific data and analysis results. This API uses and extends the same structure as in Elephant to ensure intuitive usage for scientists that are used to Elephant.

Documentation

https://viziphant.readthedocs.io/en/latest/

Getting in touch

Installation

For instructions on installing Viziphant, please see https://viziphant.readthedocs.io/en/latest/install.html

Copyright

Šī¸ 2017-2023 by the Viziphant team.

License

BSD 3-Clause License, see LICENSE.txt for details.

Acknowledgments

See acknowledgments.

viziphant's People

Contributors

alperyeg avatar dizcza avatar essink avatar kleinjohann avatar kohlerca avatar mdenker avatar moritz-alexander-kern avatar muellerbjoern avatar pbouss avatar pietroquaglio avatar rgutzen avatar rjurkus avatar stellalessandra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

viziphant's Issues

Error in plot_isi_histogram for default cutoff value

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)

Viziphant UE plotting to handle triple correlations (and more)

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.

Unitary Events RuntimeWarning

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
)

Array plotting should use Neo annotations and utilize ImageSequence object

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.

Bug: viziphant.gpfa plot_trajectories with matplotlib-3.6.2

Tested with:

  • python: 3.8.10
  • viziphant: 0.2.0
  • matplotlib: 3.6.2

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'

[Enh] Reuse Elephant function for `rasterplot_rates`

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.

Function to plot patterns from SPADE does not consider lags

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}]

image

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}]

image

Expected output

Spikes in the second plot would be shown with the lags, overlapping with the original spike trains in gray.

UEA spurious coincident events

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.

UEA_tutorial_bug

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.