We give them rewards for doing tasks.
Imagine a mouse cage with a green and a blue button on the floor of the cage, small enough for the mouse to push, and also a green and a blue light on the wall of the cage.
If I show a mouse a blue light and it presses the blue button, it gets a reward, like sugar water.
If I showed it a green light and it presses a green button, it would get a reward. If it pressed the wrong colour button, it would get nothing.
Then I can tell if it thinks the light I show it is blue or green, depending on which button it presses.
Now, say I switched off some of the brain cells that I think are important for the mouse to be able to see colour…
If I’m right and that’s what those cells do, it wouldn’t be able to tell the difference between blue and green any more and would press the wrong button.
So by changing which brain cells we switch on and off, and seeing how the mouse’s behaviour changes on these sorts of tasks, we can tell which brain cells do what!