예제 #1
0
def test_bond_protocols(plot=False):
    """Run all Bondarenko protocols."""

    from cgp.virtexp.elphys.examples import Bond

    b = Bond(chunksize=10000)

    def plotprot(i, varnames, limits, L):
        """Plot one protocol."""
        from pylab import figure, subplot, plot, savefig, legend, axis

        figure()
        proto0, _ = L[0]
        isclamped = len(proto0[0]) == 2
        for j, (n, lim) in enumerate(zip(varnames, limits)):
            subplot(len(varnames), 1, j + 1)
            leg = set()
            for k in n.split():
                if isclamped:  # clamp protocol
                    # For each protocol, traj is a list with a Trajectory
                    # for each pulse.
                    for _proto, traj in L:
                        t, y, _dy, a = catrec(*traj[1:])
                        plot(t, y[k] if k in y.dtype.names else a[k], label=k if (k not in leg) else None)
                        leg.add(k)
                else:  # pacing protocol
                    # For each protocol, paces is a list of Pace
                    for _proto, paces in L:
                        t, y, _dy, a, _stats = catrec(*paces)
                        plot(t, y[k] if k in y.dtype.names else a[k], label=k if (k not in leg) else None)
                        leg.add(k)
                legend()
            if lim:
                axis(lim)
        savefig("fig%s%s.png" % (i, b.name))

    bp = b.bond_protocols()
    for i, (varnames, protocol, limits, _url) in bp.items():
        if len(protocol[0]) == 2:  # (duration, voltage), so clamping
            # List of (proto, traj), where traj is list of Trajectory
            L = b.vecvclamp(protocol)
        else:  # (n, period, duration, amplitude), so pacing
            # List of (proto, paces), where paces is list of Pace
            L = b.vecpace(protocol)
        if plot:
            plotprot(i, varnames, limits, L)
예제 #2
0
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.pyplot import (plot, ylabel, title, 
    tick_params, xlim, axis, box, setp, getp)
import os
from joblib import Memory
from cgp.virtexp.elphys.examples import Bond
from cgp.virtexp.elphys.clampable import catrec, markovplot, listify
from cgp.virtexp.elphys.clampable import Bond_protocol
from cgp.utils.splom import spij

### Options, model and protocols

cell = Bond()
protocols = cell.bond_protocols()
# Pacing parameters
nprepace = 10
npace = 4
# P1-P2 double-pulse protocol to study voltage-dependence of ion channel
varnames, protocol, limits, url = listify(protocols[3])
protocol[1][1] = protocol[1][1][::3]
p1p2 = Bond_protocol(varnames, protocol, limits, url)
# Variable-gap protocol to study the rate of recovery from inactivation
varnames, protocol, limits, url = listify(protocols[7])
protocol[2][0] = protocol[2][0][6::3]  # don't need so many gap lengths
protocol[2][1] = protocol[2][1][1]  # don't vary gap voltage
protocol[3][0] = 300  # make shortest run last until the longest gap is done
vargap = Bond_protocol(varnames, protocol, limits, url)

# Lineplot options