示例#1
0
def proto_0203(theABF):
    """protocol: vast IV."""
    abf = ABF(theABF)
    abf.log.info("analyzing as a fast IV")
    plot = ABFplot(abf)
    plot.title = ""
    m1, m2 = .7, 1
    plt.figure(figsize=(SQUARESIZE, SQUARESIZE / 2))

    plt.subplot(121)
    plot.figure_sweeps()
    plt.axvspan(m1, m2, color='r', ec=None, alpha=.1)

    plt.subplot(122)
    plt.grid(alpha=.5)
    Xs = np.arange(abf.sweeps) * 5 - 110
    Ys = []
    for sweep in range(abf.sweeps):
        abf.setsweep(sweep)
        Ys.append(abf.average(m1, m2))
    plt.plot(Xs, Ys, '.-', ms=10)
    plt.axvline(-70, color='r', ls='--', lw=2, alpha=.5)
    plt.axhline(0, color='r', ls='--', lw=2, alpha=.5)
    plt.margins(.1, .1)
    plt.xlabel("membrane potential (mV)")

    # save it
    plt.tight_layout()
    frameAndSave(abf, "fast IV")
    plt.close('all')
示例#2
0
def proto_gain(theABF, stepSize=25, startAt=-100):
    """protocol: gain function of some sort. step size and start at are pA."""
    abf = ABF(theABF)
    abf.log.info("analyzing as an IC ramp")
    plot = ABFplot(abf)
    plot.kwargs["lw"] = .5
    plot.title = ""
    currents = np.arange(abf.sweeps) * stepSize - startAt

    # AP detection
    ap = AP(abf)
    ap.detect_time1 = .1
    ap.detect_time2 = .7
    ap.detect()

    # stacked plot
    plt.figure(figsize=(SQUARESIZE, SQUARESIZE))

    ax1 = plt.subplot(221)
    plot.figure_sweeps()

    ax2 = plt.subplot(222)
    ax2.get_yaxis().set_visible(False)
    plot.figure_sweeps(offsetY=150)

    # add vertical marks to graphs:
    for ax in [ax1, ax2]:
        for limit in [ap.detect_time1, ap.detect_time2]:
            ax.axvline(limit, color='r', ls='--', alpha=.5, lw=2)

    # make stacked gain function
    ax4 = plt.subplot(223)
    plt.ylabel("frequency (Hz)")
    plt.ylabel("seconds")
    plt.grid(alpha=.5)
    freqs = ap.get_bySweep("freqs")
    times = ap.get_bySweep("times")
    for i in range(abf.sweeps):
        if len(freqs[i]):
            plt.plot(times[i][:-1],
                     freqs[i],
                     '-',
                     alpha=.5,
                     lw=2,
                     color=plot.getColor(i / abf.sweeps))

    # make gain function graph
    ax4 = plt.subplot(224)
    ax4.grid(alpha=.5)
    plt.plot(currents, ap.get_bySweep("median"), 'b.-', label="median")
    plt.plot(currents, ap.get_bySweep("firsts"), 'g.-', label="first")
    plt.xlabel("applied current (pA)")
    plt.legend(loc=2, fontsize=10)
    plt.axhline(40, color='r', alpha=.5, ls="--", lw=2)
    plt.margins(.02, .1)

    # save it
    plt.tight_layout()
    frameAndSave(abf, "AP Gain %d_%d" % (startAt, stepSize))
    plt.close('all')
