Skip to main content
NIHPA Author Manuscripts logoLink to NIHPA Author Manuscripts
. Author manuscript; available in PMC: 2024 Jan 9.
Published in final edited form as: J Vis Exp. 2023 Mar 3;(193):10.3791/64863. doi: 10.3791/64863

An Open-Source Virtual-reality System for Measurement of Spatial Learning in Head-restrained Mice

Clay Lacefield 1,2,*, Hongtao Cai 1, Huong Ho 1, Carla Dias 1, Hannah Chung 1, René Hen 1,2, Gergely F Turi 1,2,*
PMCID: PMC10775991  NIHMSID: NIHMS1953751  PMID: 36939265

Abstract

Head-fixed behavioral experiments in mice allow neuroscientists to observe neural circuit activity with high-resolution electrophysiological and optical imaging tools while delivering precise sensory stimuli to a behaving animal. Recently, human and rodent studies using virtual reality (VR) environments have shown VR to be an important tool for uncovering the neural mechanisms underlying ethologically relevant behaviors such as spatial learning in the hippocampus and cortex, due to extremely precise control over parameters such as spatial and contextual cues. Setting up virtual environments for rodent spatial behaviors can however be costly and require extensive background in engineering and computer programming. Here we present a simple yet powerful system based upon inexpensive, modular open-source hardware and software that enables researchers to study spatial learning in head-fixed mice using a VR environment. This system uses coupled microcontrollers to measure locomotion and deliver behavioral stimuli while head-restrained mice run on a wheel, in concert with a virtual linear track environment rendered by a graphical software package, “HallPassVR” running on a Raspberry Pi single-board computer. An emphasis on distributed processing allows researchers to design flexible, modular systems to elicit and measure complex spatial behaviors in mice in order to determine the connection between neural circuit activity and spatial learning in the mammalian brain.

SUMMARY:

Presented here is a simplified open-source hardware and software setup for investigating mouse spatial learning using VR. This system displays a virtual linear track to a head-fixed mouse running on a wheel, utilizing a network of microcontrollers and a single-board computer running an easy-to-use graphical software package.

INTRODUCTION:

Spatial navigation is an ethologically important behavior by which animals encode the features of new locations into a cognitive map useful for finding areas of possible reward and to avoid areas of potential danger. Inextricably linked with memory, the cognitive processes underlying spatial navigation share a neural substrate in the hippocampus1 and cortex, where neural circuits in these areas integrate incoming information and form cognitive maps of environments and events for later recall2. While the discovery of place cells in the hippocampus3,4 and grid cells in the entorhinal cortex5 has shed light on how the cognitive map within the hippocampus is formed, many questions remain about how specific neural subtypes, microcircuits and individual subregions of the hippocampus (the dentate gyrus, and cornu ammonis areas CA3–1) interact and participate in spatial memory formation and recall.

In vivo two-photon imaging has been a useful tool in uncovering cellular and population dynamics in sensory neurophysiology6,7, however the typical necessity for head fixation limits the utility of this method to examine mammalian spatial behavior. The advent of virtual reality (VR)8 has addressed this shortcoming by presenting immersive and realistic visuospatial environments while head restrained mice run on a ball or treadmill to study spatial and contextual encoding in the hippocampus810 and cortex11. Furthermore the use of VR environments with behaving mice has allowed neuroscience researchers to dissect components of spatial behavior by precisely controlling elements of a VR environment12 (e.g. visual flow, contextual modulation) in ways not possible in real world experiments of spatial learning, such as the Morris water maze, Barnes maze, or hole board tasks.

Visual VR environments are typically rendered on the graphical processing unit (GPU) of a computer, which handles the computational load of rapidly computing the thousands of polygons necessary to model a moving 3D environment to a screen in real time. The large processing requirements generally require the use of a separate PC with a GPU which renders the visual environment to a monitor, multiple screens13, or a projector14 as the movement is recorded from a treadmill, wheel or foam ball under the animal. The resulting apparatus for controlling, rendering and projecting the VR environment is therefore both relatively expensive, bulky, and cumbersome. Furthermore, many such environments in the literature have been implemented using proprietary software that is both costly and can only be run on a dedicated PC.

For these reasons we have designed an open-source VR system for the study of spatial learning behaviors in head-fixed mice using the Raspberry Pi single board computer. This Linux computer is both small and inexpensive but contains a GPU chip for VR rendering, allowing the integration of VR environment generation with the display or behavioral apparatus on varied individual setups. We have furthermore developed a graphical software package written in Python, “HallPassVR”, which utilizes the Raspberry Pi to render a simple visuospatial environment, a virtual linear track or hallway, by recombining custom visual features selected using a graphical user interface (GUI). This is combined with microcontroller subsystems (e.g., ESP32 or Arduino) to measure locomotion and coordinate behavior, such as delivery of other modalities of sensory stimuli or rewards to facilitate reinforced learning. This system provides an inexpensive, flexible, and easy-to-use alternative method for delivering visuospatial VR environments to head-fixed mice during two-photon imaging (or other techniques requiring head fixation) for the study of neural circuits underlying spatial learning behavior.

PROTOCOL:

A Raspberry Pi 4 single-board computer is used to display a VR visual environment coordinated with the running of a head-fixed mouse on a wheel. Movement information is received as serial input from an ESP32 microcontroller reading a rotary encoder coupled to the wheel axle. The VR environment, “HallPassVR”, is rendered using OpenGL hardware acceleration on the Raspberry Pi GPU, using the pi3d python package on the Raspberry Pi. The rendered environment is then output via a projector onto a compact wraparound parabolic screen centered on the head-restrained mouse’s visual field15,16, while behavior (e.g. licking to spatial rewards) is measured by a second behavior ESP32 microcontroller. A python software package (“HallPassVR”) enables creation of virtual linear track environments consisting of repeated patterns of visual stimuli along a virtual corridor, with a graphical user interface (GUI). This design is easily parameterized, allowing creation of complex experiments aimed at understanding how the brain encodes places and visual cues during spatial learning (see Step 4). All procedures in this protocol have been approved by the Institutional Animal Care and Use Committee of the New York State Psychiatric Institute.

