def METHOD_NAME(I, mdh, dt=1):
    #from pylab import *
    import matplotlib.pyplot as plt
    t = np.arange(len(I))*dt
    dfb, dfe = mdh['Protocol.DarkFrameRange']
    dk_emgain = I[dfb:dfe].mean()
    pbb, pbe = mdh['Protocol.PrebleachFrames']
    bb, be = mdh['Protocol.BleachFrames']
    #this is asuming that we get a couple of dark frames between the prebleach 
    #exposure and the high intensity switch on.
    dk_noem = min(I[pbe:be])
    #find real start of bleach curve by looking for the maximum of the bleach signal
    bb += np.argmax(I[bb:be])
    bb += 1
    init_bleach = mdh['Camera.TrueEMGain']*(I[bb:be] - dk_noem)
    t_init = t[bb:be]
    ds = mdh['Protocol.DataStartsAt']
    full_bleach = I[ds:] - dk_emgain
    t_full = t[ds:] + .3
    r0 = FitModel(linMod, [-1, -1, full_bleach[0],full_bleach[3] - init_bleach[-1]], np.hstack((init_bleach[-40:], full_bleach[5:40])),
                  np.hstack((t_init[-40:], t_full[5:40])) - t_init[-1])
    print((r0[0]))
    plt.figure()
    t_ = np.hstack((t_init[-40:], t_full[5:40])) - t_init[-1]
    plt.plot(t_, np.hstack((init_bleach[-40:], full_bleach[5:40])))
    plt.plot(t_, linMod(r0[0], t_))
    init_bleach = init_bleach - r0[0][3]#full_bleach[5] - init_bleach[-1]
    #figure()
    #plot(t, I)
    t2 = np.hstack([t_init, t_full])
    I2 = np.hstack([init_bleach, full_bleach])
    t3 = t2 - t2[0]
    #ds3 = t[ds] - t2[0]
    r = FitModelWeighted(dyedyemod, [I2[0], 1., I2[-1]], I2, np.sqrt(I2)/4, t3)
    print((r[0]))
    #r2 = FitModel(dyedyemod2, [I2[0], 1., I2[-1], 0.], I2, t3, ds3)
    #print r2[0]
    r3 = FitModel(dyedyemod, [init_bleach[0], .01, full_bleach[-1]], init_bleach, t_init - t_init[0])
    print((r3[0]))
    print([init_bleach[0], .01, full_bleach[-1]])
    r4 = FitModel(dyedyemod, [init_bleach[0], .1, full_bleach[-1]], full_bleach, t_full - t_init[0])
    print((r4[0]))
    #r5 = FitModel(dyedyemoda, [sqrt(init_bleach[0]), .01, full_bleach[-1]], full_bleach, t_full - t_init[0])
    #print r5[0]
    A0 = init_bleach[0] 
    print(A0)
    r6 = FitModelWeighted(dyedyemodt, [A0, dt, full_bleach[-1], 1.], I2, np.sqrt(I2)/4, t3)
    print((r6[0]))
    plt.figure()
    plt.plot(t_init, init_bleach)
    plt.plot(t_full, full_bleach)
    plt.plot(t2, dyedyemod(r[0], t3))
    #plot(t2, dyedyemod2(r2[0], t3, ds3))
    #plot(t2, dyedyemod(r3[0], t3))
    plt.plot(t2, dyedyemod(r4[0], t3) )
    plt.xlabel('Time [s]')
    plt.ylabel('Intensity')
    #plot(t_init, init_bleach + full_bleach[0] - init_bleach[-1])
    plt.figure()
    plt.loglog(t3 + dt, I2)
    plt.loglog(t3 + dt, dyedyemod(r[0], t3))
    #loglog(t3, dyedyemod2(r2[0], t3, ds3))
    #loglog(t3, dyedyemod(r3[0], t3))
    #loglog(t3 + dt, dyedyemod(r4[0], t3))
    #loglog(t3, dyedyemoda(r5[0], t3))
    plt.loglog(t3+ dt, dyedyemodt(r6[0], t3))
    #loglog(t3+ dt, dyedyemodt([dt,I2[-1]], t3, A0))
    plt.figtext(.3,.8, 'A0 = %3.0f, k = %3.4f, b = %3.1f' % tuple(r[0]), size=18, color='g')
    #figtext(.3,.75, 'A0 = %3.0f, k = %3.4f, b = %3.1f' % tuple(r4[0]), size=18, color='r')
    plt.figtext(.3,.75, 'A0 = %3.0f, k = %3.3f, b = %3.1f, exp = %3.3f' % tuple(r6[0]), size=18, color='r')
    #i2s = 
    #plot(t2[:-1], diff(convolve(I2, ones(20), 'same')))
    #return t2, I2