Nov 07, 2025

Public workspaceRunning a Dynamic Foraging Behavior Task in Mice

Running a Dynamic Foraging Behavior Task in Mice
  • Ella Hilton-VanOsdall1
  • 1Allen Institute for Neural Dynamics
  • Allen Institute for Neural Dynamics
Icon indicating open access to content
QR code linking to this content
Protocol CitationElla Hilton-VanOsdall 2025. Running a Dynamic Foraging Behavior Task in Mice. protocols.io https://dx.doi.org/10.17504/protocols.io.5jyl8p4m6g2w/v1
License: This is an open access protocol distributed under the terms of the Creative Commons Attribution License,  which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited
Protocol status: Working
We use this protocol and it's working
Created: February 23, 2024
Last Modified: November 07, 2025
Protocol Integer ID: 95676
Keywords: Foraging, Dynamic Foraging, Behavior, Behavior Training, Foraging Behavior, Decision Making, Mouse behavior, foraging behavior task, behavior task in mice, dynamic foraging, behavioral task, thirsty mouse, water reward, behavioral training, mice, decisions on reward, procedure for behavioral training, course of the experiment, probabilistic reward, experiment, experimenter, reward, task, water, experimental setup, choice history
Abstract
This protocol describes the experimental setup and procedure for behavioral training of mice in a “dynamic foraging” task (as described in Bari et al., 2019; Grossman, et al., 2022). The behavioral task outlined in this protocol involves training a thirsty mouse to make decisions in a dynamic environment. Each trial begins with an auditory “go cue,” followed by a choice to lick toward either a left or right lickspout. Choices are followed by probabilistic rewards (drops of water). Reward probabilities change over the course of the experiment, so mice must base their decisions on reward and choice history to maximize their water reward. The task can be modified to reflect the experimenter’s specific question through alterations in the training parameters. Mice are trained 5-7 days per week, with a typical session lasting 75-90 minutes. This protocol outlines the materials and steps for preparing and running the experiment.
Guidelines
Mice should be single-housed on a 12-hour light cycle (8:30 AM - 8:30 PM dark). Active behavior must occur during the dark period. Mice must be provided ad-libitum food throughout the experiment - refer to protocol in Before Starting for details on water restriction. Experimenters must ensure cleanliness of the experimental environment at all times.

It is best practice to let the mouse's weight stabilize at their target weight (post water restriction) before starting training, and run experiments at approximately the same time each day to ensure the mouse is motivated by the water reward.
Materials
Materials (Software):

Materials (Hardware):
Supplies can be substituted with their equivalent
MaterialManufacturerPart NumberPurpose
Behavior boxesBuilt in-house-Secure animal, run behavior. See Materials - Figure 1
1mL Luer-Lok Syringe Becton Dickinson and Company309628 Supplemental water delivery to mouse
Nalgene® 125 ml PET Square Media Bottles, Sterile CP Lab Safety342040-0125Storage of supplemental liquid reward
1000mL Nalgene Straight-Sided Wide Mounth Polocarbonate JarsFisher Scientific21161000 Mouse weight collection
KimWipesKimberly-Clark ProfessionalS47299A Cleaning
70% EthanolSigma Aldrich459836 Disinfecting hardware, diluted in house
Ohaus® Scout® Portable Balance OhausOH30253024 Weight collection
Water Reward (Reverse Osmosis)- -Liquid reward, replaced weekly
Lens Cleaning Wipes ZeissB0030E4UIQCleaning debris from optic fiber implants
Water BowlBuilt in-house-Holds supplemental water for the mouse. See Materials - Figure 2
Cloth Cart CoverLife Science ProductsCC-34X19X38ZCoverage of mouse cages to block potential light exposure
Swiffer SweeperUlineH-1960Weekly mopping of experimental room
Swiffer Sweeper PadsUlineS-13901Weekly mopping of experimental room
HEPA Filter VacuumMakitaXCV11ZWeekly vacuuming of behavior boxes and room
1/16" Hexagon DriverDigiKey431-1114-ND Headfixing
5MM Hexagon DriverBondhus13164Engaging magnetic base
Personal Protective Equipment (PPE)
Materials
Biohazard Sharps Disposal Container
Disposable Face Mask
Disposable Lab Coat
Gloves


Figure 1.1: Behavior box (1 in Materials - Hardware)
1 = High speed video camera (side view)
2 = Infrared LED
3 = High speed video camera (bottom view)
4 = Head frame clamp*
5 = Metal mouse tube, alligator clip*
6 = Mouse stage apparatus*
7 = Mirror
8 = Lickspouts
9 = Motor stage
10 = Magnetic base
11 = Speaker