Note: Designs for custom hardware components necessary for this system (running wheel, projection screen, and head fixation apparatus) are deposited to a public GitHub repository (https://github.com/GergelyTuri/HallPassVR ). We recommend reading the documentation of that repository along with this protocol, as the site will be updated with future enhancements of the system.

Step 1: Hardware setup: Construction of the running wheel, projection screen, and head-fixation apparatus.

Note: Custom components for these setups (see design files) can be easily manufactured if the user has access to 3D printing and laser cutting equipment or outsourced to professional manufacturing or prototyping services.

1.1: Running wheel and behavioral setup (Figure 1.). The wheel consists of a clear acrylic cylinder (6” diam., 3” width, 1/8” thick) centered on an axle suspended from laser cut acrylic mounts via ball bearings. The wheel assembly is then mounted to a lightweight aluminum frame (t-slotted) and securely fastened to an optical breadboard (Figure 1CE.).

  • 1.1.1:

    Laser cut sides of wheel and axle mounts, and attach wheel sides with acrylic cement. Screw axle flange into wheel center piece.

  • 1.1.2:

    Insert axle into wheel center flange, snap ball bearings into axle mounts, and attach to vertical aluminum support bar.

  • 1.1.3:

    Insert wheel axle into mounted ball bearings, leaving 0.5–1” of axle past the bearings for attachment of the rotary encoder.

  • 1.1.4:

    Attach rotary encoder mount to end of axle opposite the wheel and insert rotary encoder, then use shaft coupler to couple wheel axle to rotary encoder shaft.

  • 1.1.5:

    Attach lick port to flex arm then affix to aluminum wheel frame with t-slot nuts. Use 1/16” tubing to connect lick port to solenoid valve, and valve to water reservoir.

    Note: The lick port must be metal, and a wire soldered to attach to the capacitive touch sensing pins of the behavior ESP32.

Figure 1.

Figure 1.

Head-fixed VR hardware setup: projection screen, running wheel, and head fixation apparatus.

A. 3D design schematic of running wheel and projection screen. B. Completed VR behavioral setup. The VR environment is rendered on a Raspberry Pi 4 single board computer (1) and projected onto a parabolic rear-projection screen (2) (based on Chris Harvey lab design15,16). 3) wheel assembly. 4) head post holder. 5) water reservoir for reward delivery. C. Top view of the projection screen and behavioral setup. 1) LED projector. 2) Mirror for rear-projecting the VR corridor onto the curved screen. 3) running wheel. D. Rear view of the wheel assembly. Wheel rotations are translated by the rotary encoder (1) and transmitted to the Raspberry Pi via an ESP32 microcontroller (2). A dual axis goniometer (3) is used to fine tune the head position for optical imaging. E. Setup at the level of mouse insertion, showing the head fixation apparatus (1) and lick port placement (2) over the running wheel surface (3). F. Photo of the lick port (1) attached to a flex arm (2) for precise placement of the reward spout near the mouth of the mouse. Rewards are given via a solenoid valve (3) controlled by the behavior ESP32 (via the OpenMaze OMwSmall PCB). Also visible are the rotary encoder coupled to the wheel axle (4) and goniometer for head angle adjustment (5).

1.2: Projection screen: The VR screen is a small parabolic rear-projection screen (canvas size: 54 cm x21.5 cm) based on a design developed in Christopher Harvey’s laboratory15,16. The projection angle (keystone) of the LED projector we have used is different from that of the laser projector used previously, thus we slightly modified the original design by mounting the unit under screen and simplifying the mirror system (Figure 1A, B.).

Note: It is highly recommended to read the Harvey lab documentation along with ours to tailor the VR environment to the user’s needs.

  • 1.2.1:

    Laser cut projection screen sides from ¼” black matte acrylic sheets. Laser cut back projection mirror from ¼” mirrored acrylic.

  • 1.2.2:

    Assemble projection screen frame with aluminum bars and laser cut acrylic panels.

  • 1.2.3:

    Insert translucent projection screen material into parabolic slot in frame. Insert rear projection mirror into slot in the back of the projection screen frame.

  • 1.2.4:

    Place LED projector on bottom mounting plate inside projection screen frame. Align projector with mounting bolts to optimize positioning of the projected image on the parabolic rear projection screen.

  • 1.2.5:

    Seal the projector box unit to prevent light contamination of optical sensors if necessary.

1.3: Head fixation apparatus: This head restraint design consists of two interlocking 3D printed manifolds for securing a metal headpost (Figure 1EF).

  • 1.3.1:

    3D print headpost holding arms using a high-resolution SLM 3D printer.

    NOTE: Resin printed plastic is able to provide stable head fixation for behavior experiments, however to achieve maximum stability for sensitive applications like single cell recording or two-photon imaging, we recommend using machined metal parts.

  • 1.3.2:

    Install the 3D printed headpost holder on a dual-axis goniometer with optical mounting posts, so that the animal’s head can be tilted to level the preparation. NOTE: This feature is indispensable for chronic in vivo imaging experiments when finding the same cell population on subsequent imaging sessions is required.

  • 1.3.3:

    Two types of head posts with different complexity (and price) are deposited along with these instructions. Depending on the experiment type, the user should decide which one to implement. The head bars are made of stainless steel and generally outsourced to our local machine shop or to an online service (e.g., eMachineShop) for manufacturing.