示例#3
0
def proto_avgRange(theABF, m1=1.0, m2=1.1):
    """experiment: generic VC time course experiment."""
    abf = ABF(theABF)
    abf.log.info("analyzing as a fast IV")
    plot = ABFplot(abf)

    plt.figure(figsize=(SQUARESIZE * 2, SQUARESIZE / 2))

    plt.subplot(121)
    plot.title = "first sweep"
    plot.figure_sweep()
    plt.axvspan(m1, m2, color='r', ec=None, alpha=.1)

    plt.subplot(122)
    plt.grid(alpha=.5)
    Ts = np.arange(abf.sweeps) * abf.sweepInterval
    Ys = np.empty(abf.sweeps) * np.nan
    for sweep in range(abf.sweeps):
        Ys[sweep] = abf.average(m1, m2, setsweep=sweep)
    for i, t in enumerate(abf.comment_times):
        plt.axvline(t / 60, color='r', alpha=.5, lw=2, ls='--')
    plt.plot(Ts / 60, Ys, '.')
    plt.title(str(abf.comment_tags))
    plt.ylabel(abf.units2)
    plt.xlabel("minutes")

    plt.tight_layout()
    frameAndSave(abf, "sweep vs average", "experiment")
    plt.close('all')
示例#4
0
def proto_avgRange(theABF, m1=None, m2=None):
    """experiment: generic VC time course experiment."""

    abf = ABF(theABF)
    abf.log.info("analyzing as a fast IV")
    if m1 is None:
        m1 = abf.sweepLength
    if m2 is None:
        m2 = abf.sweepLength

    I1 = int(abf.pointsPerSec * m1)
    I2 = int(abf.pointsPerSec * m2)

    Ts = np.arange(abf.sweeps) * abf.sweepInterval
    Yav = np.empty(abf.sweeps) * np.nan  # average
    Ysd = np.empty(abf.sweeps) * np.nan  # standard deviation
    #Yar=np.empty(abf.sweeps)*np.nan # area

    for sweep in abf.setsweeps():
        Yav[sweep] = np.average(abf.sweepY[I1:I2])
        Ysd[sweep] = np.std(abf.sweepY[I1:I2])
        #Yar[sweep]=np.sum(abf.sweepY[I1:I2])/(I2*I1)-Yav[sweep]

    plot = ABFplot(abf)
    plt.figure(figsize=(SQUARESIZE * 2, SQUARESIZE / 2))

    plt.subplot(131)
    plot.title = "first sweep"
    plot.figure_sweep(0)
    plt.title("First Sweep\n(shaded measurement range)")
    plt.axvspan(m1, m2, color='r', ec=None, alpha=.1)

    plt.subplot(132)
    plt.grid(alpha=.5)
    for i, t in enumerate(abf.comment_times):
        plt.axvline(t / 60, color='r', alpha=.5, lw=2, ls='--')
    plt.plot(Ts / 60, Yav, '.', alpha=.75)
    plt.title("Range Average\nTAGS: %s" % (", ".join(abf.comment_tags)))
    plt.ylabel(abf.units2)
    plt.xlabel("minutes")
    plt.margins(0, .1)

    plt.subplot(133)
    plt.grid(alpha=.5)
    for i, t in enumerate(abf.comment_times):
        plt.axvline(t / 60, color='r', alpha=.5, lw=2, ls='--')
    plt.plot(Ts / 60, Ysd, '.', alpha=.5, color='g', ms=15, mew=0)
    #plt.fill_between(Ts/60,Ysd*0,Ysd,lw=0,alpha=.5,color='g')
    plt.title("Range Standard Deviation\nTAGS: %s" %
              (", ".join(abf.comment_tags)))
    plt.ylabel(abf.units2)
    plt.xlabel("minutes")
    plt.margins(0, .1)
    plt.axis([None, None, 0, np.percentile(Ysd, 99) * 1.25])

    plt.tight_layout()
    frameAndSave(abf, "sweep vs average", "experiment")
    plt.close('all')
示例#5
0
def proto_unknown(theABF):
    """protocol: unknown."""
    abf = ABF(theABF)
    abf.log.info("analyzing as an unknown protocol")
    plot = ABFplot(abf)
    plot.rainbow = False
    plot.title = None
    plot.figure_height, plot.figure_width = SQUARESIZE, SQUARESIZE
    plot.kwargs["lw"] = .5
    plot.figure_chronological()
    plt.gca().set_axis_bgcolor(
        '#AAAAAA')  # different background if unknown protocol
    frameAndSave(abf, "UNKNOWN")