*= all components of the mouse stage apparatus

Figure 1.2: Behavior box tower

Figure 2 (10 in Materials - Hardware): water bowl attaches to cage food hopper




Troubleshooting
Safety warnings
Ensure the following PPE is worn by experimenter:
  • Gloves
  • Disposable Face Mask
  • Disposable Lab Coat
Ethics statement
Research focused behavior experiments must be conducted according to internationally accepted standards and should always have prior approval from an Institutional Animal Care and Use Committee (IACUC) or equivalent ethics committee(s).  
 
This protocol has been approved by the Allen Institute Animal Care and Use Committee (IACUC).  
PHS Assurance: D16-00781 
AAALAC: Unit 1854 
Before start
Ensure that all animals meet IACUC and veterinary requirements. Whenever handling a water-restricted mouse, be sure to monitor the animal for signs of dehydration, referring to institutional veterinary staff. Mice must be habituated and headfixed using an approved head-fixing technique (see protocol below). Mice must be run in the dark period of their light cycle, as described in the guidelines section.

Running this experiment is dependent on a specific HARP/Bonsai configuration and software setup - see GitHub repository here for the software to run the task.
Protocol
CREATED BY
Avalon Amaya

Protocol
Mouse Habituation - Head Fixation into Tube
CREATED BY
Avalon Amaya


Software Setup
Set up the software and GUI to enable running the task by ensuring connections between hardware and software are established (see Materials - Software). Launch Bonsai and the GUI by selecting the appropriate software on the computer.
Figure 1: Dynamic Foraging GUI
1 = Camera control button
2 = Mouse ID box
2a = Load button
3 = Experimenter name box
4 =Baseline weight box
5 = Water calibration window button
6 = Motor stage control panel
7 = Start button
8 = Weight and water panel
9 = Save button

Launch cameras through the GUI so that the mouse can be visualized during training (see Figure 1: part 1).
Figure 2.1: Dynamic Foraging GUI camera control window

Figure 2.2: Dynamic Foraging GUI camera preview window

In the main window of the GUI, enter the mouse ID, experimenter name, and baseline weight (see Figure 1: parts 2, 3, and 4). Cross reference all mouse ID information (ear notch or tattoo with information in the GUI).
Figure 3: Dynamic Foraging GUI after entering mouse ID and experimenter name

Note
If loading a previously trained mouse, this can be done using the Load function (see Figure 1: part 2a).

Prepare Hardware
Open the water control panel (see Figure 1: part 5). Using the software control of the solenoids in the water calibration panel (see Figure 4), drain Amount5 mL of water from each lickspout. This ensures that all air bubbles are cleared from the tubing and that water delivery to mice during the task is reliable.
Figure 4: Dynamic Foraging GUI water calibration window

Note
Once a week, empty the water reservoir completely, and refill with reverse osmosis water. See the protocol below for water system maintenance.
Protocol
Solenoid Valve Calibration for Behavior Rigs Utilizing Water Reward
CREATED BY
Ella Hilton-VanOsdall


Refill water reservoirs toAmount50 mL .
Note
It is important that each water reservoir is filled to a consistent volume each session, as differences in water volume can affect the pressure in the water lines and subsequent water delivery.

Use a KimWipe moistened with 70% ethanol (EtOH) to sanitize each lickspout.
Ensure that the infrared LEDs are turned on to allow the experimenter to visualize the mouse through the highspeed video camera while minimizing the mouse's white light exposure.
Secure the Mouse to Behavior Apparatus
Remove the mouse tube from the behavior box and place it on the head-fixing station. Move tube apparatus into its lowest and most posterior position.
Protocol
Mouse Habituation - Head Fixation into Tube
CREATED BY
Avalon Amaya

Remove the mouse from its home cage and evaluate health conditions.
If the mouse does not appear BAR do not proceed with the experiment. Alert your animal care team and monitor the mouse's condition.
Note
Always follow all IACUC and veterinary requirements when handling water restricted mice.

