예제 #1
0
def dyeConc(concs):
    from PYME.Analysis._fithelpers import FitModel

    figure()

    constants={'q':0, 'O2':0}
    I = Stimulus(I0, [], [])

    t = linspace(1, 1e6, 1000)

    tXs = []
    tRs = []

    s = System(r,constants=constants, ties={'S1':('I', 'S0')},stimulae={'I':I})#
    s.GenerateGradAndJacCode()

    for i in range(len(concs)):  
        s.initialConditions['S0'] = concs[i] #conc of fluorophores on an antibody ~ 100M

        res = s.solve(t)

        r1 = FitModel(emod, [1e-3, 3], res['X'][t>1e6], t[t>1e6]/1e6 - 1)
        tXs.append(r1[0][1])

        r1 = FitModel(emod, [1e-3, 3], res['R'][t>1e6], t[t>1e6]/1e6 - 1)
        tRs.append(r1[0][1])

    loglog(concs, tXs, label='X', lw=2)
    loglog(concs, tRs, label='R', lw=2)

    ylabel('Time constant [$s^{-1}$]')

    legend()
def plotConcDep(spec, concs):
    plt.figure()

    constants = {'I': I0, 'q': 1e-3, 'O2': 0.1 * air_sat_O2_conc}

    timestep = 50.  #3e-3
    blinkStartTime = 1  #when to start the blinking simulation
    #dm.GenTransitionMatrix(t=[1e6*blinkStartTime], timestep=timestep)

    NSteps = 100000
    t = np.arange(NSteps) * timestep / 1e6 + blinkStartTime

    for i in range(len(concs)):
        constants[spec] = concs[i]

        s = System(r, constants=constants, ties={'S1': ('I', 'S0')})  #
        s.GenerateGradAndJacCode()
        s.initialConditions[
            'S0'] = 1e-3  #conc of fluorophores on an antibody ~ 100M

        dm = DiscreteModel(s, ['S0', 'T1', 'R', 'X', 'P'])
        dm.GenTransitionMatrix(t=[1e6 * blinkStartTime], timestep=timestep)

        tr = dm.DoSteps(NSteps)

        plt.subplot(len(concs), 1, i + 1)
        plt.step(t[::1], tr[::1], lw=2)

        plt.yticks(range(5))
        ax = plt.gca()
        ax.set_yticklabels(dm.states)

        plt.ylabel('%3g [M/L]' % concs[i])

    plt.xlabel('Time [s]')
def viscLifetimes(viscs):
    from PYME.Analysis._fithelpers import FitModel

    plt.figure()

    constants = {'q': 1e-6, 'O2': 0.1 * air_sat_O2_conc}
    I = Stimulus(I0, [1e6], [0])

    tXs = []
    tRs = []

    for i in range(len(viscs)):
        visc = viscs[i]
        visc2 = visc

        if visc <= 10:
            t = np.linspace(1, 10e6, 10000)
        else:
            t = np.linspace(1, 10e6, 1000)

        r = genReactionScheme(visc, visc2)

        s = System(r,
                   constants=constants,
                   ties={'S1': ('I', 'S0')},
                   stimulae={'I': I})  #
        s.GenerateGradAndJacCode()
        s.initialConditions[
            'S0'] = 1e-3  #conc of fluorophores on an antibody ~ 100M

        res = s.solve(t)

        r1 = FitModel(emod, [1e-3, 3], res['X'][t > 1e6], t[t > 1e6] / 1e6 - 1)
        tXs.append(r1[0][1])

        r1 = FitModel(emod, [1e-3, 3], res['R'][t > 1e6], t[t > 1e6] / 1e6 - 1)
        tRs.append(r1[0][1])

    plt.loglog(viscs, tXs, label='X', lw=2)
    plt.loglog(viscs, tRs, label='R', lw=2)

    plt.ylabel('Time constant [$s^{-1}$]')

    plt.legend()
