Initialize tutorial — Elephant 0.5.0 documentation

# Initialize tutorial

First, we perform some initial steps to set up the tutorial.

    In [1]:

    import random
    import numpy as np
    import matplotlib.pyplot as plt
    import quantities as pq
    import neo

    import elephant.unitary_event_analysis as ue

    # Fix random seed to guarantee fixed output
    random.seed(1224)

    /home/denker/anaconda/envs/stdpy2/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
      from ._conv import register_converters as _register_converters

Next, we download a data file containing spike train data from multiple trials of two neurons.

    In [2]:

    # Download data
    !wget -Nq https://github.com/INM-6/elephant-tutorial-data/raw/master/dataset-1/dataset-1.h5

# Load data and extract spiketrains

    In [4]:

    block = neo.io.NeoHdf5IO("./dataset-1.h5")
    sts1 = block.read_block().segments[0].spiketrains
    sts2 = block.read_block().segments[1].spiketrains
    spiketrains = np.vstack((sts1,sts2)).T

# Calculate Unitary Events

    In [5]:

    UE = ue.unitary_event_analysis(
        spiketrains, bin_size=5*pq.ms, window_size=100*pq.ms, window_step=10*pq.ms, pattern_hash=[3])

    plot_UE(
            spiketrains, UE, ue.jointJ(0.05),binsize=5*pq.ms,winsize=100*pq.ms,winstep=10*pq.ms,
            pat=ue.inverse_hash_from_pattern([3], N=2), N=2,
            t_winpos=ue._winpos(0*pq.ms,spiketrains[0][0].t_stop,winsize=100*pq.ms,winstep=10*pq.ms))
    plt.show()

    plotting UEs ...
    plotting Raw Coincidences ...
    plotting PSTH ...
    plotting emp. and exp. coincidences rate ...
    plotting Surprise ...

    In [6]:

    In [6]: