Train your rat: behavioural science at home

Skinner boxes are a kind of apparatus used for conditioning and training animals in scientific studies. You’ll almost certainly have read about them or seen them on TV: an animal is rewarded with a treat for pressing a button; or trained to respond to a patter of lights or other stimuli (like shapes, music and other sounds, or drawings). This is the sort of arrangement where a sequence of behavioural primitives (light flashes green, animal pokes green button, is rewarded with a snack) can be threaded together to create really useful data for behavioural scientists. Is it harder for an old mouse to learn to solve the puzzle than a young mouse might find it? Do other environmental variables, like diet, gender or temperature affect the results?

rat eating someone's lunch

An example rat, engaging in behaviour.

They’re not just used by behavioural scientists: a Skinner box can be a useful device for training pets, especially pets with a reasonable amount of smarts, like parrots or rats. It can automate the process you may have already used with your pet, where “correct” behaviour is rewarded – walk to heel, get a doggy snack. (We also find this approach helpful here at Pi Towers. When Gordon behaves himself, we give him a biscuit.)

Skinner boxes are also pretty expensive.  So Katherine Scott, computer vision and robotics expert, electronics ninja and rat owner/trainer, has built her own, which she intends to release as an open source device when she’s finished refining it.

Open Skinner box

Prototype Open Skinner box, with ratty customer.

Katherine didn’t just want any old Skinner box, though – Open Skinner box is an Internet of Things device, and she says:

I wanted to create not just a Skinner Box but a web enabled Skinner Box, a sorta internet of things Skinner Box. So what features should it have? I came up with the following list:

  1. I should be able to see the rats using the Raspberry Pi’s camera.
  2. The camera data should be used to create a rough correlate of the rat’s activity.
  3. The box should run experiments automatically.
  4. I should be able to buzz and feed the rats remotely.
  5. The web interface should give a live feed of all of the events as they happen.
  6. The web interface should be able to give me daily digests of the rats activity and training.
Live camera output from the box

Live camera output from the box

ratstats

Rat stats

Katherine presented Open Skinner box at Pycon: you can watch a video of her presentation at her website, and find schematics, source code, sample rat-stats, thoughts on where the device is going next, and much more there too.

Here at Pi Towers, we’ve been contemplating the acquisition of an office rodent, so we can make sure that the pet projects we’re working on for the resources section here work properly. (How many hamsters does it take to trigger a home-made tinfoil switch? What’s the best design for a Twitter-enabled food hopper?) If you’ve got suggestions for names, please leave them in the comments below.

24 Comments