Example #1
0
def error_func(dbspl, model, cf, model_pars, spont_si):

    if model_pars is None:
        model_pars = {}

    pars = dict(model_pars)

    fs = pars.setdefault('fs', 100e3)

    tone_duration = 250e-3
    onset = 15e-3

    s = wv.make_ramped_tone(fs,
                            cf,
                            duration=tone_duration,
                            ramp=2.5e-3,
                            pad=0,
                            dbspl=dbspl)

    anf = model(sound=s, anf_num=(1000, 0, 0), cf=cf, seed=0, **pars)

    trains = th.trim(anf, onset, None)
    si = th.calc_si(trains, cf)

    error = si - spont_si

    logging.debug("{} {} {}".format(dbspl, si, error))

    return error
Example #2
0
def calc_spont_threshold(model, model_pars=None):

    if model_pars is None:
        model_pars = {}

    pars = dict(model_pars)

    fs = pars.setdefault('fs', 100e3)
    cf = pars.setdefault('cf', 1e3)

    tmax = 250e-3
    s = np.zeros(fs*tmax)

    anf = model(
        sound=s,
        anf_num=(10000,0,0),
        seed=0,
        **pars
    )

    sis = [th.calc_si(train,cf) for _,train in anf.iterrows()]
    sis = np.array(sis)

    threshold = sis.mean() + sis.std()

    return threshold
Example #3
0
def calc_spont_threshold(model, model_pars=None):

    if model_pars is None:
        model_pars = {}

    pars = dict(model_pars)

    fs = pars.setdefault('fs', 100e3)
    cf = pars.setdefault('cf', 1e3)

    tmax = 250e-3
    s = np.zeros(fs * tmax)

    anf = model(sound=s, anf_num=(10000, 0, 0), seed=0, **pars)

    sis = [th.calc_si(train, cf) for _, train in anf.iterrows()]
    sis = np.array(sis)

    threshold = sis.mean() + sis.std()

    return threshold
Example #4
0
def error_func(dbspl, model, cf, model_pars, spont_si):

    if model_pars is None:
        model_pars = {}

    pars = dict(model_pars)

    fs = pars.setdefault('fs', 100e3)

    tone_duration = 250e-3
    onset = 15e-3

    s = wv.make_ramped_tone(
        fs,
        cf,
        duration=tone_duration,
        ramp=2.5e-3,
        pad=0,
        dbspl=dbspl
    )

    anf = model(
        sound=s,
        anf_num=(1000, 0, 0),
        cf=cf,
        seed=0,
        **pars
    )

    trains = th.trim(anf, onset, None)
    si = th.calc_si(trains, cf)

    error = si - spont_si

    logging.debug("{} {} {}".format(dbspl, si, error))

    return error