Secure the mouse to the tube using a 1/16" hex driver and approved head-fixing technique (Step 7 in Mouse Habituation - Head Fixation into Tube).
Adjust the tube apparatus such that the mouse is in a comfortable position, as described in Mouse Habituation - Head Fixation into Tube Go to . If the mouse shows signs of stress, such as vocalization, this is an indication that they are experiencing discomfort and action to mitigate this must be taken, such as adjusting the tube height and backward/forward positioning.
Position the Mouse in the Rig
Place the mouse tube apparatus in the rig and engage the magnetic mechanism (see Figure 5: part 10) with a 5mm hex screwdriver. This ensures that the mouse tube apparatus remains firmly in place during training.
Figure 5: Behavior box
1 = High speed video camera (side view)
2 = Infrared LED
3 = High speed video camera (bottom view)
4 = Head frame clamp*
5 = Metal mouse tube, alligator clip*
6 = Mouse stage apparatus*
7 = Mirror
8 = Lickspouts
9 = Motor stage
10 = Magnetic base
11 = Speaker

*= all components of the mouse stage apparatus

Using an alligator clip, ground the mouse by connecting the alligator clip from the AIND motor stage (Figure 5: part 9) to the tube apparatus (Figure 5: part 5).
Note
Connecting the alligator clip to the conductive tube ensures that each time the mouse's tongue touches the lickspout during the session, the electrical circuit is completed and the mouse's licks are detected.

Close the door to the experimental box to ensure minimal sound contamination during the session.
While viewing the mouse through the side and bottom cameras (see Figure 2.2), adjust the lickspouts using the motor control in the GUI (see Figure 1: part 6) so that each spout is within reach of the mouse's tongue.
Note
Always move lickspouts slowly and in small increments (0.2 mm) to ensure mouse safety.

Lickspouts should be positioned such that:
  1. The philtrum line between the nose and and mouth is positioned in the middle of the two lickspouts.
  2. The tips of the lickspouts are aligned with the upper front teeth.
  3. The Z position of the lickspouts is approximately 2mm below the mouth.

The mouse's tongue should be able to comfortably reach the end of the lickspout and make full contact with each lick. This placement can take a few days of training to refine, as new mice will likely need the lickspout close to encourage engagement. However, as the mouse learns the task, the lickspout should be lowered to 2 mm below the mouse to discourage excessive licking.

To minimize side bias the lickspout location may need to be adjusted to the left or right during the experiment. For example, a mouse that is left biased may need the lickspout offset, so that the right lickspout is closer to the center.
Figure 6: Example lickspout placement for an experienced mouse
Left: left licks
Middle: resting position
Right: right licks

Start the Behavior Session
Ensure that all training parameters are correct for the particular training stage that the mouse is on (see Figure 8). Training parameters should follow the below examples for each stage (Uncoupled Baiting Task, version 2.3).
Figure 7: Curriculum stage advancement criteria for the Uncoupled Baiting Task version 2.3

Figure 8: Parameter changes across stages for the Uncoupled Baiting Task version 2.3

Note
As training continues, parameters become increasingly difficult as the mouse learns the task. If using the Dynamic Foraging GUI setup, mouse performance is evaluated at the end of each day, and the results saved in the Autotrain database (df_manager) for the rigs to query on the next day. If the criteria for advancement in Figure 7 are met, parameters will automatically change the following training session, as outlined in Figure 8.

Refer to the Training Parameters section of the GitHub repository for parameter definitions. For technical details of defining and deploying the curriculum system, see this GitHub repo. In particular, the script outlining advancement criteria here, and the code driving advancement of mice through training stages here (evaluated in this Code Ocean capsule).

Ensure end-point criteria for the session are set such that the session will stop when training time reaches 75min or if the mouse ignores > 80% of the past 30 trials, whichever comes first (maximum time = 75min, auto stop ignore window = 30, auto stop ignore ratio threshold = 0.80).
Note
Experimenters can modify these criteria for their own purposes if needed.

Using the behavioral apparatus coupled with software control, start the session by pressing the Start button (see Figure 1: part 7).
Figure 9: Dynamic Foraging GUI after starting the behavior session

Monitor Behavior and Hardware Performance
Aurally verify that the GoCue is being delivered throughout the session.
Note
If the experimenter suspects that the GoCue is not within the correct range, it should be measured using a decibel meter to ensure that it is within the range of 73+/- 2 dB at 7.5 kHz.

Visually verify that all mouse licks are being registered by ensuring that lines appear in the LickVisualizer window of the GUI at the same time that the mouse's tongue touches the lickspout.
Note
If mouse licks are not being registered, the lick detection board must be tuned such that each mouse lick registers.

Figure 10: Dynamic Foraging GUI LickVisualizer window


