carfac icon indicating copy to clipboard operation
carfac copied to clipboard

Output scaling question

Open davidmarttila opened this issue 4 months ago • 1 comments

Hello, thank you for providing this model open source!

I have a question about the output range of the NAP / IHC values. I was expecting the output values to be in the [0, 1] range as mentioned in section 18.3 of Human and Machine Hearing. I understand the values to represent the "probability of firing" for a neuron.

Testing out the numpy and JAX implementations with the default design parameters and some sample input (noise and sines at varying volumes), I am getting different results though. The output seems to have a floor at a specific value of -0.81157 (consistent across different types of input), and have peaks anywhere between 2 and 10 depending on the input signal.

Here is some example code:

sr = 22050
f0 = 300
x = jnp.sin(2 * jnp.pi * f0 * jnp.arange(sr // 10) / sr) * 0.1

params_jax = carfac.CarfacDesignParameters(fs=sr)
hypers_jax, weights_jax, state_jax = carfac.design_and_init_carfac(
    params_jax
)

naps, naps_fibers, state, bm, seg_ohc, seg_agc = carfac.run_segment(x, hypers_jax, weights_jax, state_jax)

fig, ax = plt.subplots(3, 1, figsize=(8, 6), sharex=True)
ax[0].plot(x)
ax[0].set_title('input')

ax[1].imshow(naps.squeeze().T, aspect='auto')
ax[1].set_title('NAP')

ax[2].plot(naps[:, 50])
ax[2].set_title('NAP channel 50')
ax[2].axhline(-0.81157, color='r')
ax[2].grid()
plt.show()

And the output:

Image

Could you help me understand how to interpret these values? Is there some sensible design parameter setting or some post-scaling that I can apply to constrain the output to [0, 1]?

Thanks again and sorry if I'm missing something obvious, I'm very new to working with these models!

davidmarttila avatar Aug 29 '25 13:08 davidmarttila