示例#6
0
def proto_0202(theABF):
    """protocol: MTIV."""
    abf = ABF(theABF)
    abf.log.info("analyzing as MTIV")
    plot = ABFplot(abf)
    plot.figure_height, plot.figure_width = SQUARESIZE, SQUARESIZE
    plot.title = ""
    plot.kwargs["alpha"] = .6
    plot.figure_sweeps()

    # frame to uppwer/lower bounds, ignoring peaks from capacitive transients
    abf.setsweep(0)
    plt.axis([None, None, abf.average(.9, 1) - 100, None])
    abf.setsweep(-1)
    plt.axis([None, None, None, abf.average(.9, 1) + 100])

    # save it
    plt.tight_layout()
    frameAndSave(abf, "MTIV")
    plt.close('all')
示例#7
0
def proto_gain(theABF, stepSize=25, startAt=-100):
    """protocol: gain function of some sort. step size and start at are pA."""
    abf = ABF(theABF)
    abf.log.info("analyzing as an IC ramp")
    plot = ABFplot(abf)
    plot.kwargs["lw"] = .5
    plot.title = ""
    currents = np.arange(abf.sweeps) * stepSize - startAt

    # AP detection
    ap = AP(abf)
    ap.detect_time1 = .1
    ap.detect_time2 = .7
    ap.detect()

    # stacked plot
    plt.figure(figsize=(SQUARESIZE, SQUARESIZE))

    ax1 = plt.subplot(221)
    plot.figure_sweeps()

    ax2 = plt.subplot(222)
    ax2.get_yaxis().set_visible(False)
    plot.figure_sweeps(offsetY=150)

    # add vertical marks to graphs:
    for ax in [ax1, ax2]:
        for limit in [ap.detect_time1, ap.detect_time2]:
            ax.axvline(limit, color='r', ls='--', alpha=.5, lw=2)

    # make stacked gain function
    ax4 = plt.subplot(223)
    plt.ylabel("frequency (Hz)")
    plt.ylabel("seconds")
    plt.grid(alpha=.5)
    freqs = ap.get_bySweep("freqs")
    times = ap.get_bySweep("times")
    for i in range(abf.sweeps):
        if len(freqs[i]):
            plt.plot(times[i][:-1],
                     freqs[i],
                     '-',
                     alpha=.5,
                     lw=2,
                     color=plot.getColor(i / abf.sweeps))

    # make gain function graph
    ax4 = plt.subplot(224)
    ax4.grid(alpha=.5)
    plt.plot(currents, ap.get_bySweep("median"), 'b.-', label="median")
    plt.plot(currents, ap.get_bySweep("firsts"), 'g.-', label="first")
    plt.xlabel("applied current (pA)")
    plt.legend(loc=2, fontsize=10)
    plt.axhline(40, color='r', alpha=.5, ls="--", lw=2)
    plt.margins(.02, .1)

    # save it
    plt.tight_layout()
    frameAndSave(abf, "AP Gain %d_%d" % (startAt, stepSize))
    plt.close('all')

    # make a second figure that just shows every sweep up to the first AP
    plt.figure(figsize=(SQUARESIZE, SQUARESIZE))
    plt.grid(alpha=.5)
    plt.ylabel("Membrane Potential (mV)")
    plt.xlabel("Time (seconds)")
    for sweep in abf.setsweeps():
        plt.plot(abf.sweepX2, abf.sweepY, color='b', alpha=.5)
        if np.max(abf.sweepY > 0):
            break
    plt.tight_layout()
    plt.margins(0, .1)

    plt.axis([0, 1, None, None])
    plt.title("%d pA Steps from Rest" % stepSize)
    frameAndSave(abf, "voltage response fromRest", closeWhenDone=False)
    plt.axis([1.5, 2.5, None, None])
    plt.title("%d pA Steps from %d pA" % (stepSize, startAt))
    frameAndSave(abf, "voltage response hyperpol", closeWhenDone=False)
    plt.close('all')