Visually verify that water is being delivered to each lickspout during the session, by ensuring that a drop of water can be seen at the tip of the lickspout after reward delivery.
Throughout the session, monitor the mouse's behavioral performance through the behavioral visualization in the GUI. Depending on bias, engagement, and licking ability, the experimenter may need to intervene to help shape the mouse's behavior and aid their learning of the task. Such manipulations can include lickspout adjustment and manual water delivery.
Note
The experimenter should monitor for bias via the bias graph (see Figure 11). If the bias becomes severe (> 0.7), the user should deliver manual water to the unchosen lickspout when the reward probability on that side is high. If the mouse does not respond to manual water, the user should move the lickspout towards the biased side by 200um, which will make it harder for the mouse to reach, allowing the mouse easier access to the lickspout that was previously disfavored.
The user should continue with this pattern until bias improves. Once the bias value reaches 0.3, the user should begin to move the lickspout back towards center in increments of 200um.

Figure 11: Behavior and bias graph during dynamic foraging behavior

Ensure throughout the session that the mouse is not displaying signs of distress such as vocalization or eye foam. If the mouse displays signs of stress, end the session.
End the Behavior Session & Takedown
When the mouse has completed the behavior session, stop the session through the GUI by unclicking the Start button (see Figure 1: part 7). Refer to pre-determined endpoint criteria (Go to ) to evaluate when to end a session.

The end of a session can be defined by a pre-determined trial number or session length, a loss of engagement by the mouse, or other endpoint criteria being met.
Note
Mice in early training (<7 days) often stop responding after 30 min in the box. If mouse engagement is low (finish rate < 30%), it is best to remove the mouse from the box and resume training the following day.

Figure 12: Dynamic Foraging GUI as the user stops the behavior session

Remove the alligator clip from the mouse tube (Figure 5: part 5), disengage the magnet securing the mouse within the box (Figure 5: part 10), and remove the mouse tube from the behavior apparatus.
Carefully release the mouse from the head-fixed position by releasing the headfixing screws (Figure 5: part 4) with a 1/16" hex driver, and allow the mouse to crawl from the tube into your hand.
Weigh the mouse, record the weight, and return the mouse to its home cage.
Calculate and Deliver Supplemental Water
Calculate supplemental water.
Using the following equation, calculate the amount of supplemental water to deliver to the mouse. If using the Dynamic Foraging GUI, total and supplemental water can be calculated using the GUI (see Figure 1: part 8).

Target Weight - Post Session Weight = Supplemental Water

(Target Weight = 85% of Baseline Weight)

(Baseline Weight = average of 3 weights taken the 3 days before the animal is water restricted)
Note
In this protocol, mice must receive a minimum of 1 mL of water per day, regardless of their body weight.

Example - Baseline Weight Calculation:
Day 1 weight: 25.43 g
Day 2 weight: 25.87 g
Day 3 weight: 25.64 g
Baseline weight = (25.43 g + 25.87 g + 25.64 g)/3 = 25.65 g

Example - Target Weight Calculation:
Baseline weight = 25.65 g
Water restriction at 85% of baseline weight

25.65 g x 0.85 = 21.8 g
Maintain mouse at target weight of 21.8 g

Example - Supplemental Water Calculation:
Post Session weight = 20.5 g
Target weight = 21.8 g

21.8 g - 20.5 g = 1.3 g = 1.3 mL water

Using the value calculated above (or the value recommended by your institutional veterinary staff) record the date, time, total volume of water (Amount1.3 mL in the example above), and experimenter initials on the water restriction card, and deliver supplemental water in the mouse's water bowl (Materials - Hardware: Figure 2) with a Amount1 mL syringe.
Save all behavior data through the GUI (see Figure 1: part 9).

Rig Cleanup and Maintenance
Remove all excrement from the box and sanitize equipment with 70% EtOH after each session or mouse that is trained, including:
  • Behavior box
  • Mouse tube
  • Lickspouts
  • Weigh station
Once per week, perform spot checks and water calibration as described in the protocol below.
Protocol
Solenoid Valve Calibration for Behavior Rigs Utilizing Water Reward
CREATED BY
Ella Hilton-VanOsdall

Protocol references
Grossman, C. D., Bari, B. A., & Cohen, J. Y. (2022). Serotonin neurons modulate learning rate through uncertainty. Current Biology32(3), 586-599.e7. https://doi.org/10.1016/j.cub.2021.12.006

Bari, B. A., Grossman, C. D., Lubin, E. E., Rajagopalan, A. E., Cressy, J. I., & Cohen, J. Y. (2019). Stable Representations of Decision Variables for Flexible Behavior. Neuron103(5), 922–933.e7. https://doi.org/10.1016/j.neuron.2019.06.001