Beispiel #1
0
import methods
import methods.outward as outward
import numpy as np
import matplotlib
import matplotlib.pyplot as pl

#
# Fit all outward current experiments (or used cached result)
#
force = '--force' in sys.argv
table, cells = outward.fit_all(force=force)

#
# Run simulations with each cell (or use cached data)
#
aps = outward.simulate_tailored_aps(table, cells, force=force)

#
# Plot 2APs
#
#
# Order cells by APD at -65mV
#
tmin = 50 * 1e-3
vapd = -65 * 1e-3
order = np.array([aps['membrane.V', i] for i in xrange(len(outward.ORDER))])
offset = np.where(aps.time() >= tmin)[0][0]
order = order[:, offset:]
order = [np.where(v < vapd)[0][:1] for v in order]
order = [v[0] if v else 2000 for v in order]
order = np.argsort(np.argsort(order))
    #
    # Run simulations with tailored models
    #
    if TAILORED:
        apds = []
        stars = []
        nmodels = []
        for concentration in detailed:
            print('Running for drug: ' + drug + ' ' + str(concentration) +
                  ' [uM]')

            # Run simulations
            sim = outward.simulate_tailored_aps(table,
                                                cells,
                                                drug=drug,
                                                concentration=concentration,
                                                cl=cl,
                                                force=force)

            # Normalise and get apds
            group = []
            t = sim.time() * 1e3
            for i, long_id in enumerate(outward.ORDER):
                filename = None
                if concentration > 0 and drug != 'paracetamol':
                    filename = os.path.join(
                        apd.AP_FIGURES, 'sim-' + long_id + '-' + drug + '-' +
                        str(concentration) + '.png')
                ap = apd.normalise(t, sim['membrane.V', i], filename=filename)
                if concentration > 0 and drug != 'paracetamol':
                    filename = os.path.join(
Beispiel #3
0
import matplotlib
#matplotlib.use('Agg')
import matplotlib.pyplot as pl

# Don't cache
force = "--force" in sys.argv

#
# Fit all outward current experiments (or used cached result)
#
table, cells = outward.fit_all()

#
# Run simulations with each cell (or use cached data)
#
sim = outward.simulate_tailored_aps(table, cells, force=force, beats=100, cl=1,
 stimulate=False)

# Normalise and calculate apd
n = len(outward.ORDER)
sim_time = sim.time() * 1e3 - 50
sim_aps = []
sim_apds = []
for i, long_id in enumerate(outward.ORDER):
    filename = os.path.join(apd.AP_FIGURES, 'sim-base-' + long_id + '.png')
    #sim_aps.append(apd.normalise(sim_time, sim['membrane.V', i],
    #    filename=filename))
    sim_aps.append(sim['membrane.V', i])
    filename = os.path.join(apd.APD_FIGURES, 'sim-base-' + long_id + '.png')
    #sim_apds.append(apd.calculate_apd(sim_time, sim_aps[-1],
    #    filename=filename)[0])
sim_aps = np.array(sim_aps)
import methods
import methods.outward as outward
import numpy as np
import matplotlib
import matplotlib.pyplot as pl

#
# Fit all outward current experiments (or used cached result)
#
force = '--force' in sys.argv
table, cells = outward.fit_all(force=force)

#
# Run simulations with each cell (or use cached data)
#
aps = outward.simulate_tailored_aps(table, cells, store_currents=True,
    force=force)

#
# Plot 2APs
#
#
# Order cells by APD at -65mV
#
tmin = 50 * 1e-3
vapd = -65 * 1e-3
order = np.array([aps['membrane.V', i] for i in xrange(len(outward.ORDER))])
offset = np.where(aps.time() >= tmin)[0][0]
order = order[:, offset:]
order = [np.where(v < vapd)[0][:1] for v in order]
order = [v[0] if v else 2000 for v in order]
order = np.argsort(np.argsort(order))