m, c, l = mot[rec.absname], con[rec.absname], lum[rec.absname]
        tm = tmovie[rec.absname]
        ms = motspars[rec.absname]
        psthis0d = t.searchsorted(tm) # PSTH indices closest to movie frame times, no delay
        dt = rec.e0.d.sweepSec # frame duration in seconds
        corrdelaysec = corrdelay / 1000 # convert from ms to s
        ntdelay = intround(corrdelaysec / dt) # ntimepoints to delay movie-PSTH correlation by
        if ntdelay >= 0:
            psthis = psthis0d[ntdelay:]
            movieis = np.arange(0, len(tm)-ntdelay)
        else: # ntdelay is -ve
            psthis = psthis0d[:ntdelay]
            movieis = np.arange(abs(ntdelay), len(tm))
        for nid in sorted(rpsths[rec.absname][statei]):
            psth = rpsths[rec.absname][statei][nid]
            motrho = core.corrcoef(m[movieis], psth[psthis])
            conrho = core.corrcoef(c[movieis], psth[psthis])
            lumrho = core.corrcoef(l[movieis], psth[psthis])
            motrhos[state].append(motrho)
            conrhos[state].append(conrho)
            lumrhos[state].append(lumrho)
            motscatspars[state].append([ms, core.sparseness(psth)])
            if nid not in recsecscatmotrhos[rec.absname]:
                recsecscatmotrhos[rec.absname][nid] = [NULLRHO, NULLRHO] # init list for this nid
                recsecscatconrhos[rec.absname][nid] = [NULLRHO, NULLRHO]
                recsecscatlumrhos[rec.absname][nid] = [NULLRHO, NULLRHO]
            recsecscatmotrhos[rec.absname][nid][statei] = motrho
            recsecscatconrhos[rec.absname][nid][statei] = conrho
            recsecscatlumrhos[rec.absname][nid][statei] = lumrho

            if rec.absname == EXAMPLERECNAME and nid == EXAMPLENID:
示例#2
0
    stranges = REC2STATETRANGES[rec.absname]
    for statei, strange in enumerate(stranges): # desynched, then synched
        lfpt, lfps = rec.tlfps(trange=strange, blank=BLANK, plot=False)
        muat, muas = rec.tmuas(trange=strange, blank=BLANK, plot=False) # Hz/unit
        TLFPs[rec.absname].append((lfpt, lfps))
        TMUAs[rec.absname].append((muat, muas))
        MAXMUA[rec.absname] = max(MAXMUA[rec.absname], muas.max())
        ntrials = len(lfps)
        assert ntrials == len(muas)
        for triali in range(ntrials):
            # measure reliability as correlation of each trial with mean of all others.
            # To exclude last sec of blankscreen in each trial, set BLANK=False:
            lfptrial, muatrial = lfps[triali], muas[triali]
            otheris = np.ones(ntrials, dtype=bool)
            otheris[triali] = False # exclude current trial
            LFPCORRS[statei].append(corrcoef(lfptrial, lfps[otheris].mean(axis=0)))
            MUACORRS[statei].append(corrcoef(muatrial, muas[otheris].mean(axis=0)))
            LFPSPARS[statei].append(sparseness(abs(lfptrial)))
            MUASPARS[statei].append(sparseness(muatrial))

for statei in range(2): # desynched, then synched
    LFPCORRS[statei] = np.asarray(LFPCORRS[statei]) # convert from list to array
    MUACORRS[statei] = np.asarray(MUACORRS[statei])
    LFPSPARS[statei] = np.asarray(LFPSPARS[statei])
    MUASPARS[statei] = np.asarray(MUASPARS[statei])

# plot LFP and MUA time series, plus mean and stdevs, and SNR time series:
for rec in urecs:
    print(rec.absname)
    # subplotting trickery from
    # http://stackoverflow.com/questions/22511550/gridspec-with-shared-axes-in-python
示例#3
0
            cs = n2count[nid] # 2D array of spike counts over trial time, one row per trial
            rhos, weights = core.pairwisecorr(cs, weight=WEIGHT, invalid='ignore')
            # set rho to 0 for trial pairs with undefined rho (one or both trials
            # with 0 spikes):
            nanis = np.isnan(rhos)
            rhos[nanis] = 0.0
            # for log plotting convenience, replace any mean rhos < NULLREL with NULLREL
            rel = np.mean(rhos)
            if rel < NULLREL:
                rel = NULLREL
                nreplacedbynullrel += 1
            rels[statei].append(rel)
            # calculate sparseness of this PSTH:
            spars[statei].append(sparseness(psth))
            # calculate coupling of this PSTH with tMUA:
            coup = core.corrcoef(psth, tmua)
            coups[statei].append(coup)
        print()

for statei in stateis:
    rels[statei] = np.asarray(rels[statei])
    spars[statei] = np.asarray(spars[statei])
    coups[statei] = np.asarray(coups[statei])

