A deliberately simple, open-source box for recording mouse locomotion, built as a first step towards scalable behavioural phenotyping. About £1095 a box, six printed parts, half an hour to assemble.
Every part is either printed or bought off the shelf, nothing needs machining, and the printed parts need no supports. Simplicity is the point: a box that is quick to replicate, cheap enough to run in parallel, and hard to set up wrongly.
The box pairs video capture with rotary-encoder wheel tracking, using Harp for synchronised timestamping and Bonsai for control and acquisition. The aim is to pre-screen animals before downstream experiments, so behavioural differences show up early — improving experimental efficiency and reducing the number of animals needed later.
Four frames from a single session. The wheel is against the far wall; the mouse is tracked by centroid in both the arena and the wheel, under 850 nm light it cannot see.
- Video — continuous capture at 50 Hz for observation and offline analysis
- Wheel locomotion — cumulative running distance from a 1024 ppr encoder, sampled per frame
- One clock — the Harp board triggers the camera and timestamps the encoder, so the two streams share a time base rather than being aligned afterwards
| # | Part | Qty | Supplier | Cost (£) | Notes |
|---|---|---|---|---|---|
| 1 | PLA filament | 2 | Bambu Lab | 36 | 18 each |
| 2 | FLIR Blackfly S camera | 1 | DigiKey | 277 | BFS-U3-16S2M-CS |
| 3 | Rotary encoder | 1 | AliExpress | 18 | 1024 ppr version, see notes |
| 4 | Harp Behaviour Board | 1 | Open Ephys | 415 | Listed at €510 |
| 5 | Locking USB 3.0 Micro-B cable | 1 | Amazon | 18 | 5 m, straight connector |
| 6 | GPIO cable | 1 | DigiKey | 33 | Camera trigger. FLIR ACC-01-3010, Hirose HR10 6-pin, 4.5 m |
| 7 | Varifocal lens, 2.8-12 mm, CS mount | 1 | AliExpress | 12.49 | Manual zoom and focus, no IR filter |
| 8 | IR LED strip, 850 nm, 12 V | 2 m | AliExpress | 26 | Cut to length. Three walls need about 0.6 m |
| 9 | Mini PC, e.g. GEEKOM Air12 | 1 | Amazon | 240 | Meets the minimum specification below |
| 10 | M3 hex screw set, 6-14 mm | 1 | AliExpress | 9 | May be optional, see notes |
| 11 | RJ45 breakout | 1 | AliExpress | 2 | Gets the encoder wires into Port 2 |
| 12 | Screw terminal blocks, 5-way | 1 | AliExpress | 6.25 | Pack of 10. One terminates the encoder |
| 13 | 12 V power supply | 1 | AliExpress | 2.45 | For the IR LED strip |
Approximate total: £1095
Notes
- Encoder resolution — row 3 is sold in several resolutions off the same listing, and they are
indistinguishable in the product photographs. Choose 1024 ppr: the workflow ships with
CountsPerRevset to 4096, which is 1024 quadrature-decoded x4. Fit a different resolution without changing that value andWheelDistanceis wrong in every recording, with nothing in the data to say so. See Software. - Rotary encoder alternative — Omron E6B2-CWZ6C 360P/R 0.5M,
RS stock 215-8863, £216.14 exc VAT. Same NPN open-collector output and 6 mm shaft, but 360 ppr
rather than 1024, and about twelve times the price. Worth it only if you need a warranted part.
It needs
CountsPerRevchanged to 1440. - Screws — Omron encoders ship with an E69-2 bracket and three M3 x 10 Phillips screws, which may cover the encoder mount on their own. The assembly guide calls for three M3 x 8 mm hex screws and a 2 mm Allen key, so check what arrives before ordering row 10.
One machine per box runs Bonsai and writes the video. The GEEKOM Air12 in row 9 is the cheapest unit we have found that clears the bar, so its specification is the floor:
| Minimum | |
|---|---|
| CPU | 4-core x86, Intel N-series or PT7505 class |
| RAM | 16 GB |
| Storage | 512 GB NVMe SSD |
| USB | One USB 3.2 Gen 1 Type-A port dedicated to the camera |
| OS | Windows 11, for Bonsai and the Spinnaker SDK |
Two things to watch:
- No PCIe slot on a mini PC, so the camera runs from a built-in port rather than an expansion card.
- Storage — compressed video runs at roughly 4-16 GB per hour, so 512 GB holds days rather than weeks. Uncompressed it would fill in under two hours, at the shipped 1440 x 1080 and 50 Hz. Binning 2 quarters all of these figures, at half the resolution in each direction.
Four steps, a couple of days of printing and half an hour of assembly.
| Step | What it involves | Guide |
|---|---|---|
| 1. Print | Six parts from five STLs in Assembly/Parts: arena, lid, camera holder, wheel, and the thumb screw twice. 15% infill, no supports, three plates on a standard Bambu Lab printer or equivalent. |
Assembly |
| 2. Assemble | Mount the encoder, fit the wheel to its D-shaft, clamp the camera in its holder with the lens, and line three walls with the IR strip. 20-30 minutes. | Assembly |
| 3. Wire | Camera to computer over locking USB, GPIO trigger and encoder to the Harp board. | Wiring |
| 4. Software | Install the Spinnaker SDK, run Setup.cmd, open the workflow. |
Software |
Order matters: Bonsai cannot see the camera without the Spinnaker driver already in place.
- Spinnaker SDK 4.2.0.83 — download from Teledyne Vision Solutions. The version must match exactly; the download page defaults to the latest, so choose deliberately. An account is required, so this step cannot be scripted.
- Bonsai — run
Software\Setup.cmd. It downloads Bonsai and restores every package fromBonsai.config, and warns if Spinnaker is missing or the wrong version. Nothing else needs installing by hand. - Open the workflow — start Bonsai, then File → Open →
Behaviour_Box.bonsai. Do not launch the workflow file directly: this project relies on compatibility patches.
Full detail, including camera settings, is in Software.
Configure the camera and experiment settings first — see Software. Then:
-
Clean the box with 70% ethanol or another disinfectant, and wipe it completely dry.
-
Connect the hardware, with the box still empty:
- 12 V power supply to the Harp Behaviour Board
- Rotary encoder to the Harp Behaviour Board (Port 2)
- IR LED strip power supply
- Camera USB cable to the computer
- Camera GPIO trigger cable to the Harp Behaviour Board
-
Open the Bonsai workflow and check the live camera preview is updating.
-
Place the mouse in the box.
-
Fit the lid with the camera attached.
-
Minimise external light — turn the room lights off, or cover the box with black fabric (recommended).
-
Set the save directory, camera serial number, subject ID, session ID and trial length, then click Start.
-
Recording stops automatically at the trial length, saving a video and a CSV of the behavioural data.
-
Return the mouse to its home cage.
-
Clean the box before the next recording, checking the corners carefully — faeces are easy to miss.
- No live camera preview — check the locking USB 3.0 cable is connected, the correct Spinnaker SDK version is installed, and the camera serial number matches the connected device.
- Rotary encoder not responding — check the RJ45 connection to the Harp Behaviour Board and that the encoder is on the correct input pins.
- Preview or CSV window missing — reopen them manually, as below.
- Right-click the Logging node and select Show Default Editor...
- In the editor window, right-click the LogVideo node and select Show Default Editor...
- Right-click the VideoWriter node and select:
- Show Visualizer
- Bonsai.Vision.Design.IplImageVisualizer
- Right-click the CsvWriter node.
- Select:
- Show Visualizer
- Bonsai.Design.ObjectTextVisualizer
Tip
Do not close these visualizer windows by hand. Bonsai closes them when the workflow stops, and reopens them on the next run.
Released under the MIT License, which covers the printed design as well as the workflow and the documentation.
The five UclOpen packages in local_packages/ are redistributed under the BSD 3-Clause License, and
everything Setup.cmd downloads stays under its own terms. See
THIRD-PARTY-NOTICES.md.

