A mathematical framework to study the contribution of neural codes to behaviour