Step 2: Set up electronics hardware/software (Raspberry Pi, ESP32 microcontrollers, Fig 2.)

Figure 2.

Figure 2.

VR electronics setup schematic.

This schematic depicts the most relevant connections between electronic components in the open-source virtual reality system for mice. A. Mice are head restrained on a custom 3D printed head-fixation apparatus above an acrylic running wheel. B. Rotation of the wheel axle with mouse running is detected by a high-resolution rotary encoder connected to a microcontroller (Rotary decoder ESP32). C. Movement information is conveyed via a serial connection to a Raspberry Pi 4B single board computer running the HallPassVR GUI software and 3D environment, which updates the position in the VR virtual linear track environment based upon mouse locomotion. D. The rendered VR environment is sent to the projector/screen via the HDMI #2 video output of the Raspberry Pi 4 (VR video HDMI). E. Movement information from the rotary encoder ESP32 is also sent to another microcontroller (Behavior ESP32 with the OpenMaze OMwSmall PCB) which uses the mouse position to control spatial, non-VR behavioral events (such as reward zones or spatial olfactory, tactile, or auditory stimuli) in concert with the VR environment, and measures licking of the reward spout via capacitive touch sensing.

2.1: Configure Raspberry Pi 4 model B: Note: This single-board computer is optimal for this setup because it has an onboard GPU to facilitate VR environment rendering, as well as two HDMI ports for experiment control/monitoring and VR projection. However other single-board computers with these characteristics may potentially be substituted.

  • 2.1.1:

    Download Raspberry Pi Imager app to your PC and install OS (currently Raspberry Pi OS r.2021–05-07) on the microSD card (8GB+). Insert card and boot Raspberry Pi.

  • 2.1.2:

    Configure Raspberry Pi for pi3d python 3D library: (menu bar) Preferences>Raspberry Pi Configuration> a.) Display>Screen Blanking>Disable, b.) Interfaces>Serial Port>Enable, c.) Performance>GPU Memory>256

  • 2.1.3:

    Upgrade python image library package for pi3d: (terminal)> sudo pip3 install pillow --upgrade

  • 2.1.4:

    Install pi3d python 3D package for Raspberry Pi: (terminal)> sudo pip3 install pi3d

  • 2.1.5:

    Increase HDMI output level for projector: (terminal)>sudo nano /boot/config.txt, uncomment config_hdmi_boost=4, save, reboot.

  • 2.1.6:

    Download and install Arduino IDE from arduino.cc/en/software (e.g., arduino-1.8.19-linuxarm.tar.gz), needed to load code onto rotary encoder and behavior ESP32 microcontrollers.

    Note: Arduino and Processing environments may be run on a separate PC from the VR Raspberry Pi if desired.

  • 2.1.7:

    Install ESP32 microcontroller support on Arduino IDE: 1.) File>Preferences>Additional Board Manager URLs = https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json, 2.) Tools>Boards>Boards Manager>ESP32 (by Espressif). Install v.2.0.0 (upload currently fails on v2.0.4).

  • 2.1.8:

    Download and install Processing IDE from https://github.com/processing/processing4/releases (e.g., processing-4.0.1-linux-arm32.tgz). Necessary for recording and online plotting of mouse behavior during VR.

2.2: Set up rotary encoder ESP32 connections: The rotary encoder coupled to the wheel axle measures wheel rotation with mouse locomotion, which is counted with an ESP32 microcontroller. Position changes are then sent to the Raspberry Pi GPIO serial port to control movement through the virtual environment using HallPassVR, and to the behavior ESP32 to control reward zones (Fig. 2).

  • 2.2.1:

    Connect wires between rotary encoder component and the rotary ESP32: Rotary encoders generally have four wires: +, GND, A &B (two digital lines for quadrature encoders), which will connect via jumper wires to ESP32 3.3V, GND, 25, 26 (in the case of our attached code).

  • 2.2.2:

    Connect serial RX/TX wires between the rotary ESP32 and behavior ESP32: A simple 2-wire connection should be made between the rotary ESP32 Serial0 RX/TX (receive/transmit) and the Serial2 port of the behavior ESP32 (TX/RX, pins 17, 16; see Serial2 port on right of OMwSmall PCB). This will carry movement information from the rotary encoder to the behavior setup for spatial zones such as reward zones.

  • 2.2.3:

    Connect serial RX/TX wires between the rotary ESP32 and Raspberry Pi GPIO (or direct USB connection): 2-wire connection between Raspberry Pi GPIO pins 14, 15 (RX/TX) and rotary ESP32 Serial2 (TX/RX, pins 17, 16). This will carry movement information from the rotary encoder to the HallPassVR software running on the Raspberry Pi.

    Note: Only necessary if rotary ESP32 is not connected via USB, but VR code must be modified to use ‘/dev/ttyUSB0’. This hardwired connection will be replaced with a wireless Bluetooth connection in future versions.

  • 2.2.4:

    Plug rotary ESP32 USB into Raspberry Pi USB (or other PC running Arduino IDE), to upload initial rotary encoder arduino code.