예제 #4
0
def stateLifetimes3(spec, concs, r, labelAddition = '',  constants={'q':10e-3, 'O2':0.1*air_sat_O2_conc}, **kwargs):
    lineSpec = {'lw':2}
    lineSpec.update(kwargs)

    #figure()

    #constants={'q':10e-3, 'O2':0.1*air_sat_O2_conc}
    I = Stimulus(I0, [9e4], [0])

    t = linspace(1, 1e5, 10000)

    tXs = []
    tRs = []

    nConc = constants[spec]

    rates = []

    initConc = 1e-3

    s = System(r,constants={}, ties={'S1':('I', 'S0')},stimulae={'I':I})#
    s.GenerateGradAndJacCode()
    s.initialConditions['S0'] = 1e-3 #conc of fluorophores on an antibody ~ 100M
    #s.initialConditions['X'] = initConc
    #s.initialConditions['R'] = initConc

    s.initialConditions['q'] = constants['q']
    s.initialConditions['O2'] = constants['O2']

    for i in range(len(concs)):
        s.initialConditions[spec] = concs[i]
        res, r = s.solve(t, True)
        #print res[-1].dtype
        #print res[-1].view('9f8')
        rates.append(r[-1])

    rates = hstack(rates)
    
    #plot(concs, 1e-6/(-rates['X']/initConc))

    loglog(concs, 1e-6/(-rates['X']/initConc), c = 'b', label='X' + labelAddition, **lineSpec)
    loglog(concs, 1e-6/(-rates['R']/initConc), c = 'g', label='R' + labelAddition, **lineSpec)

    plot([nConc, nConc], ylim(), 'k--')

    ylabel('Dark state lifetime [s]')
    xlabel('[%s]' % spec)

    legend()
def stateLifetimes(spec, concs):
    from PYME.Analysis._fithelpers import *

    plt.figure()

    constants = {'q': 10e-3, 'O2': 0.05 * air_sat_O2_conc}
    I = Stimulus(0, [], [])

    t = np.linspace(1, 10e6, 1000)

    tXs = []
    tRs = []

    nConc = constants[spec]

    for i in range(len(concs)):
        constants[spec] = concs[i]

        s = System(r,
                   constants=constants,
                   ties={'S1': ('0', 'S0')},
                   stimulae={'I': I})  #
        s.GenerateGradAndJacCode()
        #s.initialConditions['S0'] = 1e-3 #conc of fluorophores on an antibody ~ 100M
        s.initialConditions['X'] = 1e-3
        s.initialConditions['R'] = 1e-3

        res = s.solve(t)

        r1 = FitModel(emod, [1e-3, 3], res['X'], t / 1e6)
        tXs.append(r1[0][1])

        r1 = FitModel(emod, [1e-3, 3], res['R'], t / 1e6)
        tRs.append(r1[0][1])

        print(max(tXs[-1], tRs[-1]))
        #t = linspace(1, 5e6*max(max(tXs[-1], tRs[-1]), 1e-3), 1000)

    plt.loglog(concs, tXs, label='X', lw=2)
    plt.loglog(concs, tRs, label='R', lw=2)

    plt.plot([nConc, nConc], plt.ylim(), 'k--')

    plt.ylabel('Time constant [s]')
    plt.xlabel('[%s]' % spec)

    plt.legend()
예제 #6
0
def dyeConc2(concs):
    constants={'q':5e-3, 'O2':0.1*air_sat_O2_conc}
    #constants = {}
    #constants={'q':0, 'O2':0}
    s = System(r,constants=constants, ties={'S1':('I', 'S0')},stimulae={'I':I})#
    s.GenerateGradAndJacCode()

    rates = []
    for c in concs:
        s.initialConditions['S0'] = c

        res = s.solve([1e3])

        rates.append(s.GradFcn(0, res.view('f8')).view(s.dtype))

    rates = hstack(rates)

    figure()
    #plot(concs, rates['S0']/concs)
    plot(concs, rates['T1']/concs)
