cross-correlogram

154 views
Skip to first unread message

jonathan platkiewicz

unread,
May 5, 2015, 2:08:17 PM5/5/15
to brians...@googlegroups.com
Hi,

I am using the code available on Brian for computing auto- or cross-correlograms (see below). But I obtained sometimes (and usually, in the most interesting cases), the artifacts shown on the attached figure (note that there are 58,000 spikes in the train). 

Can someone help me with that? 

I already posted a related question, but I didn't manage to solve this problem. Note: the problem is not "bin size < signal discretization size" (bin size = 1 ms; signal discretization size = 0.05 ms, since sampling frequency = 20kHz).

That would be great if someone can help me with this issue. It should be a numerical error, but I cannot figure out which one. 

Thank you,
Jonathan
--

def CCG(T1,T2,width,bin,T):
    '''
    Returns a cross-correlogram with lag in [-width,width] and given bin size.
    T is the total duration (optional) and should be greater than the duration of T1 and T2.
    The result is in Hz (rate of coincidences in each bin).

    N.B.: units are discarded.
    '''
    # Remove units
    Fs = 20000.      #-sampling frequency in (Hz)
    dt = 1/Fs*10**3  #-elementary time step in (ms) 
    width = int64(width/dt)
    bin = int64(bin/dt)
    T1 = array(T1)
    T2 = array(T2)
    i = 0
    j = 0
    n = int64(ceil(width/bin)) # Histogram length
    l = []
    for t in T1:
        while i < len(T2) and T2[i] < t-width: # other possibility use searchsorted
            i += 1
        while j < len(T2) and T2[j] < t+width:
            j += 1
        l.extend(T2[i:j]-t)
    H,_ = histogram(l,bins=arange(2*n+1)*bin*dt-n*bin*dt)
   
    # Divide by time to get rate
    if T is None:
        T=max(T1[-1],T2[-1])-min(T1[0],T2[0])
    # Windowing function (triangle)
    #W=zeros(2*n)
    #W[:n]=T-bin*arange(n-1,-1,-1)
    #W[n:]=T-bin*arange(n)
   
    return H/T*10**6 

autocorrelogram_artifact.png

jonathan platkiewicz

unread,
May 5, 2015, 2:13:41 PM5/5/15
to brians...@googlegroups.com
Hi again,

I am also attaching a python file of the spike train used for computing the auto-correlogram (in the figure), in case it could be useful.

Thank you,
Jonathan

spiketimes_artifact.npy

Cyrille Rossant

unread,
May 5, 2015, 2:16:27 PM5/5/15
to brians...@googlegroups.com
Hi Jonathan

FYI there's another implementation of CCGs at
https://github.com/kwikteam/phy/blob/master/phy/stats/ccg.py

It's not extensively tested but it seems to work... It should be quite
fast (vectorized), especially when you want to compute all pairwise
CCGs in a set of neurons.

Cyrille

2015-05-05 20:08 GMT+02:00 jonathan platkiewicz
<jonathan.p...@gmail.com>:
> --
> http://www.facebook.com/briansimulator
> https://twitter.com/briansimulator
>
> New paper about Brian 2: Stimberg M, Goodman DFM, Benichoux V, Brette R
> (2014).Equation-oriented specification of neural models for simulations.
> Frontiers Neuroinf, doi: 10.3389/fninf.2014.00006.
> ---
> You received this message because you are subscribed to the Google Groups
> "Brian" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to briansupport...@googlegroups.com.
> To post to this group, send email to brians...@googlegroups.com.
> Visit this group at http://groups.google.com/group/briansupport.
> For more options, visit https://groups.google.com/d/optout.

Dan Goodman

unread,
May 7, 2015, 12:02:53 PM5/7/15
to brians...@googlegroups.com
Hey Jonathan,

Could you try Cyrille's code and see if it works better for you? Let us
know either way.

Dan
Reply all
Reply to author
Forward
0 new messages