def proto_0101(theABF): abf = ABF(theABF) abf.log.info("analyzing as an IC tau") #plot=ABFplot(abf) plt.figure(figsize=(SQUARESIZE / 2, SQUARESIZE / 2)) plt.grid() plt.ylabel("relative potential (mV)") plt.xlabel("time (sec)") m1, m2 = [.05, .1] for sweep in range(abf.sweeps): abf.setsweep(sweep) plt.plot(abf.sweepX2, abf.sweepY - abf.average(m1, m2), alpha=.2, color='#AAAAFF') average = abf.averageSweep() average -= np.average( average[int(m1**abf.pointsPerSec):int(m2 * abf.pointsPerSec)]) plt.plot(abf.sweepX2, average, color='b', lw=2, alpha=.5) plt.axvspan(m1, m2, color='r', ec=None, alpha=.1) plt.axhline(0, color='r', ls="--", alpha=.5, lw=2) plt.margins(0, .1) # save it plt.tight_layout() frameAndSave(abf, "IC tau") plt.close('all')
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')
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')
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')
def proto_0304(theABF): """protocol: repeated IC steps.""" abf = ABF(theABF) abf.log.info("analyzing as repeated current-clamp step") # prepare for AP analysis ap = AP(abf) # calculate rest potential avgVoltagePerSweep = [] times = [] for sweep in abf.setsweeps(): avgVoltagePerSweep.append(abf.average(0, 3)) times.append(abf.sweepStart / 60) # detect only step APs M1, M2 = 3.15, 4.15 ap.detect_time1, ap.detect_time2 = M1, M2 ap.detect() apsPerSweepCos = [len(x) for x in ap.get_bySweep()] # detect all APs M1, M2 = 0, 10 ap.detect_time1, ap.detect_time2 = M1, M2 ap.detect() apsPerSweepRamp = [len(x) for x in ap.get_bySweep()] # make the plot of APs and stuff plt.figure(figsize=(8, 8)) plt.subplot(311) plt.grid(ls='--', alpha=.5) plt.plot(times, avgVoltagePerSweep, '.-') plt.ylabel("Rest Potential (mV)") comment_lines(abf) plt.subplot(312) plt.grid(ls='--', alpha=.5) plt.plot(times, apsPerSweepCos, '.-') plt.ylabel("APs in Step (#)") comment_lines(abf) plt.subplot(313) plt.grid(ls='--', alpha=.5) plt.plot(times, apsPerSweepRamp, '.-') plt.ylabel("APs in Sweep (#)") comment_lines(abf) plt.tight_layout() frameAndSave(abf, "cos ramp") plt.close('all')
def proto_0314(theABF): abf = ABF(theABF) abf.log.info("analyzing a cosine + ramp protocol") if len(abf.comment_sweeps > 0): # comments exist, so graph the average sweep before/after the first comment sweepsToAverage = 10 baselineSweep1 = max(0, abf.comment_sweeps[0] - sweepsToAverage) baselineSweep2 = abf.comment_sweeps[0] drugSweep1 = abf.comment_sweeps[0] + 1 drugSweep2 = min(abf.sweeps - 1, abf.comment_sweeps[0] + 1 + sweepsToAverage) plt.figure(figsize=(16, 4)) plt.grid(ls='--', alpha=.5) plt.plot(abf.sweepX2, abf.averageSweep(baselineSweep1, baselineSweep2), label="baseline (%d-%d)" % (baselineSweep1, baselineSweep2), alpha=.8) plt.plot(abf.sweepX2, abf.averageSweep(drugSweep1, drugSweep2), label="drug (%d-%d)" % (drugSweep1, drugSweep2), alpha=.8) plt.margins(0, .05) plt.legend() plt.tight_layout() frameAndSave(abf, "cos ramp avg", closeWhenDone=False) plt.axis([2.25, 4.5, None, None]) frameAndSave(abf, "cos ramp avgSine", closeWhenDone=False) plt.axis([9, 12.5, None, None]) frameAndSave(abf, "cos ramp avgRamp") # prepare for AP analysis ap = AP(abf) # calculate rest potential avgVoltagePerSweep = [] times = [] for sweep in abf.setsweeps(): avgVoltagePerSweep.append(abf.average(0, 2.25)) times.append(abf.sweepStart / 60) # detect only cos APs M1, M2 = 2.25, 4.5 ap.detect_time1, ap.detect_time2 = M1, M2 ap.detect() apsPerSweepCos = [len(x) for x in ap.get_bySweep()] # detect only ramp APs M1, M2 = 9, 12.5 ap.detect_time1, ap.detect_time2 = M1, M2 ap.detect() apsPerSweepRamp = [len(x) for x in ap.get_bySweep()] # make the plot of APs and stuff plt.figure(figsize=(8, 8)) plt.subplot(311) plt.grid(ls='--', alpha=.5) plt.plot(times, avgVoltagePerSweep, '.-') plt.ylabel("Rest Potential (mV)") comment_lines(abf) plt.subplot(312) plt.grid(ls='--', alpha=.5) plt.plot(times, apsPerSweepCos, '.-') plt.ylabel("APs in Cos (#)") comment_lines(abf) plt.subplot(313) plt.grid(ls='--', alpha=.5) plt.plot(times, apsPerSweepRamp, '.-') plt.ylabel("APs in Ramp (#)") comment_lines(abf) plt.tight_layout() frameAndSave(abf, "cos ramp") plt.close('all')