def stateLifetimes2(spec,
                    concs,
                    r,
                    labelAddition='',
                    constants={
                        'q': 10e-3,
                        'O2': 0.1 * air_sat_O2_conc
                    },
                    **kwargs):
    lineSpec = {'lw': 2}
    lineSpec.update(kwargs)

    #figure()

    #constants={'q':10e-3, 'O2':0.1*air_sat_O2_conc}
    I = Stimulus(0, [], [])

    t = np.linspace(1, 10e6, 1000)

    tXs = []
    tRs = []

    nConc = constants[spec]

    rates = []

    initConc = 1e-3

    s = System(r, constants={}, ties={'S1': ('0', 'S0')}, stimulae={'I': I})  #
    s.GenerateGradAndJacCode()
    #s.initialConditions['S0'] = 1e-3 #conc of fluorophores on an antibody ~ 100M
    s.initialConditions['X'] = initConc
    s.initialConditions['R'] = initConc

    s.initialConditions['q'] = constants['q']
    s.initialConditions['O2'] = constants['O2']

    for i in range(len(concs)):
        s.initialConditions[spec] = concs[i]
        rates.append(
            s.GradFcn(0, s.initialConditions.view('f8')).view(s.dtype))

    rates = np.hstack(rates)

    plt.loglog(concs,
               1e-6 / (-rates['X'] / initConc),
               c='b',
               label='X' + labelAddition,
               **lineSpec)
    plt.loglog(concs,
               1e-6 / (-rates['R'] / initConc),
               c='g',
               label='R' + labelAddition,
               **lineSpec)

    plt.plot([nConc, nConc], plt.ylim(), 'k--')

    plt.ylabel('Dark state lifetime [s]')
    plt.xlabel('[%s]' % spec)

    plt.legend()
r = genReactionScheme(visc, visc2)

#Intensity as a fraction of saturation intensity
I0 = 1e-1

#intensity function
#I = Stimulus(1e-3*I0, 1e6*np.array([1, 3,  4, 5,  6, 8,  9, 15, 16, 25, 26, 50, 51, 100]),
#                                   [0, I0, 0, I0, 0, I0, 0, I0, 0,  I0, 0,  I0, 0,  I0])
I = Stimulus(I0, [], [])

#s = System(r,constants={'I':I0, 'q':1e-6, 'O2':0.1*air_sat_O2_conc}, ties={'S1':('I', 'S0')})#
constants = {'q': 5e-7, 'O2': (0.5e-5) * air_sat_O2_conc}
#constants = {}
#constants={'q':10e-3}
s = System(r, constants=constants, ties={'S1': ('I', 'S0')}, stimulae={'I':
                                                                       I})  #
s.GenerateGradAndJacCode()
s.initialConditions['S0'] = 1e-6  #conc of fluorophores on an antibody ~ 100M
#s.initialConditions['q'] = .25e-3
#s.initialConditions['O2'] = .1*air_sat_O2_conc

exPower = I0 * k_emmision / excitations_per_W_per_cm2_per_us
print(u'Excitation Power: %3.2g W/cm\xB2' % (exPower))
print(u'                  = %3.2g mW over a 15 \u03BCm field' %
      (exPower * (0.0015**2) * 1e3))


def dyedyemodt(p, t):
    '''Model for bleach decay when the rate is dominated by dye-dye interactions.
    The equation (~ 1/t) is a solution to a differential equation of the form:
        dN/dt = -k*N^2
r = genReactionScheme(visc, visc2)

#Intensity as a fraction of saturation intensity
I0 = 1e-4

#intensity function
#I = Stimulus(1e-3*I0, 1e6*np.array([1, 3,  4, 5,  6, 8,  9, 15, 16, 25, 26, 50, 51, 100]),
#                                   [0, I0, 0, I0, 0, I0, 0, I0, 0,  I0, 0,  I0, 0,  I0])
I = Stimulus(I0, [], [])

#s = System(r,constants={'I':I0, 'q':1e-6, 'O2':0.1*air_sat_O2_conc}, ties={'S1':('I', 'S0')})#
#constants={'q':10e-3, 'O2':0.1*air_sat_O2_conc}
constants = {}
#constants={'q':10e-3}
s = System(r, constants=constants, ties={'S1': ('I', 'S0')}, stimulae={'I':
                                                                       I})  #
s.GenerateGradAndJacCode()
s.initialConditions['S0'] = 1e-2  #conc of fluorophores on an antibody ~ 100M
s.initialConditions['q'] = 10e-3
s.initialConditions['O2'] = 0.1 * air_sat_O2_conc

exPower = I0 * k_emmision / excitations_per_W_per_cm2_per_us
print(u'Excitation Power: %3.2g W/cm\xB2' % (exPower))
print(u'                  = %3.2g mW over a 15 \u03BCm field' %
      (exPower * (0.0015**2) * 1e3))


def dyedyemodt(p, t):
    '''Model for bleach decay when the rate is dominated by dye-dye interactions.
    The equation (~ 1/t) is a solution to a differential equation of the form:
        dN/dt = -k*N^2