Example #1
0
 def analyze_reactive(self, DVg, DVs, p):
     """ get rt and accuracy of go and stop process for simulated
     conditions generated from simulate_dpm
     """
     ssd, nssd, nss, nss_per, ssd_ix = self.ssd_info
     nl, ntot = self.nlevels, self.ntot
     gdec = self.go_resp(DVg, p['a'])
     sdec = self.ss_resp(DVs, p['a'])
     gort = self.go_RT(p['tr'], gdec)
     ssrt = self.ss_RT(ssd, sdec)
     gort[np.isnan(gort)] = 1000.
     ssrt[np.isnan(ssrt)] = 1000.
     ert = gort[:, :nss].reshape(nl, nssd, nss_per)
     gacc = np.mean(ufunc_where(gort < self.tb, 1, 0), axis=1)
     sacc = np.mean(ufunc_where(ert <= ssrt, 0, 1), axis=2)
     eq = self.RTQ(zip(ert, ssrt))
     gq = self.RTQ(zip(gort, [self.tb] * nl))
     return hs([hs([i[ii] for i in [gacc, sacc, gq, eq]]) for ii in range(nl)])
Example #2
0
 def analyze_reactive(self, DVg, DVs, p):
     """ get rt and accuracy of go and stop process for simulated
     conditions generated from simulate_dpm
     """
     ssd, nssd, nss, nss_per, ssd_ix = self.ssd_info
     nl, ntot = self.nlevels, self.ntot
     gdec = self.go_resp(DVg, p['a'])
     # if dpm, simply ss_resp() uses 0
     # as boundary simply ignores sec. arg
     sdec = self.ss_resp(DVs, p['a'])
     gort = self.go_RT(p['tr'], gdec)
     ssrt = self.ss_RT(ssd, sdec)
     ert = gort[:, :nss].reshape(nl, nssd, nss_per)
     eq = self.RTQ(zip(ert, ssrt))
     gq = self.RTQ(zip(gort, [self.tb] * nl))
     gacc = np.nanmean(np.where(gort < self.tb, 1, 0), axis=1)
     sacc = np.where(ert < ssrt, 0, 1).mean(axis=2)
     return hs([hs([i[ii] for i in [gacc, sacc, gq, eq]]) for ii in range(nl)])
Example #3
0
File: lca.py Project: dunovank/bsac
def decision_network(Id=3.5, Ii=3.5, Io=3., wdi=.22, wid=.22, k=.85, si=2.3, dt=.001, tau=.05, tmax=1.5, rmax=70, b=35, g=15, ntrials=10, y=1, Z=20, IoMax=4.5):

    timepoints = np.arange(0, tmax, dt)
    ntp = len(timepoints)

    rd = np.zeros(ntp)
    ri = np.zeros(ntp)
    dv = np.zeros(ntp)

    NInput = lambda x, r: rmax / (1 + np.exp(-(x - b) / g)) - r
    dspace = lambda rd, ri: (rd - ri) / np.sqrt(2)

    Ed = si * np.sqrt(dt / tau) * rs(ntp)
    Ei = si * np.sqrt(dt / tau) * rs(ntp)
    x = 200
    rd[:x], ri[:x] = [v[0][:x] + Io + v[1][:x] for v in [[rd, Ed], [ri, Ei]]]

    subZ = True
    IIi, IId = [deepcopy(ii) for ii in [Id, Ii]]
    for i in xrange(x, ntp):

        rd[i] = rd[i - 1] + dt / tau * \
            (NInput(Id + y * Io + k * rd[i - 1] + -
                    wid * ri[i - 1], rd[i - 1])) + Ed[i]
        ri[i] = ri[i - 1] + dt / tau * \
            (NInput(Ii + y * Io + k * ri[i - 1] + -
                    wdi * rd[i - 1], ri[i - 1])) + Ei[i]

        if dv[i - 1] < Z and subZ:
            dv[i] = dspace(rd[i - 1], ri[i - 1])
        elif subZ:
            Id, Ii, Io = -Id * Io, -Ii * Io, Io
            wdi, wid = 0, 0
            NInput = lambda x, r: Io / (1 + np.exp(-(x - b) / g)) - r - IoMax
            subZ = False
        elif not subZ and rd[i] < (IoMax + 1):
            x = len(rd[i:])
            rd0 = hs(rd[:200].tolist() * 3)
            ri0 = hs(ri[:200].tolist() * 3)
            rd, ri = hs([rd[:i], rd0]), hs([ri[:i], ri0])
            break

    return rd, ri, dv[:dv[dv < Z].argmax()]
Example #4
0
 def analyze_proactive(self, DVg, p):
     """ get proactive rt and accuracy of go process for simulated
     conditions generated from simulate_pro
     """
     nl, ntot = self.nlevels, self.ntot
     gdec = self.go_resp(DVg, p['a'])
     gort = self.go_RT(p['tr'], gdec)
     gq = self.RTQ(zip(gort, [self.tb] * nl))
     # Get response and stop accuracy information
     gacc = 1 - np.mean(np.where(gort < self.tb, 1, 0), axis=1)
     return hs([gacc, gq])
Example #5
0
File: lca.py Project: dunovank/bsac
def dual_space_plot(ax1, ax2, rd, ri, dv, rts=None, Z=20, alpha=1, isfirst=True, xlabel=False, i=0, xlim=None):

    colors = tools.colors.style_params()['colors']
    rt = len(dv)

    if isfirst:
        labels = ['Direct', 'Indirect']
        ax1.set_xlabel('Time (ms)')
    else:
        labels = [None, None]
    ax1.plot(rd, label=labels[0], color=colors[3], alpha=alpha)
    ax1.plot(ri, label=labels[1], color=colors[6], alpha=alpha)
    ax1.vlines(rt, ymin=ri[rt], ymax=rd[rt],
               color=colors[-2], linestyles='--', alpha=alpha)

    # Decision Space
    ax2.plot(dv, color=colors[-2], alpha=alpha)

    if xlabel:
        ax1.set_xlabel('Time (ms)')

    ax1.set_ylabel('Firing Rate (Hz)')
    ax2.set_ylabel('Decision Evidence ($\Theta$)')

    ax1.set_yticks([0, int(hs([rd, ri]).max()) + 5])
    for ax in [ax1, ax2]:
        ax.set_yticklabels([])
        ax.set_xticks(xlim)
        ax.set_xticklabels(xlim)

    ax2.set_ylim(-1, Z)
    ax1.legend(loc=2)
    ax2.hlines(Z, 0, ax2.get_xlim()[1], linestyle='--')
    f = plt.gcf()
    f.subplots_adjust(hspace=0.1)
    sns.despine(ax=ax1)
    sns.despine(top=True, ax=ax2)
    if xlim is not None:
        ax1.set_xlim(xlim[0], xlim[1])
        ax2.set_xlim(xlim[0], xlim[1])