Ejemplo n.º 1
0
    be_inds = _N.array(_N.linspace(beginInd, endInd, sections + 1),
                       dtype=_N.int)
    time_lags = _N.linspace(-(slideby / 300) * lags, lags * (slideby / 300),
                            2 * lags + 1)

    dNGS_acs = _N.empty((sections, 2 * lags + 1))
    fac01s = _N.empty((nStates, sections, 2 * lags + 1))

    wgt_states = _N.zeros((nStates, sections))

    for hlf in range(sections):
        i0 = be_inds[hlf]
        i1 = be_inds[hlf + 1]
        x, dNGS_ac = _eu.autocorrelate(
            cwtl_avg_behv_sig_interp[i0:i1] -
            _N.mean(cwtl_avg_behv_sig_interp[i0:i1]), lags)
        acdNGS_AMP = _N.std(dNGS_ac[0:lags - 5])
        acdNGS_mn = _N.mean(dNGS_ac[0:lags - 5])

        dNGS_acs[hlf] = (dNGS_ac - acdNGS_mn) / acdNGS_AMP

        dNGS_timescales[hlf] = find_osc_timescale(dNGS_ac[lags - 5:], lags)
        toobig = _N.where(dNGS_acs[hlf] > 2.8)[0]
        dNGS_acs[hlf, toobig] = 2.8  #  cut it off

    for ns in range(nStates):
        rmpd_lab = _rmpd_lab

        stateInds = _N.where(rmpd_lab == ns)[0]
Ejemplo n.º 2
0
        be_inds = _N.array(_N.linspace(beginInd, endInd, sections + 1),
                           dtype=_N.int)
        time_lags = _N.linspace(-(slideby / 300) * lags,
                                lags * (slideby / 300), 2 * lags + 1)

        dNGS_acs = _N.empty((sections, 2 * lags + 1))
        fac01s = _N.empty((nStates, sections, 2 * lags + 1))

        wgt_states = _N.zeros((nStates, sections))

        for hlf in range(sections):
            i0 = be_inds[hlf]
            i1 = be_inds[hlf + 1]
            x, dNGS_ac = _eu.autocorrelate(
                cwtl_avg_behv_sig_interp[i0:i1] -
                _N.mean(cwtl_avg_behv_sig_interp[i0:i1]), lags)
            acdNGS_AMP = _N.std(dNGS_ac[0:lags - 5])
            acdNGS_mn = _N.mean(dNGS_ac[0:lags - 5])

            dNGS_acs[hlf] = (dNGS_ac - acdNGS_mn) / acdNGS_AMP

            dNGS_timescales[hlf] = find_osc_timescale(dNGS_ac[lags - 5:], lags)
            toobig = _N.where(dNGS_acs[hlf] > 2.8)[0]
            dNGS_acs[hlf, toobig] = 2.8  #  cut it off

        for ns in range(nStates):
            rmpd_lab = _rmpd_lab

            stateInds = _N.where(rmpd_lab == ns)[0]
Ejemplo n.º 3
0
    wins = _N.where(_hnd_dat[0:TO-2, 2] == 1)[0]
    ww   = _N.where(_hnd_dat[wins+1, 2] == 1)[0]
    win_aft_win[pid-1] = len(ww) / len(wins)
    loses = _N.where(_hnd_dat[0:TO-2, 2] == -1)[0]
    lw   = _N.where(_hnd_dat[loses+1, 2] == 1)[0]
    win_aft_los[pid-1] = len(lw) / len(loses)
    
    dmp       = depickle(getResultFN("%(rpsm)s/%(lb)d/WTL_1.dmp" % {"rpsm" : partID, "lb" : label}))
    _prob_mvs = dmp["cond_probs"][0]
    prob_mvs  = _prob_mvs[:, 0:_hnd_dat.shape[0] - win]  #  is bigger than hand by win size
    prob_mvs = prob_mvs.reshape((3, 3, prob_mvs.shape[1]))
    dbehv = _emp.get_dbehv(prob_mvs, gk)
    maxs = _N.where((dbehv[0:TO-11] >= 0) & (dbehv[1:TO-10] < 0))[0] + (win//2) #  3 from label71
    MLAG = 20
    tlag, AC = _eu.autocorrelate(dbehv, MLAG)
    # dAC = _N.diff(AC)
    # AC_pks = _N.where((dAC[0:-1] > 0) & (dAC[1:] <= 0))[0]
    # coherence[pid-1] = _N.std(_N.diff(AC_pks))
    decr = True
    for i in range(2, MLAG-1):
        if decr:
            if (AC[MLAG+i-1] >= AC[MLAG+i]) and (AC[MLAG+i] <= AC[MLAG+i+1]):
                decr = False
                iLow = i+MLAG
        else:
            if (AC[MLAG+i-1] <= AC[MLAG+i]) and (AC[MLAG+i] >= AC[MLAG+i+1]):
                iHigh = i+MLAG
                break
    coherence[pid-1] = AC[iHigh] - AC[iLow]
    ACmin = _N.min(AC[MLAG:])
Ejemplo n.º 4
0
    })

    for ns in range(nStates):
        rmpd_lab = _rmpd_lab  #shift_correlated_shuffle(_rmpd_lab, low=2, high=4, local_shuffle=True, local_shuffle_pcs=(4*sections)) if shf > 0 else _rmpd_lab
        stateInds = _N.where(rmpd_lab == ns)[0]

        stateBin[:] = 0
        stateBin[stateInds] = 1  #  neural signal

        k_stateBin = _N.convolve(stateBin, gk, mode="same")
        k_rps_ts = _N.convolve(rps_times, gk, mode="same")

        for hlf in range(sections):
            i0 = be_inds[hlf]
            i1 = be_inds[hlf + 1]
            ac1 = _eu.autocorrelate(
                k_stateBin[i0:i1] - _N.mean(k_stateBin[i0:i1]), lags)
            ac2 = _eu.autocorrelate(k_rps_ts[i0:i1] - _N.mean(k_rps_ts[i0:i1]),
                                    lags)
            ac1[1][lags] = 0
            ac2[1][lags] = 0
            std1 = _N.std(ac1[1][lags + 3:])
            std2 = _N.std(ac2[1][lags + 2:])
            fig.add_subplot(nStates, sections, sections * ns + hlf + 1)
            if ns == 0:
                _plt.title("section %d" % (hlf + 1))
            if hlf == 0:
                _plt.ylabel("pattern %d" % ns)

            #_plt.plot(time_lags[0:lags-1], (ac1[1][0:lags-1] - _N.mean(ac1[1]))*4 + 0.2, lags, color="black")
            _plt.plot(time_lags[lags + 3:],
                      (ac1[1][lags + 3:] - _N.mean(ac1[1])) * (0.4 / std1),