2.3: Set up behavior ESP32 connections with behavioral hardware (via OpenMaze PCB): The behavior ESP32 microcontroller will control all non-VR animal interactions (delivering non-VR stimuli, rewards, detecting mouse licks), which are connected through a general PCB “breakout board” for the ESP32 (“OMwSmall”, designs of which are available through our website www.openmaze.org). The PCB contains electronic components necessary for driving electromechanical components such as solenoid valves used to deliver liquid rewards.

  • 2.3.1:

    Connect 12V liquid solenoid valve to ULN2803 IC output on the far left of the OMwSmall PCB (pin#12 in our example setup and code). This IC gates 12V power to the reward solenoid valve, controlled by a GPIO output on the behavior ESP32 microcontroller.

  • 2.3.2:

    Connect lick port to ESP32 touch input (e.g., T0, GPIO4 in our example code). The ESP32 has built-in capacitive touch sensing on specific pins, which we the behavior ESP32 code uses to detect mouse licking of an attached metal lick port during VR behavior.

  • 2.3.3:

    Connect serial RX/TX wires between the behavior ESP32 Serial2 (pins 16, 17) and rotary encoder ESP32 Serial0 (see above #2.2.2.).

  • 2.3.4:

    Plug USB into Raspberry Pi USB port (or other PC). The USB connection will be used to upload new programs to the behavior ESP32 for different experimental paradigms (e.g., number/location of reward zones), and to capture behavior data using the included Processing sketch.

  • 2.3.5:

    Plug 12V DC wall adapter into 2.1mm barrel jack connector on the behavior ESP32 OMwSmall PCB. This will provide power for the reward solenoid valve.

  • 2.3.6:

    Plug Raspberry Pi HDMI #2 output into projector HDMI port: this will carry the HallPassVR environment rendered by the Raspberry Pi GPU to the projection screen.

  • 2.3.7:

    (optional) Connect synchronization wire (pin 26) to neural imaging or electrophysiological recording setup. A 3.3V TTL signal will be sent every 5 sec to align systems with near millisecond precision.

2.4: Set up software: Load firmware/software onto the rotary encoder ESP32 (Fig. 2B) and behavior ESP32 (Fig. 2E) using the Arduino IDE, and download the HallPassVR Python software onto the Raspberry Pi.

  • 2.4.1:

    Plug rotary encoder ESP32 into Raspberry Pi USB port first- it will automatically be named ‘/dev/ttyUSB0’ by the OS.

  • 2.4.2:

    Load rotary encoder arduino code by first selecting the ESP32 under Arduino IDE>Tools>Boards>ESP32 Dev Module, then Tools>Port>‘/dev/ttyUSB0’, then click Upload: RotaryEncoder_Esp32_VR.ino.

  • 2.4.3:

    Plug behavior ESP32 into Raspberry Pi USB port next- it will be named ‘/dev/ttyUSB1’ by the OS.

  • 2.4.4:

    Load behavior sequence arduino code onto behavior ESP32 (Arduino IDE, ESP32 Dev Module already selected), then Tools>Port>‘/dev/ttyUSB1’, and click Upload: wheel_VR_behavior.ino.

  • 2.4.5:

    Test serial connections by selecting the Port in the Arduino IDE, then clicking on Tools>Serial Monitor (baud rate: 115200), to observe serial output from the rotary board (USB0) or the behavior board (USB1). Rotate the wheel and you should see raw movement output from the rotary ESP32 on USB0, or formatted movement output from the behavior ESP32 on USB1.

  • 2.4.6:

    Download HallPassVR python code from https://github.com/GergelyTuri/HallPassVR/tree/master/software/HallPassVR (to: /home/pi/Documents). This folder contains all files necessary for running HallPassVR, if the pi3d python3 package was installed correctly earlier (Step 2.1).

Step 3: Run and test HallPassVR: Run the HallPassVR GUI to initiate a VR linear track environment, calibrate the distances on the VR software and behavior ESP32 arduino code, and test acquisition and online plotting of mouse running and licking behavior with the included Processing language sketch.

3.1: Open terminal window in Raspberry Pi, navigate to HallPassVR folder (terminal:> cd /home/pi/Documents/HallPassVR)

3.2: Run VR GUI: (terminal)> python3 HallPassVR_GUI.py (GUI window will open, Fig. 3A).

Figure 3.

Figure 3.

HallPassVR GUI and behavior.

A. HallPassVR GUI: Select 4 images to tile over each spatial pattern (or load combination pattern previously saved), for 3 patterns in each path equal to the track length. Select ceiling and floor images, then press Start to initialize VR environment on the Raspberry Pi HDMI output (projection screen). B. Example virtual corridor created with HallPassVR GUI parameters shown in “A.”, and used for hidden reward experiment to test spatial learning. C. Photo of head restrained mouse running on wheel in virtual environment shown in “B.”. D. Online plot of animal behavior in VR environment from our included Processing sketch to record and plot behavioral data. Licks, laps, and rewards are plotted per 30 sec time bins for the 30 min session during hidden reward spatial learning. Bottom panel shows the current mouse position (black) and the location of any reward zones (gray) during behavior.

3.3: HallPassVR GUI:

  • 3.3.1:

    Select and add four elements (images) from the listbox (or select pre-stored pattern, then click Upload) for each of the 3 patterns along the track, then click Generate. NOTE: new image jpegs can be placed in the folder HallPassVR/HallPassVR_wired/images/ELEMENTS before GUI is run.

  • 3.3.2:

    Select floor and ceiling images from dropdown menus, and set 2m for length of track for this example code (must equal trackLength in mm in behavior ESP32 code, and Processing code).

  • 3.3.3:

    Name this pattern if desired (will be stored in HallPassVR_wired/images/PATH_HIST).

  • 3.3.4:

    Click Start button (wait until VR window starts before clicking elsewhere).

  • 3.3.5:

    HallPassVR environment will appear on Screen #2 (projection screen, Fig. 3BC).

3.4: Run Processing sketch to acquire and plot behavioral data/movement.

  • 3.4.1:

    Open RecGraphSerialTxt_VR.pde in Processing IDE.

  • 3.4.2:

    Change animal = “yourMouseNumber”; variable, and set sessionMinutes equal to the length of the behavioral session in minutes.

  • 3.4.3:

    Click Run button on Processing IDE.

  • 3.4.4:

    Plot window will appear, showing current mouse position on virtual linear track, along with reward zones, and running histograms of licks, laps, and rewards updated every 30 seconds (Fig. 3D).

  • 3.4.5:

    A text file of behavioral events and times (usually <2MB in size per session) and an image of the final plot window (.png) will be saved when sessionMinutes has elapsed, or the user presses the ‘q’ key after clicking on the plot window to quit.

    Note: Due to the small size of the output .txt files, we estimate that at least several thousand behavior recordings can be stored on the Raspberry Pi SD card. Data files can be saved to a thumb drive for analysis or if connected to a local network, the data can be managed remotely.

3.5: Calibrate behavior track length with VR track length: Note: The code is currently calibrated for a 6” diameter running wheel using a 256-position quadrature rotary encoder, so the user may have to alter the VR and behavior code to account for other configurations. Behavioral position is however reset on each VR hall lap to maintain correspondence between the systems.

Step 4: Mouse training and spatial learning behavior.

Mice are implanted for head fixation, habituated to head restraint, then trained to run on the wheel and lick consistently for liquid rewards, progressively (“random foraging”). Mice achieving consistent running and licking are then trained on a spatial hidden reward task using HallPassVR where a single reward zone is present following presentation of a visual cue on the virtual linear track. Spatial learning is then measured as increased licking selectivity for positions immediately prior to the reward zone.

4.1: Headpost implantation surgery: This surgery can be done within 15–20 min/mouse for an experienced surgeon. This procedure is described in detail elsewhere in this journal and in others, so users may refer to this literature for specific instructions7,1721.

4.2: Water schedule: Water restriction is necessary to motivate mice to run on the wheel using liquid rewards, as well as to use spatial licking as an indication of learned locations along the track. Limit ad libitum water consumption to 5 min daily (or ultimately as rewards presented during behavior) and monitor weight and body condition daily for any signs of dehydration22 and to ensure that mice do not fall below 80% of their pre-restriction body weight.

Note: Institutional guidelines may differ on specific instructions for this procedure, so the user must consult their individual institutional animal care committees to assure animal health and welfare during water restriction.

4.3: Handling: Handle implanted mice daily to habituate them to human contact, following which limited ad libitum water may be administered as a reinforcement (1–5 min/day, 2 days – 1 week).

4.4: Habituation to head fixation: Habituate mice to head fixation for increasing amounts of time by placing them in the head restraint apparatus while rewarding them with occasional drops of water to reduce the stress of head fixation. Start with 5 minutes of head fixation and increase the duration by 5-minute increments daily until mice are able to tolerate fixation for up to 30 minutes. Remove mice from the fixation apparatus if they appear to be struggling or moving very little, however mice generally begin running on the wheel spontaneously within several sessions, and are ready for the next stage of training.

4.5: Run/lick training (random foraging): In order to perform the spatial learning task in the HallPassVR environment, mice must first learn to run on the wheel and lick consistently for occasional rewards. The progression in operant behavior is controlled via the behavior ESP32 microcontroller.

  • 4.5.1:

    Random foraging with non-operant rewards. Run HallPassVR GUI program with path of visual elements (user choice). Upload behavior program with multiple non-operant rewards (behavior ESP32 arduino code variables: isOperant=0, numRew=4, isRandRew=1) to condition mice to run and lick. Run mice with 20–30 min sessions until mice run for at least 20 laps per session and lick to rewards presented in random locations (1–4 sessions).

  • 4.5.2:

    Random foraging with operant rewards on alternate laps. Upload behavior program with altOpt=1 (alternating operant/non-operant laps) and train mice until they lick to both non-operant and operant reward zones (1–4 sessions).

  • 4.5.3:

    Fully operant random foraging. Upload behavior program with 4 operant random reward zones (behavior ESP32 arduino code variables: isOperant=1, numRew=4, isRandRew=1). By the end of this training step, mice should be running consistently and performing test licks over the entire track length (1–4 sessions).

4.6: Spatial learning: To perform a spatial learning experiment with a single hidden reward zone some distance away from a single visual cue, we selected a 2 m long hallway with dark panels along the track and a single high-contrast visual stimulus panel in the middle as a visual cue (0.9–1.1 m position), analogous to our recent experiments with spatial olfactory cues20. Mice are required to lick at a reward zone (at 1.5–1.8 m position), which is located a distance away from the visual cue in the virtual linear track environment.

  • 4.6.1:

    Run HallPassVR program with path of dark hallway with single visual cue in center (e.g. chessboard, see Step 3.3).

  • 4.6.2:

    Upload behavior program with single hidden reward zone to behavior ESP32 (behavior ESP32 arduino code variables: isOperant=1, numRew=1, rewPosArr[]= {1500}).

  • 4.6.3:

    Gently place mouse in head fixation apparatus, adjust lick spout to location just anterior to mouse’s mouth, and position mouse wheel into center of projection screen zone. The head of the mouse should be about 12–15 cm away from the screen after the final adjustments.

  • 4.6.4:

    Set animal name in Processing sketch, then press Run to start acquiring and plotting behavioral data (see Step 3.4).

  • 4.6.5:

    Run mice for 30 min sessions with a single hidden reward zone and single visual cue VR hallway.

  • 4.6.6:

    (Offline) Download .txt data file from Processing sketch folder and analyze spatial licking behavior (e.g., in Matlab with procVRbehav.m and vrLickByLap.m).

  • 4.6.7:

    Mice should initially perform test licks over the entire virtual track (“random foraging”), then begin to lick selectively only near the reward location following the VR visual cue (Figure 4).

Figure 4.

Figure 4.

Spatial Learning using the HallPassVR environment.

Representative spatial licking data from one animal during random foraging with random cues along the virtual linear track (A.), and two days of training with a static hidden reward zone at 1.5 m with a single visual cue in the middle of the track (B-C). A. Day 0 random foraging for 4 reward zones per lap, selected randomly from 8 positions spaced evenly along the 2 m virtual linear track. (left) Average number of licks per spatial bin (5 cm), over the 30 min session (top: VR hallway with random visual stimulus panels). (right) Number of licks in each 5cm spatial bin per lap during this session represented by a heatmap. B. Day 1, first day of training with a single reward zone at 1.5 m (red box on track diagram, top), using a virtual track containing a single high-contrast stimulus at position 0.8–1.2m. (left) Average spatial lick counts over the session showing increasing licks when the animal approaches the reward zone. (right) Spatial licks per lap, showing increased selectivity of licking in the pre-reward region. C. Day 2, from the same hidden reward task and virtual hallway as Day 1, from the same mouse. (left) Total licks per spatial bin showing a decrease in licks outside of the pre-reward zone. (right) Spatial licking per lap on Day 2, showing increased licking prior to reward zone and decreased licks elsewhere, indicating development of spatially specific anticipatory licking. This shows that this animal has learned the (uncued) hidden reward location and developed a strategy to minimize effort (licking) in regions where they do not expect a reward to be presented.

REPRESENTATIVE RESULTS:

This open-source virtual reality behavioral setup allowed us to monitor licking behavior as head restrained mice navigated a virtual linear track environment, in order to probe the cognitive process of spatial learning. Seven C57BL/6 mice from both sexes at four months of age were placed on a restricted water schedule and trained to lick continuously at low levels while running on the wheel for random spatial rewards (“random foraging”) without VR. Although their performance was initially affected when moved to the VR projection screen setup with a 2 m random hallway pattern, it returned to previous levels within several VR sessions (Fig. 4A). Mice that developed the random foraging strategy with VR (6/7 mice, 86%; one mouse failed to run consistently and was discarded) were then required to lick at an uncued operant reward zone 0.5 m following a single visual cue location in the middle of an otherwise featureless 2 m virtual track, in order to receive water rewards (“hidden reward task”). In our current pilot data with this system, 4/7 (57%) of mice were able to learn the hidden reward task with a single visual cue in 2–4 sessions, as shown by licking near the reward zone with increasing selectivity (Fig. 4B,C.), which is similar to our previous results with a non-VR treadmill (Turi, et al., 2019). This fact is important in the study of spatial learning, as it allows monitoring and/or manipulation of neural activity during critical periods of learning without extensive training. Furthermore, mice exhibited both substantial within-session as well as between-session learning (Fig. 4C), providing an opportunity to observe both short-term and long-term neural circuit adaptations that accompany behavioral learning. We did not test the learning rate of an equivalent non-VR task, however many classical real-world hippocampus dependent spatial tasks such as the Morris water maze require even more extensive training and present dramatically fewer behavioral trials, and are thus less suitable for monitoring of behavioral learning along with neural activity changes.

While a majority of mice in our pilot group (57%) were able to learn the hidden reward task in a small number of sessions, additional mice may exhibit spatial learning over longer timescales and individualized training should increase this fraction of mice. Indeed, variations in learning rate may be useful for dissociating the specific relationship between neural activity in brain areas such as the hippocampus and behavioral learning. However, we have observed that a small percentage of mice do not learn to run on the wheel or lick to either non-operant or operant rewards (1/7, 14%), and thus cannot be used for these experiments. Additional handling and habituation, and a reduction in the general state of stress of the animal through further reinforcement such as desirable food treats, may be useful for helping these animals adopt active running and licking during head-restrained behavior on the wheel.

By manipulating the presence and position of the cue and reward zones on intermittent laps on the virtual track, an experimenter may further discern the dependence of spatially selective licking on specific channels of information in VR, for example to determine how mice rely on local or distant cues or self-motion information to establish their location in an environment. Licking selectivity of mice that have learned the hidden reward location should be affected by the shift or omission of the visual cue along the track if they actively utilize this spatial cue as a landmark, as we have shown in recent work using spatial olfactory cues20. However even with the simple example we have presented here, the highly selective licking achieved by the mice (Fig. 4C., right) indicates that they are encoding the VR visual environment to inform their decision of where they are and therefore when to lick, because the reward zone is only evident in relation to visual cues in the VR environment. This VR system also allows presentation of other modalities of spatial and contextual cues in addition to the visual VR environment, such as olfactory, tactile, and auditory cues, which can be used to test selectivity of neural activity and behavior for complex combinations of distinct sensory cues. And although we did not test for dependence of task performance on hippocampal activity, a recent study using a similar task but with tactile cues has shown perturbation of spatial learning with hippocampal inactivation23, which should be confirmed for our VR hidden reward task.

DISCUSSION:

Critical Steps:

This open-source VR system for mice will only function if serial connections are made properly between the rotary and behavior ESP32 microcontrollers and Raspberry Pi single-board computer (Step 2), which can be confirmed using the Arduino IDE Serial Monitor (Step 2.4.5). For successful behavioral results from this protocol (Step 4), mice must be habituated to the apparatus and comfortable running on the wheel for liquid rewards (Steps 4.3–4.5). This requires sufficient (but not excessive) water restriction, as mice given ad libitum water in the homecage will not run and lick for rewards (i.e. to indicate their perceived location), and dehydrated mice may be lethargic and not run on the wheel. For the training procedure, animals that do not run initially may be given ad hoc (i.e. non-spatial) water rewards by the experimenter, or the wheel moved gently, to encourage locomotion. To develop random foraging behavior, mice that run but do not lick should be run with non-operant rewards (behavior ESP32 code: isOperant = 0;, Step 4.5.1) until they run and lick for rewards, then alternating laps of non-operant and operant reward zones (altOpt=1;, Step 4.5.2) until they start to lick on operant laps, before moving to fully operant random reward zones (Step 4.5.3).

Modifications and troubleshooting:

While we have provided complete instructions and example results for a basic set of experiments aimed at eliciting one form of spatial learning (conditioned licking at a hidden reward location in the virtual linear track environment), the same basic hardware and software setup can also be modified for delivery of more complex visuospatial environments using the pi3d Python package for Raspberry Pi. For example, our system can incorporate more complex mazes such as corridors with variable lengths, multiple patterns and 3D objects, and naturalistic VR environments. Furthermore, the behavioral software for delivery of water rewards and other non-visual stimuli can be modified for other training paradigms by altering key variables (presented at beginning of arduino behavior ESP32 code), or by inserting new types of spatial events into the same code. We are happy to advise users regarding methods for implementing other types of behavioral experiments with this VR setup, or in troubleshooting.

Limitations of the method:

Immersive virtual reality (VR) environments have proven a versatile tool for studying the underlying neural mechanisms of spatial navigation68, reward-learning behaviors9 and visual perception24 both in clinical and animal studies. The main advantage of this approach is that the experimenter has tight control over contextual elements such as visual cues and specific spatial stimuli (e.g., rewards and olfactory, auditory, or tactile stimuli), which is not practical in real-world environments experienced by freely-moving animals. It should be noted however that differences may exist in the manner in which VR environments are encoded by brain areas such as the hippocampus, when compared with the use of real-world environments 25. With this caveat, the use of VR environments allows experimenters to perform a large number of behavioral trials with carefully controlled stimuli, allowing dissociation of the contribution of distinct sensory elements to spatial navigation.

Significance of the method with respect to existing/alternate methods:

The complexity of building custom VR setups often requires an extensive background in engineering and computer programming which may increase the time of setup and limit the number of apparatus that can be constructed to train mice for experimentation. VR setups are also available from commercial vendors; however, these solutions can be expensive and limited if the user wants to implement new features or expand the training/recording capacity to more than one setup. The estimated price range of the open-source VR setup presented here is <$1000 (USD), however a simplified version for training (e.g., lacking goniometers for head angle adjustment) can be produced for <$500 (USD), allowing construction of multiple setups for training mice on a larger scale. The modular arrangement of components also allows the integration of VR with other systems for behavioral control such as the treadmill system with spatial olfactory stimuli we have used previously20, and are thus not mutually exclusive.

Importance and potential applications of the method in specific research areas:

This open-source VR system with its associated hardware (running wheel, projection screen, and head fixation apparatus), electronics setup (Raspberry Pi and ESP32 microcontrollers), and software (HallPassVR GUI and Arduino behavior code) provides an inexpensive, compact, and easy to use setup for delivering parameterized immersive VR environments to mice during head restrained spatial navigation. This behavior may then be synchronized with neural imaging or electrophysiological recording to examine neural activity during spatial learning (Step 2.3.7). The spectrum of experimental techniques the VR can be useful for is wide, ranging from spatial learning behavior alone to the combination with fiber photometry, miniscope imaging, single and multiphoton-photon imaging and electrophysiological techniques (e.g. Neuropixels). While head restraint is necessary for some recording techniques, the extremely precise nature of stimulus presentation and stereotyped nature of the behavior may also be useful for other techniques not requiring head fixation, such as miniscope imaging and fiber photometry.

Future improvements to the VR system will be uploaded to the project GitHub page (https://github.com/GergelyTuri/HallPassVR), so users should check this page regularly for updates. For example, we are in the process of replacing hardwired serial connections between the microcontrollers and Raspberry Pi with Bluetooth functionality native to the ESP32 microcontrollers already used in this design. In addition, we are planning to upgrade the HallPassVR GUI to allow specification of different paths in each behavioral session, containing different positions for key landmark visual stimuli on different laps. This will allow greater flexibility for dissociating the impact of specific visual and contextual features on the neural encoding of space during spatial learning.

ACKNOWLEDGMENTS:

We would like to thank Noah Pettit from the Harvey lab for discussion and suggestions while developing the protocol in this manuscript. This work was supported by a BBRF Young Investigator Award and NIMH 1R21MH122965 (G.F.T), in addition to NINDS R56NS128177 (R.H., C.L.) and NIMH R01MH068542 (R.H.).

Footnotes

A complete version of this article that includes the video component is available at http://dx.doi.org/10.3791/64863.

DISCLOSURES:

Clay Lacefield is the founder and maintainer of OpenMaze.org, which provides designs for the OMw PCB used in this protocol free for download through www.openmaze.org.

REFERENCES:

  • 1.Lisman J et al. Viewpoints: how the hippocampus contributes to memory, navigation and cognition. Nature Neuroscience. 20 (11), 1434–1447, doi: 10.1038/nn.4661, (2017). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 2.Buzsaki G & Moser EI Memory, navigation and theta rhythm in the hippocampal-entorhinal system. Nature Neuroscience. 16 (2), 130–138, doi: 10.1038/nn.3304, (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 3.O’Keefe J & Dostrovsky J The hippocampus as a spatial map. Preliminary evidence from unit activity in the freely-moving rat. Brain Research. 34 (1), 171–175, doi: 10.1016/0006-8993(71)90358-1, (1971). [DOI] [PubMed] [Google Scholar]
  • 4.O’Keefe J Place units in the hippocampus of the freely moving rat. Experimental Neurology. 51 (1), 78–109, doi: 10.1016/0014-4886(76)90055-8, (1976). [DOI] [PubMed] [Google Scholar]
  • 5.Fyhn M, Molden S, Witter MP, Moser EI & Moser MB Spatial representation in the entorhinal cortex. Science. 305 (5688), 1258–1264, doi: 10.1126/science.1099901, (2004). [DOI] [PubMed] [Google Scholar]
  • 6.Letzkus JJ et al. A disinhibitory microcircuit for associative fear learning in the auditory cortex. Nature. 480 (7377), 331–335, doi: 10.1038/nature10674, (2011). [DOI] [PubMed] [Google Scholar]
  • 7.Lacefield CO, Pnevmatikakis EA, Paninski L & Bruno RM Reinforcement Learning Recruits Somata and Apical Dendrites across Layers of Primary Sensory Cortex. Cell Reports. 26 (8), 2000–2008 e2002, doi: 10.1016/j.celrep.2019.01.093, (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 8.Dombeck DA, Harvey CD, Tian L, Looger LL & Tank DW Functional imaging of hippocampal place cells at cellular resolution during virtual navigation. Nature Neuroscience. 13 (11), 1433–1440, doi: 10.1038/nn.2648, (2010). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 9.Gauthier JL & Tank DW A Dedicated Population for Reward Coding in the Hippocampus. Neuron. 99 (1), 179–193 e177, doi: 10.1016/j.neuron.2018.06.008, (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 10.Rickgauer JP, Deisseroth K & Tank DW Simultaneous cellular-resolution optical perturbation and imaging of place cell firing fields. Nature Neuroscience. 17 (12), 1816–1824, doi: 10.1038/nn.3866, (2014). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 11.Yadav N et al. Prefrontal feature representations drive memory recall. Nature. 608 (7921), 153–160, doi: 10.1038/s41586-022-04936-2, (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 12.Priestley JB, Bowler JC, Rolotti SV, Fusi S & Losonczy A Signatures of rapid synaptic learning in the hippocampus during novel experiences. bioRxiv. 2021.2007.2002.450956, doi: 10.1101/2021.07.02.450956, (2021). [DOI] [Google Scholar]
  • 13.Heys JG, Rangarajan KV & Dombeck DA The functional micro-organization of grid cells revealed by cellular-resolution imaging. Neuron. 84 (5), 1079–1090, doi: 10.1016/j.neuron.2014.10.048, (2014). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 14.Harvey CD, Collman F, Dombeck DA & Tank DW Intracellular dynamics of hippocampal place cells during virtual navigation. Nature. 461 (7266), 941–946, doi: 10.1038/nature08499, (2009). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 15.Pettit N et al. Harvey Lab Mouse VR, <https://github.com/HarveyLab/mouseVR> (2021).
  • 16.Pettit NL, Yap EL, Greenberg ME & Harvey CD Fos ensembles encode and shape stable spatial maps in the hippocampus. Nature. 609 (7926), 327–334, doi: 10.1038/s41586-022-05113-1, (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 17.Turi GF et al. Vasoactive Intestinal Polypeptide-Expressing Interneurons in the Hippocampus Support Goal-Oriented Spatial Learning. Neuron. 101 (6), 1150–1165 e1158, doi: 10.1016/j.neuron.2019.01.009, (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 18.Ulivi AF et al. Longitudinal Two-Photon Imaging of Dorsal Hippocampal CA1 in Live Mice. Journal of Visual Experiments. (148), e59598, doi: 10.3791/59598, (2019). [DOI] [PubMed] [Google Scholar]
  • 19.Wang Y, Zhu D, Liu B & Piatkevich KD Craniotomy Procedure for Visualizing Neuronal Activities in Hippocampus of Behaving Mice. Journal of Visual Experiments. (173), e62266, doi: 10.3791/62266, (2021). [DOI] [PubMed] [Google Scholar]
  • 20.Tuncdemir SN et al. Parallel processing of sensory cue and spatial information in the dentate gyrus. Cell Reports. 38 (3), 110257, doi: 10.1016/j.celrep.2021.110257, (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 21.Dombeck DA, Khabbaz AN, Collman F, Adelman TL & Tank DW Imaging large-scale neural activity with cellular resolution in awake, mobile mice. Neuron. 56 (1), 43–57, doi: 10.1016/j.neuron.2007.08.003, (2007). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 22.Guo ZV et al. Procedures for behavioral experiments in head-fixed mice. PLoS One. 9 (2), e88678, doi: 10.1371/journal.pone.0088678, (2014). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 23.Jordan JT & Gonçalves JT Silencing of hippocampal synaptic transmission impairs spatial reward search on a head-fixed tactile treadmill task. bioRxiv. 2021.2009.2003.458092, doi: 10.1101/2021.09.03.458092, (2021). [DOI] [Google Scholar]
  • 24.Saleem AB, Diamanti EM, Fournier J, Harris KD & Carandini M Coherent encoding of subjective spatial position in visual cortex and hippocampus. Nature. 562 (7725), 124–127, doi: 10.1038/s41586-018-0516-1, (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 25.Ravassard P et al. Multisensory control of hippocampal spatiotemporal selectivity. Science. 340 (6138), 1342–1346, doi: 10.1126/science.1232655, (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]

RESOURCES