# plot MUA coupling histogram:
dmean = coups[0].mean()
smean = coups[1].mean()
u, p = mannwhitneyu(coups[0], coups[1]) # 1-sided
if p < ALPHA:
    pstring = 'p < %g' % ceilsigfig(p)
else:
示例#4
0
                                              weight=WEIGHT,
                                              invalid='ignore')
            # set rho to 0 for trial pairs with undefined rho (one or both trials
            # with 0 spikes):
            nanis = np.isnan(rhos)
            rhos[nanis] = 0.0
            # for log plotting convenience, replace any mean rhos < NULLREL with NULLREL
            rel = np.mean(rhos)
            if rel < NULLREL:
                rel = NULLREL
                nreplacedbynullrel += 1
            rels[statei].append(rel)
            # calculate sparseness of this PSTH:
            spars[statei].append(sparseness(psth))
            # calculate coupling of this PSTH with tMUA:
            coup = core.corrcoef(psth, tmua)
            coups[statei].append(coup)
        print()

for statei in stateis:
    rels[statei] = np.asarray(rels[statei])
    spars[statei] = np.asarray(spars[statei])
    coups[statei] = np.asarray(coups[statei])

# plot MUA coupling histogram:
dmean = coups[0].mean()
smean = coups[1].mean()
u, p = mannwhitneyu(coups[0], coups[1])  # 1-sided
if p < ALPHA:
    pstring = 'p < %g' % ceilsigfig(p)
else:
 psthis0d = t.searchsorted(
     tm)  # PSTH indices closest to movie frame times, no delay
 dt = rec.e0.d.sweepSec  # frame duration in seconds
 corrdelaysec = corrdelay / 1000  # convert from ms to s
 ntdelay = intround(
     corrdelaysec /
     dt)  # ntimepoints to delay movie-PSTH correlation by
 if ntdelay >= 0:
     psthis = psthis0d[ntdelay:]
     movieis = np.arange(0, len(tm) - ntdelay)
 else:  # ntdelay is -ve
     psthis = psthis0d[:ntdelay]
     movieis = np.arange(abs(ntdelay), len(tm))
 for nid in sorted(rpsths[rec.absname][statei]):
     psth = rpsths[rec.absname][statei][nid]
     motrho = core.corrcoef(m[movieis], psth[psthis])
     conrho = core.corrcoef(c[movieis], psth[psthis])
     lumrho = core.corrcoef(l[movieis], psth[psthis])
     motrhos[state].append(motrho)
     conrhos[state].append(conrho)
     lumrhos[state].append(lumrho)
     motscatspars[state].append([ms, core.sparseness(psth)])
     if nid not in recsecscatmotrhos[rec.absname]:
         recsecscatmotrhos[rec.absname][nid] = [
             NULLRHO, NULLRHO
         ]  # init list for this nid
         recsecscatconrhos[rec.absname][nid] = [NULLRHO, NULLRHO]
         recsecscatlumrhos[rec.absname][nid] = [NULLRHO, NULLRHO]
     recsecscatmotrhos[rec.absname][nid][statei] = motrho
     recsecscatconrhos[rec.absname][nid][statei] = conrho
     recsecscatlumrhos[rec.absname][nid][statei] = lumrho
示例#6
0
        lfpt, lfps = rec.tlfps(trange=strange, blank=BLANK, plot=False)
        muat, muas = rec.tmuas(trange=strange, blank=BLANK,
                               plot=False)  # Hz/unit
        TLFPs[rec.absname].append((lfpt, lfps))
        TMUAs[rec.absname].append((muat, muas))
        MAXMUA[rec.absname] = max(MAXMUA[rec.absname], muas.max())
        ntrials = len(lfps)
        assert ntrials == len(muas)
        for triali in range(ntrials):
            # measure reliability as correlation of each trial with mean of all others.
            # To exclude last sec of blankscreen in each trial, set BLANK=False:
            lfptrial, muatrial = lfps[triali], muas[triali]
            otheris = np.ones(ntrials, dtype=bool)
            otheris[triali] = False  # exclude current trial
            LFPCORRS[statei].append(
                corrcoef(lfptrial, lfps[otheris].mean(axis=0)))
            MUACORRS[statei].append(
                corrcoef(muatrial, muas[otheris].mean(axis=0)))
            LFPSPARS[statei].append(sparseness(abs(lfptrial)))
            MUASPARS[statei].append(sparseness(muatrial))

for statei in range(2):  # desynched, then synched
    LFPCORRS[statei] = np.asarray(
        LFPCORRS[statei])  # convert from list to array
    MUACORRS[statei] = np.asarray(MUACORRS[statei])
    LFPSPARS[statei] = np.asarray(LFPSPARS[statei])
    MUASPARS[statei] = np.asarray(MUASPARS[statei])

# plot LFP and MUA time series, plus mean and stdevs, and SNR time series:
for rec in urecs:
    print(rec.absname)