Zebrafish behavior tracking: 4 open-source software tools
A zebrafish behavior assay can produce thousands of frames in a single session, but raw video is not yet a measurement.

The useful signal may be a change in tail curvature, a brief turn, a preference for one region of the arena, or a coordinated response across dozens of animals. The challenge is to preserve those details without turning every experiment into a custom computer-vision project.
The current landscape of zebrafish behavior tracking software is unusually varied. Some tools are built around deep-learning pose estimation. Others combine stimulus control with real-time tracking, or offer a visual programming environment for closed-loop experiments. One is designed specifically to identify many unmarked animals as they move together. The right choice depends less on which tool sounds most advanced than on the geometry of the assay, the behavior being measured, and the level of control required during acquisition.
Start with the behavior, not the software
A larval zebrafish is typically only about 4 mm long. At that scale, a camera view that appears generous to the human eye can still be biologically cramped. A few pixels may encode the difference between forward swimming and a rapid escape response; a small change in contrast can determine whether the tail is separated cleanly from the background.
This is why “automated tracking” is not one problem. A free-swimming larva in a well, a head-embedded fish responding to a moving pattern, and a group of 80 unmarked animals in a large arena generate very different data structures.
Before comparing platforms, define the output you actually need:
- Position and locomotor metrics: distance, speed, acceleration, turning angle, and occupancy.
- Posture: head orientation, body curvature, tail-beat frequency, and bout structure.
- Eye motion: especially relevant in visual, optomotor, and prey-related assays.
- Identity: whether the same individual can be followed through occlusions or group interactions.
- Closed-loop control: whether the animal’s movement should alter the stimulus in real time.
- Experimental throughput: the number of animals, wells, arenas, and videos processed in one workflow.
A tool can be excellent at one layer and unsuitable at another. A contour-based tracker may be perfectly adequate for locomotor activity in a clean arena, while a kinematic study of escape behavior requires the tail to be represented as a sequence of articulated points.
The decisive question is not “Can this software track a fish?” It is “Which biological event must remain visible after the video becomes data?”
ZebraZoom: deep learning for posture and kinematics
ZebraZoom is the most natural starting point when the assay depends on more than the animal’s centroid. It tracks the head and tail of freely swimming and head-embedded larval and adult zebrafish, combining deep learning with postural and kinematic analysis.
That distinction matters. A center-point trajectory can tell you that the fish moved 12 millimeters in a given interval. It cannot, by itself, distinguish a smooth exploratory turn from a rapid escape maneuver, or separate a change in body posture from a simple translation across the arena. ZebraZoom is designed to retain that internal structure.
What ZebraZoom measures well
The software is suited to experiments where the body axis and tail motion are central to interpretation. Typical outputs can include:
- swimming trajectories and velocity;
- head position and orientation;
- tail posture and curvature;
- bout timing and locomotor patterns;
- movement in freely swimming or head-embedded preparations.
For visual behavior studies, this creates a useful bridge between stimulus and motor response. A moving grating, flash, looming stimulus, or contrast change may produce a response that is not captured by total distance alone. The temporal relationship between stimulus onset, head reorientation, and tail acceleration may be the more informative measure.
The visual design of the assay still determines the quality of the result. ZebraZoom cannot restore a tail that disappears into a low-contrast background, nor can it infer a posture reliably when reflections, debris, or neighboring animals create ambiguous edges. Good illumination, stable focus, and a consistent arena remain part of the measurement system.
The practical trade-off
Deep-learning tracking offers richer information, but it also introduces a greater demand for calibration and inspection. The researcher must decide whether the model’s output reflects genuine motion or a transient tracking error. This is especially important in high-speed behaviors, where the frame-to-frame difference is large and the tail can blur.
For a small laboratory, the sensible workflow is not to process the entire archive immediately. Begin with representative videos:
1. Select recordings with ordinary movement, rapid bouts, partial occlusion, and the least favorable lighting.
2. Run the tracking pipeline on those examples.
3. Inspect whether the head and tail remain anatomically plausible across the full movement.
4. Compare automated trajectories with a small manually reviewed subset.
5. Only then scale the analysis to the full experiment.
This takes time at the beginning, but it prevents a more expensive mistake: generating a large, polished dataset whose central variable is unstable.
Stytra: the experiment as a programmable environment
Stytra approaches larval zebrafish experiments from a different angle. It is a Python-based, modular open-source package for timed stimulus presentation, hardware interfacing, and real-time tracking of position, orientation, tail, and eye motion.
The important feature is not simply that Stytra tracks behavior. It connects the stimulus, the acquisition system, and the analysis logic in one environment. That makes it particularly useful when timing is part of the biological question.
A behavioral response is not just a movement. It is a movement aligned to a defined visual or sensory event. If the stimulus timing is imprecise, then the apparent latency of the response may reflect the software stack rather than the nervous system.
Where Stytra becomes valuable
Stytra is well suited to experiments involving:
- timed visual stimulation;
- hardware-triggered acquisition;
- real-time feedback;
- orientation and positional tracking;
- tail and eye-motion measurements;
- repeatable protocols that need to be modified programmatically.
The modular structure allows the researcher to build an experimental sequence around the assay rather than forcing the assay into a fixed commercial template. That is useful for laboratories studying sensorimotor transformations, optomotor behavior, habituation, or responses that depend on the animal’s current state.
For example, a closed-loop experiment may present a stimulus whose speed or direction changes according to the larva’s orientation. In an open-loop design, the visual field follows a predetermined schedule. These are not interchangeable conditions: the first tests a dynamic interaction between animal and environment, while the second offers tighter control over stimulus history. Stytra’s architecture supports this distinction.
Python as an advantage—and a boundary
A Python environment gives the experimenter a precise vocabulary for timing, variables, and hardware. It also makes protocols easier to version, reproduce, and adapt than a collection of undocumented manual settings. A sequence can be described explicitly: stimulus duration, inter-trial interval, trigger condition, tracking threshold, and output format.
The cost is that the first hour of setup may feel less immediate than a graphical application. Researchers do not need to become software engineers, but they do need enough fluency to understand the experiment’s control flow. A protocol that cannot be read or modified by the people running the assay will eventually become fragile, regardless of how sophisticated the software is.
Stytra therefore fits laboratories that want the experimental logic itself to remain visible. It is less a single-purpose tracker than a programmable laboratory bench, with the image, the stimulus, and the timing occupying the same frame.
In behavior experiments, reproducibility begins before analysis: it begins with a stimulus that arrives when the protocol says it should.
BonZeb: visual programming for closed-loop zebrafish assays
BonZeb is built as a suite of modular packages for the Bonsai visual programming language. It supports high-resolution zebrafish tracking with dynamic visual feedback in both head-fixed closed-loop experiments and free-swimming virtual open-loop assays.
Its central attraction is visual control. Instead of constructing the entire experiment through conventional code, the researcher assembles a flow of acquisition, tracking, stimulus presentation, and feedback. This can make the relationship between the animal’s behavior and the visual environment easier to inspect.
That clarity matters in experiments where the stimulus is not merely delivered to the fish but shaped by the fish’s own actions. A head-fixed larva may drive the movement of a visual scene through its tail beat. A free-swimming fish may encounter a virtual environment whose parameters are updated according to its position. In both cases, the closed loop is part of the neural manipulation.
BonZeb’s strongest use case
BonZeb is a good fit when the assay requires:
- dynamic visual feedback;
- high-resolution tracking;
- head-fixed preparations;
- virtual open-loop environments for free-swimming fish;
- rapid changes to the relationship between movement and stimulus;
- a workflow that can be inspected visually by more than one person.
The visual programming model can reduce the distance between experimental design and implementation. A researcher can see how the camera input is processed, where the tracking output goes, and which condition changes the stimulus. This is particularly valuable in collaborative laboratories, where the person designing the behavior paradigm may not be the person maintaining the code.
There is also a design discipline hidden inside the visual interface. A complex flow can become difficult to read if every parameter, transformation, and hardware event is placed into one dense structure. The same principle applies to a figure in a paper: more visible information does not automatically create more understanding. Modular blocks, named variables, and a restrained number of simultaneous operations make the experiment easier to audit.
Open-loop versus closed-loop
The distinction deserves careful attention. In a virtual open-loop assay, the visual stimulus can be presented according to a predefined sequence while the fish’s behavior is recorded independently. In a closed-loop assay, the animal’s movement changes the stimulus.
The first offers experimental control over what the fish sees. The second can reveal how the animal regulates its behavior in response to the consequences of its own movement. If these conditions are confused, the interpretation becomes blurred. The same swimming pattern may mean something different when the fish is controlling the visual scene than when the scene is imposed externally.
BonZeb is most useful when the experiment benefits from making that relationship explicit and adjustable.
idtracker.ai: identity at group scale
Many zebrafish assays become difficult not because the tracking problem is visually complex, but because there are many animals in the same frame. idtracker.ai addresses this problem with AI-based multi-animal tracking. It can track up to 100 unmarked animals, using convolutional neural networks to maintain individual identities with high accuracy.
That capability changes the unit of analysis. Instead of measuring a single fish in isolation, the researcher can examine trajectories, spatial distributions, and interactions across a group. This is relevant to schooling, social preference, collective responses, and assays where individual marking would alter the experiment or simply be impractical.
The software’s benchmark accuracy has been reported at 99.9% in test videos, but that figure should be read as a performance result under defined conditions, not as a guarantee for every arena and lighting setup. Tracking accuracy is shaped by contrast, density, occlusion, camera angle, animal appearance, and the duration of ambiguous crossings.
Why identity is biologically important
A group-level heat map can show where animals spend time. Identity-aware tracking can show whether the same individuals maintain a preference, switch locations, or diverge in their response to a stimulus. Those are different biological questions.
For example, a treatment may appear to reduce group movement. Without identity, it may be difficult to tell whether every animal slowed modestly or whether a small subset stopped moving while the rest behaved normally. Individual trajectories preserve that distribution.
idtracker.ai is also useful when the experiment contains repeated measures. If the same animal can be identified throughout the recording, the analysis can retain within-group variation rather than collapsing all movement into a single average.
The v6 change: learning representations rather than relying on full visibility
The updated idtracker.ai version 6 reframes multi-animal tracking as a representation-learning problem using contrastive learning. According to the reported release information, this allows tracking to run up to 700 times faster and removes the need for video segments in which all animals are simultaneously visible.
That is a meaningful conceptual shift. Traditional identity assignment becomes especially fragile when animals overlap or when the system expects a complete view of the group as a reference. A representation-learning approach attempts to encode visual features that help distinguish individuals across time, even when the scene is temporarily incomplete.
The practical consequence is not that occlusions stop mattering. They remain a source of uncertainty. Rather, the software can work with a less ideal sequence of observations, which is closer to the visual reality of group behavior.
How the four tools differ
The distinctions are clearest when the tools are placed beside the assay requirements rather than ranked in the abstract.
| Tool | Strongest capability | Typical preparation | Best suited to | Main trade-off |
|---|---|---|---|---|
| ZebraZoom | Head-and-tail tracking with postural and kinematic analysis | Freely swimming or head-embedded larval and adult zebrafish | Tail motion, posture, locomotor bouts, detailed kinematics | Richer outputs require careful review of tracking quality |
| Stytra | Timed stimulation, hardware control, and real-time tracking | Primarily larval zebrafish experiments | Programmable sensorimotor assays and precise stimulus timing | Python-based workflows require some technical setup |
| BonZeb | High-resolution tracking with dynamic visual feedback | Head-fixed or free-swimming preparations | Closed-loop and virtual open-loop visual assays | Visual programs can become complex without modular organization |
| idtracker.ai | Multi-animal identity tracking | Groups of unmarked zebrafish | Social behavior, group movement, and high-throughput trajectories | Identity confidence depends on density, occlusion, and video quality |
The table is not a hierarchy. It is a map of where information is preserved.
If the biological variable is tail curvature, a group tracker is the wrong lens. If the biological variable is the difference between fish one and fish two across a crowded arena, a single-animal pose tracker may be too narrow. If stimulus timing and feedback determine the experiment, a tracker without control over the stimulus pipeline leaves a critical part of the assay outside the measurement.
Building a reliable workflow around the tracker
Open-source software can lower the cost of experimentation, but it does not remove the need for system design. The camera, illumination, arena, stimulus display, synchronization, and analysis pipeline all contribute to the final measurement.
A practical workflow has five stages.
1. Make the image legible
The zebrafish brain is not the only biological structure that benefits from contrast. The behavior camera also needs a visual field in which the fish is separated from the background with stable luminance. Avoid lighting that creates moving reflections or bright gradients across the arena. Keep the geometry fixed between experimental days.
For larvae, the tail often carries more behavioral information than the body centroid. A clean silhouette and sufficient temporal resolution are therefore more valuable than an aesthetically pleasing but low-contrast image.
2. Match the tracker to the arena
A tool that performs well in a single well may behave differently in a multi-well plate, and a system designed for groups may not preserve fine posture. Define the region of interest carefully. If the assay includes many wells or irregular boundaries, the ability to specify flexible regions can become a practical advantage.
The emerging open-source tool StrIPETrack, published in 2026, is designed around flexible region-of-interest selection for high-throughput zebrafish behavior assays. It is presented as an alternative to proprietary LabVIEW-based systems, particularly where the experiment requires custom ROI handling. It is not one of the four core tools compared here, but it is worth watching if the geometry of the assay is the main constraint.
3. Separate acquisition from interpretation
Store the raw videos even when the software exports trajectories. A derived speed trace is not a substitute for the original image. Later questions may require a different threshold, a new region of interest, or a revised definition of a movement bout.
This is also where metadata becomes part of the science. Record camera settings, frame rate, magnification, arena dimensions, light conditions, stimulus timing, and software versions. Without that context, an apparently precise result can be difficult to reproduce.
4. Review edge cases, not only clean examples
The most informative validation videos are rarely the most beautiful ones. Include recordings with:
- overlapping animals;
- abrupt turns;
- low-contrast body regions;
- temporary occlusions;
- reflections or debris;
- animals near the edge of the ROI;
- unusually inactive or unusually vigorous behavior.
A tracker that handles only the median case may still distort the biological conclusion if the treatment specifically increases atypical behavior.
5. Keep the output close to the question
It is tempting to collect every parameter a platform can export. That often creates a broad but visually noisy dataset. Select metrics that map onto a defined biological mechanism or behavioral hypothesis.
For a locomotor assay, distance and velocity may be sufficient. For an escape response, latency, acceleration, turning angle, and tail curvature may matter more. For social behavior, individual identity and inter-animal distance become central. The best analysis is not the one with the most columns; it is the one in which each column has a defensible relationship to the nervous system.
Where simpler tools still have a place
Not every experiment needs deep learning or identity tracking. ToxTrac remains a free Windows-based option for obtaining kinematic parameters and spatial distributions in zebrafish and other animals. Its contour-based approach can be useful in relatively clean, low-density assays where the fish can be separated from the background without detailed posture estimation.
Its limitations are equally clear. ToxTrac has not received major updates since 2020, and contour-based tracking cannot provide the same anatomical detail as a head-and-tail or pose-based system. It should be treated as a practical baseline rather than a universal solution.
That distinction is useful when planning a laboratory workflow. A simpler platform can be the right choice for an uncomplicated endpoint, especially when it is stable, transparent, and easy for the team to maintain. Complexity should be purchased with a biological reason.
The same principle applies to open-source adoption more broadly. These tools do not completely replace commercial platforms in every setting. Proprietary systems may offer integrated hardware, established support, and specialized workflows for industrial high-throughput screening. The meaningful comparison is not “free versus commercial.” It is whether the platform preserves the information and timing your experiment requires.
Choosing by assay scale and visual information
A compact decision path can help narrow the field:
1. Need detailed posture or tail kinematics?
Begin with ZebraZoom, especially when the animal is freely swimming or head-embedded and the tail response carries the main signal.
2. Need precise stimulus timing or real-time hardware interaction?
Consider Stytra. Its Python-based modular design is suited to experiments where acquisition and stimulation must remain synchronized.
3. Need a visually programmable closed-loop environment?
BonZeb is a strong candidate for dynamic visual feedback, head-fixed preparations, and virtual open-loop or closed-loop assays.
4. Need to follow many unmarked animals individually?
idtracker.ai is the natural fit, with capacity for up to 100 animals and a design centered on identity preservation.
5. Need flexible ROI handling across a high-throughput layout?
Evaluate whether a tool such as StrIPETrack addresses the geometry more directly than a general-purpose tracker.
The choice should be made with a short pilot, not a long specification document. Record a small set of videos under the actual illumination, magnification, animal density, and stimulus conditions. Then inspect the output at the level where the biology lives: the tail beat, the turn, the bout, the individual trajectory, or the stimulus-response delay.
The principle that holds the workflow together
Zebrafish behavior tracking works best when the software is treated as part of the experimental apparatus rather than as a neutral post-processing layer. The camera creates a visual representation. The tracker converts that representation into coordinates, posture, identity, or timing. Every conversion can preserve information—or quietly erase it.
ZebraZoom is strongest when anatomy and kinematics matter. Stytra is strongest when timing and programmable stimulation shape the assay. BonZeb is strongest when visual feedback must respond to the animal. idtracker.ai is strongest when identity must survive group movement. These are different kinds of precision, and they should not be collapsed into a single ranking.
The actionable principle is simple: define the smallest biological event your analysis must preserve, then choose the tool that represents that event with the least distortion. In a zebrafish laboratory, the most elegant pipeline is not necessarily the most complex one. It is the one in which image quality, tracking method, stimulus timing, and behavioral interpretation remain aligned from the first frame to the final figure.