Skip to main content
eLife logoLink to eLife
. 2026 Mar 12;14:RP106033. doi: 10.7554/eLife.106033

Precision cutaneous stimulation in freely moving mice

Isobel Parkes 1, Ara Schorscher-Petcu 1, Qinyi Gan 1, Liam E Browne 1,
Editors: Theanne N Griffith2, Michael A Taffe3
PMCID: PMC12981839  PMID: 41817421

Abstract

Somatosensation connects animals to their immediate environment, shaping critical behaviors essential for adaptation, learning, and survival. Probing the relationships between somatosensory inputs and behavior in mice presents substantial challenges, primarily due to the practical difficulties of delivering stimuli to the skin during movement. To address this problem, we have developed a system for precise cutaneous stimulation of mice as they walk and run through environments. The system employs real-time body part tracking and targeted optical stimuli, offering precision while preserving the naturalistic context of the behaviors studied, thereby overcoming the traditional trade-offs between precision and animal behavior. We demonstrate the system from nociceptive testing conducted in standard small chambers to behavior in large complex environments, such as mazes. We observed that cutaneous inputs evoke rapid responses, which modify behavior when stimuli are applied during motion. This system provides a means to explore the diverse and integrative nature of somatosensation, from reflexes to decision-making, in naturalistic settings.

Research organism: Mouse

Introduction

Survival and adaptation are supported by the somatosensory system, which provides signals from the body surface to drive and refine behavior. It links the skin and central nervous system, recruiting reflexes and shaping behavior through learning and fine-tuning responses. For instance, a noxious stimulus at the skin should generate appropriate responses that minimize harm and increase the odds of survival. However, probing the somatosensory system in freely moving animals presents significant challenges due to the trade-offs between precision and preserving natural behavior.

Current methods for cutaneous stimulation usually necessitate direct physical contact, which restricts the range of behaviors and environments that can be studied. These methods often involve restraining animals or confining them to small chambers where stimuli are applied to their body. While valuable for understanding immediate responses, such approaches fail to capture the complexity of naturalistic behaviors. There is a growing need to study freely moving mice in dynamic, naturalistic environments (Juavinett et al., 2019; Datta et al., 2019; Dennis et al., 2021; Rosenberg et al., 2021; Zong et al., 2022), moving away from restraining and restricting behavior. However, delivering precise cutaneous stimuli to mice navigating complex settings, such as mazes, remains a significant challenge.

Experiments can proceed in more complex environments without researchers in proximity when cutaneous stimuli, such as electric shocks are delivered via a grid floor. This approach has contributed significantly to our understanding over decades, being used in learning studies to probe cells and circuits underpinning aversion, avoidance, fear, expectancy, and memory formation and retrieval. However, the underlying somatosensory processes cannot be resolved due to a lack of spatial precision and control—they indiscriminately stimulate multiple body parts in contact with the floor.

There have been attempts to bridge these gaps by applying localized cutaneous stimuli (e.g. von Frey filaments) to moving rodents. This has been shown to be useful in recent studies of circuits involved in pain processing (Cheng et al., 2017; Gangadharan et al., 2022). However, these approaches require experimenters to be in close proximity to the animals, to continuously observe their movements as they explore, and to manually touch a hind paw at regular intervals (LaBuda and Fuchs, 2000; Uhelski et al., 2012). This can cause observer bias and limit both precision and the complexity of the environments.

To address these challenges, we developed a closed-loop system to automatically deliver spatiotemporally precise cutaneous stimuli in a remote and dynamic manner, targeting mice as they freely explored environments. The system leverages advances in remote transdermal optogenetic stimulation (Schorscher-Petcu et al., 2021) and real-time markerless body part (keypoint) tracking (Kane et al., 2020). The approach moves away from restricted and restrained behavior to enable behaviorally relevant stimulation in more naturalistic environments (Dennis et al., 2021). This addresses the traditional trade-offs between precision and naturalistic environmental settings, providing a framework in which to integrate reflex recruitment, motivation, learning, and decision-making.

Results

To develop closed-loop cutaneous stimulation in mice exploring large environments, we built a system that could rapidly track and target mice and stimulate them remotely (Figure 1). We used real-time pose estimation to monitor body parts and target lasers for spatiotemporally precise thermal stimulation and optogenetic stimulation of genetically defined nociceptor fibers at the skin surface (Schorscher-Petcu et al., 2021; Kane et al., 2020). The approach was demonstrated in large environments, allowing automated cutaneous stimulation in an arena and during goal-directed behavior as mice run through a maze.

Figure 1. Closed-loop cutaneous stimulation of mice freely moving in naturalistic environments.

Figure 1.

(A) Mice can be remotely targeted with cutaneous stimuli while freely exploring complex environments, such as a maze. (B) Schematic illustrating the closed-loop control workflow. A freely moving mouse is recorded using a camera feed, enabling real-time pose estimation to track multiple body part keypoints. The extracted frame keypoint (x, y) of a selected body part is converted to pre-mapped x, y mirror galvanometer control signals to steer the laser beam paths and pulse the lasers. The movement of the galvanometer mirrors and triggering of the laser are determined by pre-programmed behavioral or environmental conditions, allowing stimulation to depend on behaviorally relevant states: for example, if the mouse was performing specific actions (running, sleeping, grooming, rearing) or making choices (turning right in a maze, exploring a specific area of the environment). Flexible, state-dependent laser targeting was accomplished using an infrared laser for thermal stimulation and a blue laser for optogenetic stimulation of genetically targeted primary afferent neurons, enabling high spatiotemporal control of stimulation to small areas of skin. Schematics in panel B were created using BioRender.com.

A system for closed-loop cutaneous stimulation

We designed a system that automatically tracks targets for cutaneous stimuli across a large environment, leveraging our laser-mirror galvanometer design (Schorscher-Petcu et al., 2021). The environment was built on a large glass platform, allowing us to record exploring mice from below with a camera (Figure 2A and B). The camera enabled real-time tracking with DeepLabCut-Live! (Kane et al., 2020), estimating the keypoints of multiple body parts for every frame of the camera feed. The target body part keypoint x and y coordinates were converted to pre-mapped control signals for x and y galvanometer mirrors to steer lasers as required. This provides a closed-loop system for dynamic control of stimuli according to behaviorally relevant criteria.

Figure 2. A system for closed-loop cutaneous stimulation.

(A) Rendering of the system shows camera and stimulation optics 1 m below the glass platform, accommodating a large circular arena (0.5 m diameter) for freely moving mice. (B) Side and aerial views. The blue laser beam (blue) was aligned to the galvanometer mirrors (GM) using mirrors (M1, M2), and lenses (L1, L2, L3) via ND filters. The infrared laser beam (red) is directed through a beam shutter with mirrors (M3, M4) and lens (L4). Converged beams in purple. (C) Average image of the laser across a linear voltage grid (left) and a pixel grid after mapping (left-middle). Pixel-voltage mapping corrects distortion (right-middle to right). (D) A mouse on the platform. (E) Tracking in the arena. (F) Galvanometer mirrors tracking the left hind paw keypoint. (G) 2D histograms of paw keypoints highlight the dwell of the locomotor stance phase compared to tail base motion. (H) Histogram of tail base speed indicating categories from four wild-type mice (16,000 frames). (I) Keypoint traces illustrating the out-of-phase swing-stance during locomotion. The left hind paw trace is shown in pink, while the right hind paw trace is shown in blue. The tail base speed is shown in orange. (J) Traces showing alternating left and right paw movement. (K) Accuracy of the laser targeting the hind paws across speed categories. (L) Error between the ground truth keypoint and laser spot in these same four mice, expressed as mean average Euclidean error (MAE). See also related Figure 2—figure supplements 1 and 2. Renderings were created using Solidworks.

Figure 2.

Figure 2—figure supplement 1. Spatial and temporal characterization of the closed-loop optical system.

Figure 2—figure supplement 1.

(A) Uniformity of laser spot area and optical power. Heatmaps of mean measurements taken from triplicate samples at 16 separate locations across the glass platform, and fit with a two-dimensional polynomial (area R2=0.91; power R2=0.75). (B) Galvanometer mirrors directed in a spiral formation across the glass platform. (C) The shift in the spatial calibration map was negligible as shown every week for 10 weeks during intensive use. Automatic remapping takes 30 min to complete. (D) The relative timings of the camera exposures (blue), mirror galvanometers (green), and laser (red). The acquisition frame time is shown in gray with corresponding galvanometer mirror jumps and laser pulse occurring around 80 ms later. (E) Histograms of the dwell time for hind paws spent in the swing and stance phases during locomotion. (F) Accuracy of the laser targeting the fore paws across the speed categories, which was limited by left-right confusion in the tracking of small body parts.
Figure 2—figure supplement 2. Hardware and software information flow design.

Figure 2—figure supplement 2.

Primary computer (C1) runs real-time pose estimation on the camera feed to predict multiple body part keypoints. These are converted to voltage signals at the DAQ device (DAQ1) to control the galvanometer mirrors (GM) to target the laser spot coordinates. C1 also sends a trigger to DAQ1 to trigger the blue light laser or the infrared laser shutter via an Arduino Uno (Arduino 2). To generate blue light pulse trains following a trigger, an Arduino was used (Arduino 1). The second computer (C2) interfaces with another DAQ device (DAQ2) to generate audio during experimental sessions. DAQ1 can also interface with DAQ2 to trigger audio depending on processor class conditions and for analog modulation of the blue light laser. The reward delivery system in Figure 4 is controlled via two Arduinos (Arduino 3 and 4) interfacing with DAQ1. Schematics were created using BioRender.com.

The system was optically precise. The glass platform was close to 1 m above the galvanometers, resulting in a maximum focal length variability of 3.49%, minimizing differences in the size of the laser spot in the stimulation plane. The absolute optical power and power density were uniform across the glass platform (coefficient of variation 0.035 and 0.029, respectively; Figure 2—figure supplement 1A). Laser power could be modulated using the analog control. The laser spot size was set to 2.00±0.08 mm2 (mean ± SD; coefficient of variation = 0.039) at the stimulation plane with a series of lenses along the blue light beam path (Schorscher-Petcu et al., 2021). The laser spot could be moved along specific trajectories creating patterns (Figure 2C, Figure 2—figure supplement 1B). We used 10,000 x and y voltage pairs to jump the laser across the stimulation plane and map the voltages to corresponding pixels (Figure 2C). Surface fits resulted in a pixel-voltage mapping dictionary that minimized non-linear distortions. This resulted in a mean average Euclidean error (MAE) of 1.2 pixels (0.54 mm) between predicted and actual laser spot locations in the 500 mm arena. The system and glass platform were stable, showing a displacement equivalent to about half the width of a hind paw (MAE = 1.94±2.61 mm) each week during intensive use of the system (Figure 2—figure supplement 1C), which can be corrected in less than 30 min by remapping.

The system could accurately target moving mice. Real-time estimation of keypoints (Figure 2D and E) was used for closed-loop control of the galvanometer mirror angles, resulting in pairwise correlations of r=0.999 between galvanometer coordinates and hind paw keypoints (Figure 2F). Thus, the laser could be targeted in real time to body parts when certain programmatic criteria were met (see Figure 2—figure supplement 2 for the information flow). For instance, the laser beam could be triggered if the distance of an individual keypoint moves with variance ≤v for time ≥t and keypoint estimation likelihood was ≥l, where v, t, and l are user-defined variables. To determine the targeting accuracy, we used wild-type mice that did not express ChR2 so that blue light pulses did not cause behavioral responses. The latency between acquiring a frame 1100×1100 pixels, estimating keypoints, and targeting a laser was 84±12 ms (mean ± SD using 16,000 trials across four wild-type mice; Figure 2—figure supplement 1D). This delay is sufficient to target paws: during locomotion, the hind paws were static for 350±44 ms in the stance phase and moving for 100±1 ms in the swing phase (Figure 2—figure supplement 1E). The positioning of paws during the stance phase of locomotion creates ‘footprints’ in keypoint space, indicating moments when the paws are momentarily static even as the mouse moves (Figure 2G).

Mice move around at variable speeds while exploring, which can be categorized (Figure 2H). During these movements, locomotor gait is defined by the coordinated sequence and timing of stance and swing phases across all four limbs. Each paw alternates between the stance and swing phase; thus, as the mouse moves forward, the individual paws are stationary during their respective stance phases. When the mouse was stationary (58±7% of the time), the hind paws were static in 99.8±0.1% frames, and this remains high even as the mouse increases its bodily speed: 95.7±0.1% frames for ‘low’ speed (28±4% of the time), 79.3±0.1% frames at ‘medium’ speed (8±2% of the time), and 60±0.3% at ‘high’ speed (6±1% of the time). Therefore, even during locomotion, the hind paws are static long enough for stimulation with short-latency body part tracking (Figure 2I and J). The laser was successfully targeted to the hind paws with a high ‘hit accuracy’ when the mouse was moving at low speeds (95.5±2.6%; Figure 2K). Hit accuracy refers to the percentage of trials in which the laser successfully targeted (‘hit’) the intended hind paw. As expected, the hit accuracy was reduced during high-speed running. We found zero keypoint confusion across all speeds, with 657 out of 657 trials successfully targeting the correct hind paw. The optical system targeted the hind paws of wild-type mice exploring an open arena 650±30 times within 5 min at 30 frames per second (fps, n=4 mice), providing multiple stimuli in short periods of time. We also targeted the forepaws, but confusion between them resulted in 5.7±2.2% targets being directed to the incorrect paw. This resulted in a low hit accuracy compared to the hind paws (Figure 2—figure supplement 1F). The laser spots were delivered with high accuracy to the targeted body parts, showing a small error of 1.3 mm MAE (Figure 2L). As laser targeting relies on real-time tracking to direct the laser to the specified body part, this metric includes any errors introduced by tracking and targeting. Thus, this design resulted in a fully automated system that facilitates spatiotemporally precise optical targeting of freely moving mice in a large environment.

Cutaneous stimulation in large environments drives behavioral responses

We next used the closed-loop system to automatically deliver optogenetic cutaneous stimuli and examine the resultant behavior. A large circular arena was chosen to encourage free exploration and movement (Figure 3A and B), and behavior was examined by pose estimation, reconstructing the movement trajectories of body parts in the arena (Figure 3C). Brief transdermal optogenetic stimulation of nociceptors was used to achieve minimal cutaneous stimulation: mice expressed the blue-light-sensitive opsin, ChR2, in nociceptors innervating the skin (Trpv1::ChR2; Schorscher-Petcu et al., 2021; Browne et al., 2017; Black et al., 2020). Mice explored the arena, and when stationary were stimulated on the hind paw with brief 10 ms pulses of light, delivered at intervals of at least 10 mins (Figure 3B). We found that the system accurately targeted the laser to the hind paw (Figure 3D).

Figure 3. Cutaneous stimulation in large environments drives behavioral responses.

Figure 3.

(A) Schematic of the open arena. (B) Protocol for minimal cutaneous stimulation using transdermal optogenetic activation of cutaneous nociceptors (Trpv1::ChR2, n=10 mice). (C) A single frame showing a mouse exploring the open arena (left). Keypoints for the left hind paw for 750 frames prior to and 1750 frames after the frame (1 min 23.33 s duration, middle). The body and head orientation at four time points are shown as orange rhombi connecting snout, left, and right forepaw, and tail base (middle). Keypoint skeletons (right). (D) Representative images of a 10 ms laser pulse spot targeting the plantar surface of the hind paw in littermate (top) and Trpv1::ChR2 (bottom) mice. (E) Representative keypoint traces during stimulation of the left hind paw for two mice (columns): five trials with one trial shown in bold across body parts (rows) for each mouse. (F) Example keypoint skeletons from Trpv1::ChR2 mice showing orienting behavior to hind paw stimulation (indicated by the blue arrow). Schematics in panel A were created using BioRender.com.

The precise cutaneous input gave rise to motor output as coordinated behavior in freely moving mice. The brief stimuli caused paw withdrawals along with coordinated whole-body behaviors, such as rapid head orientation and body repositioning (Figure 3E and F). These behaviors were quantified as time-locked keypoint traces for each body part (Figure 3E and F). Littermate control mice that do not express ChR2 did not exhibit responses to optogenetic cutaneous stimuli, including paw withdrawals or whole-body behaviors (n=10 mice). Therefore, the system enables fully automated and precise optical delivery of cutaneous stimuli to freely moving mice while simultaneously recording and quantifying behavior.

Multi-animal stimulation for automatic nociceptive testing

The system could deliver cutaneous stimuli across a large space, evoking behavioral responses. Next, we demonstrate the flexibility of the system design and establish automatic nociceptive testing across multiple mice simultaneously. A method for random-access targeting was developed (Figure 4A) to target nine mice (3×3 configuration) in individual chambers; we detected idle mice by analyzing motion energy in each chamber, then rapidly selected and cropped to one chamber for real-time pose estimation and stimulation (Figure 4B). This reduced the computational burden by decreasing image resolution, compared to running real-time pose estimation across the whole environment (Kane et al., 2020). The process operated as a loop, ensuring that automated stimuli were spaced by at least 1 min apart for each mouse.

Figure 4. Multi-animal stimulation for automatic nociceptive testing.

Figure 4.

(A) Concept of the random-access multi-animal stimulation. Motion energy was used to detect idle mice in multiple chambers, randomly selecting and cropping to one chamber for real-time pose estimation and stimulation. A laser spot was targeted to the hind paw of the mouse placed in the chamber. The process looped through each of the chambers, automatically targeting and stimulating the mice. (B) An example camera frame highlighting the chambers with different colors (left). Motion energy and body part keypoints shown for an individual chamber (right). (C) Representative paw responses and body repositioning following thermal stimulation (10 s pulse) and optogenetic stimulation (3 ms pulse). (D) Representative paw responses during thermal stimulation of wild-type mice. Two traces plotted with keypoints are shown. The gray dashed line indicates laser stimulation onset. (E) Raster plot of motion energy during thermal stimulation trials for 18 wild-type mice (315 trials), sorted by response latency. (F) Representative hind paw responses during optogenetic stimulation of Trpv1::ChR2 mice. The gray dashed line indicates stimulation onset. (G) Cumulative distribution of paw response latencies to thermal and optogenetic stimulation. Thermal: 18 wild-type mice, 315 trials. Optogenetic: 9 Trpv1::ChR2 mice, 181 trials (range of 15–24 trials for individual mice). Schematics in panel A were created using BioRender.com.

To test the system, we used: (1) thermal stimulation with a 10 s pulse of infrared light (785 nm) on the hind paw of wild-type mice; and (2) optogenetic stimulation of cutaneous nociceptors with a 3 ms pulse of blue light (473 nm) on the hind paw of Trpv1::ChR2 mice. We varied the intensity of the optogenetic stimuli using 10 Hz pulse trains (0.5–8 mW/mm2) compared to a single pulse at higher intensity (40 mW/mm2).

Thermal and optogenetic stimulation induced similar nocifensive behaviors, including paw responses and whole-body movements (Figure 4C). This can be seen from traces of hind paw movement following thermal or optogenetic stimuli (Figure 4D–F). Consistent with previous studies, we observed the whole-body behaviors, such as head orienting concurrent with local withdrawal (Browne et al., 2017; Blivis et al., 2017). In the case of thermal stimulation, we analyzed the local motion energy of the stimulated hind paw movements to quantify the response. Following stimulation onset, mice showed a mean response latency of 4.74±2.48 s (mean ± SD, 188 response trials; Figure 4E). Cumulative distributions further demonstrated nocifensive behaviors in response to infrared stimulation (Figure 4G) and illustrated the temporal resolution afforded by transdermal optogenetics compared to infrared stimulation. Optogenetic stimulation-induced response latencies followed the rank order of stimulus intensity, demonstrating the dynamic range possible with this system (0.5 mW/mm2: 2.98±3.19 s, 1.0 mW/mm2: 2.84±3.19 s, 2.0 mW/mm2: 1.69±2.14 s, 4.0 mW/mm2: 1.72±2.25 s, 8.0 mW/mm2: 1.51±2.19 s, 40.0 mW/mm2: 0.81±1.65 s, mean ± SD; Figure 4G). In contrast, littermate control mice did not exhibit responses (Schorscher-Petcu et al., 2021; Browne et al., 2017).

This demonstrates that the system is both versatile and precise, enabling the study of local paw withdrawals and whole-body movements, including head orientation and body repositioning. The platform is large enough to accommodate 25 mice (5×5 configuration) in a single session, allowing for high-throughput automated experiments.

Closed-loop cutaneous stimulation in mice running through a maze

We demonstrate that freely moving mice can be stimulated as they were running through a maze environment. The ability to deliver cutaneous stimuli to mice moving through behaviorally relevant tasks has previously been a significant challenge, and experimenters typically apply stimuli to moving mice manually (Cheng et al., 2017; Gangadharan et al., 2022; LaBuda and Fuchs, 2000; Uhelski et al., 2012).

To motivate movement in a task, we built a novel maze that encourages alternation between two rewards at separate locations. The maze had one-way doors, ensuring that after making a decision to turn left or right, mice could obtain a reward but are required to circle back to the maze’s start point to re-initiate the action-reward cycle (Figure 5A and B). The reward ports were activated by a brief nose poke and delivered a drop of sucrose water, followed by a timeout period. In addition to the timeout, the reward ports were only reset once the mouse exited the reward chamber through a one-way door, as determined by real-time keypoint tracking. The combination of a long timeout and required exit from the reward chamber rendered it more time-efficient to cycle between the two reward chambers and encouraged running along the corridors.

Figure 5. Closed-loop cutaneous stimulation in mice running through a maze.

Figure 5.

(A) Schematic of the maze design. A single trial was defined as the collection of a single reward, indicated by the orange and green arrows. The left and right corridors leading to the reward chambers were paired with stimulation of nociceptors using transdermal optogenetics. (B) Maze renderings from aerial, front, and side views. Mice entered via an entry chamber leading to a corridor and junction, choosing left or right through one-way doors. A sucrose-water reward awaited in the reward chamber, with exit through another one-way door. (C) Total number of rewards collected (left and right-hand side reward ports combined) for each training session. (D) Movement trajectories over an entire session (left) and a single trial (right). Trajectories are shown from one mouse for the first stimulation session. (E) Frame sequences (0.2 s apart) from four trials in four mice show runs along maze corridors toward the reward chamber. Blue arrows indicate targeted stimulation. (F) Relative timings of corridor entry and subsequent reward collection (n=4 mice). (G) Transition matrix showing mice predominately alternate between rewards at the left and right reward ports. (H) Example movement trajectories (tail base) in the left and right corridors from one mouse (left). Bar plots showing path coherence and speed in the high stimulation corridor relative to the low stimulation corridor (right). (I) Plot of speed and coherence in a 2 s window prior to the first stimulation in each trial colored by movement state cluster (Gaussian mixture modeling; 116 trials). (J) Speed and coherence relationships before and after stimulation, where the values of the prior state are colored and the responses are shown in black. The black lines pair values for each trial. Stimulation causes a consistent shift in the fast-direct state towards the slow-assess state, while stimulation of the slow-assess state shifts towards a direct movement. (K) Bar plots showing the change (post–pre) in speed and coherence. Stimulation resulted in changes in fast-direct trials (speed: Welch’s t=–6.90, p=0.006; coherence: Welch’s t=–9.39, p=0.003) and also slow-assess trials (coherence: Welch’s t=–26.9, p<0.0001). (L) Plot of post-pre stimulation speed values across all trials colored by state clusters. Schematics in panel A were created using BioRender.com. Renderings were created using Solidworks.

Mice were trained over three sessions in the maze. In the first training session, they rapidly navigated the one-way doors with little delay after a few attempts. This quickly led to the use of reward ports in the chambers on either side of the maze. The first reward was collected after 440±117 s (4 mice). By the third training session, this time decreased to 82±38 s, suggesting rapid learning. During the reward port timeout, mice typically explored the corridor connected to the reward chamber or exited it to explore the entry corridor. By the third day of training, the number of completed trials had increased for all mice. On average, mice completed 64±24 rewarded trials in the third training session (<2 hr in duration), although individual performance varied considerably. For example, one mouse completed only 10 rewarded trials in the third session, and another mouse completed 97 trials (Figure 5C).

Mice could be stimulated while they were running. Example movement trajectories from one mouse are shown in Figure 5D. Using Trpv1::ChR2 mice, we demonstrated the system’s utility in studying localized cutaneous hypersensitivity. We employed a widely used model of inflammatory pain with a unilateral injection of complete Freund’s adjuvant (CFA) in the hind paw. A brief (3 ms) nociceptive stimulus was successfully targeted to the contralateral (right, non-injected) paw with negligible confusion between paws (705/706 stimuli targeted the correct hind paw). This allows future studies in which phasic and tonic pain can be separated. Despite ongoing hypersensitivity and phasic stimuli, mice remained actively engaged in the task, collecting rewards sequentially from each side, as per their training (Figure 5F and G). Their rapid movement along the stimulation corridors (average maximum speed of 142±26 mm/s, 4 mice) required precise targeting (Figure 5E).

Stimulation during movement revealed a frequency-dependent disruption of path coherence and speed. High-frequency stimulation resulted in reduced locomotor speeds (p=0.037 with paired t-test, n=4 mice) and more variable trajectories compared to during low-frequency stimulation (Figure 5H). Once through the stimulation corridors, the mice successfully collected a reward in almost all trials.

We then examined how behavior depends on the behavioral state prior to stimulation. Before stimulation, two behavioral states were identified (Figure 5I): one represents faster locomotion in a direct heading (fast-direct state), while the other represents slower movements with headings that were less coherent (slow-assess state). The two clusters had significantly different speeds and coherence (p<0.0001 for both; Welch’s t-test), where the 79 fast-direct trials (68.1%) showed speed of 90.8±28.3 mm/s (mean ± SD) and coherence of 0.9±0.1 (mean ± SD; arbitrary units) and the 37 slow-assess trials (31.9%) had lower speed of 32.5±13.9 mm/s and less direct headings with a coherence of 0.1±0.1. Stimulation of the two states produced robust opposing changes in behavior (Figure 5J and K). Slow-assess states become significantly more coherent as the stimulus drives a redirection of heading. Fast-direct states were significantly slowed and less direct, potentially representing a pause for information gain. In this case, fast-direct states shift towards slow-assess, and slow-assess shifts towards fast-assess, where intermediate states may together represent a form of vigilant behavior. This demonstrates movement state-dependence changes behavior. Indeed, the speed after stimulation was proportional to the initial speed in the fast-direct trials; a positive linear correlation (Pearson’s r=0.23, p=0.046) indicates that the disruption of behavior partly scales with the initial movement state (Figure 5L).

We thus demonstrate automatic control of precise cutaneous stimuli as mice move through naturalistic environments.

Discussion

The somatosensory system provides a critical link between the brain, the body, and its immediate external environment. The complex ways in which this system supports movement, learning, and action in rodents have historically posed substantial methodological challenges. Traditional methodologies have varied widely, encompassing both innovative and practical approaches—from stimulation of whiskers or skin in head-fixed animals (Black et al., 2020; Pai et al., 2022; Buetfering et al., 2022; Guo et al., 2014; Hong et al., 2018; Campagner et al., 2019; Esmaeili et al., 2020; Schwaller et al., 2021; Emanuel et al., 2021) to the more straightforward manual touching of paws in mice (Cheng et al., 2017; Gangadharan et al., 2022; Uhelski et al., 2012; Gan et al., 2021). These approaches, however, have inherent limitations in replicating the dynamic and complex interactions experienced in naturalistic environmental settings. In response to these limitations, we have developed a system that enables cutaneous stimulation in more complex environments. This closed-loop system automatically tracks, targets, and stimulates mice remotely to study the somatosensory system in naturalistic environmental settings.

Generating cutaneous inputs in freely moving mice requires stimuli that are spatially and temporally precise. We achieved millisecond-timescale stimulation of small skin areas using transdermal optogenetics (‘remote touch’; Schorscher-Petcu et al., 2021). Opsins were genetically targeted to specific afferent fibers innervating skin and activated with light targeted precisely via a laser in free space. This beam path was aligned to a second laser system and employed for thermal stimulation on a timescale of seconds. Delivery of these stimuli was controlled by a feedback system consisting of three main components: (1) real-time tracking infers the keypoints of various body parts, continuously transmitting this data to the controller; (2) user-defined rules determine the stimulation conditions (spatial, temporal, and physiological state-dependence), providing control signals for the actuators; and (3) mirror galvanometers target the beam path to specified key points and signals trigger light delivery, following which real-time tracking is then resumed. The processing latency can be further reduced by minimizing the frame resolution, narrowing to a region of interest (ROI), increasing the processing power, using alternative networks, or combinations thereof. We demonstrate an approach to reduce the pixel count by cropping to an ROI using our random-access targeting method (Figure 4). One possible version of this would be centering a region on the mouse centroid as it moves. This would dramatically reduce the computational load to allow shorter processing latencies. With a reduced processing latency, high-speed video can be processed, which enables the approach to generalize to other body parts that move more rapidly. Additionally, predictive tracking can compensate for the remaining delay by estimating a keypoint location from its recent trajectory (e.g. constant-velocity extrapolation or a Kalman filter). This can reduce effective targeting error for continuously moving features, such as the snout. However, we demonstrate here that this system can precisely target the hind paw for stimulation, even as the mice are in motion.

We demonstrate the versatility of the system from automated multi-animal nociceptive testing to sparse stimulation of freely moving mice in a circular arena. We show that stimuli could be targeted with high accuracy and resulted in immediate behavioral responses that could be mapped. The system was used to deliver cutaneous stimuli to mice running through a maze. Mice were trained on an alternation task with stimuli applied en route to the reward, thus separating choice, punishment, and reward in a naturalistic environment. Mice with a model of inflammatory pain still readily engaged in this task during noxious cutaneous input (punishment). The recruitment of reflexes during locomotion caused immediate evaluative behavior that temporarily disrupted goal-directed behavior. Achieving such localized stimulation has been challenging with traditional methods: electric grid floors generate whole body stimuli that are considered incompatible with models of chronic pain that generate unilateral hind paw hypersensitivity; and manual stimulation lacks capacity, reliability, and is potentially confounded by experimenter and observer biases. Our system addresses these issues, allowing for the dissociation of touch, phasic pain, and tonic pain to better understand their relationships with behavior.

Stimulation of the body and paws enables the study of pain, touch, thermoception, and movement (Caterina et al., 1997; Decosterd and Woolf, 2000; Chiu et al., 2013; Ranade et al., 2014; Moy et al., 2018; Corder et al., 2019; Boyle et al., 2019; Juarez-Salinas et al., 2019; Choi et al., 2020; Gatto et al., 2021; Drake et al., 2021; Middleton et al., 2022). Paw stimulation is also ubiquitous in aversive learning and memory, using a crude shock stimulation with a grid floor (Klein et al., 2021; Bonapersona et al., 2022), and can now be carried out with spatiotemporal precision. The stimulation can be static or dynamic and localized to small areas on the body in an automated manner. Automation improves the precision of stimulus delivery compared to traditional manual methods; it reduces labor and enhances the reliability of the data. All experiments were conducted remotely from an adjacent room to minimize potential observer effects and biases on the mice. Automated nociceptive assays have principally focused on the initial rapid movements elicited by stimulation of mice in small chambers (Dedek et al., 2023; Iredale et al., 2023; Burdge et al., 2023). Here, we provide an approach to examine how these rapid movements are embedded within complex behavior in naturalistic environments, opening new ways to investigate nociception and somatosensation more broadly.

We have previously mapped fast behavioral responses in stationary mice, demonstrating that fast responses to noxious stimuli are not localized and fixed, but are widespread and contextual (Browne et al., 2017) and that these are coordinated where whole-body movements depend on the initial posture (Schorscher-Petcu et al., 2021). Here, we show state dependence of behavioral responses in mice that are moving, where noxious stimulation causes fast-direct moving mice to slow and mice already assessing their location to shift to a direct heading. This could be considered a state-dependent modulation or switching to a form of vigilance and suggests that even the most rapid protective responses are modulated online by the current movement state, ensuring behavior remains appropriate to context.

While we demonstrate the utility of the optical system using nociceptive stimuli, this system can deliver various cutaneous inputs by targeting specific afferents for selective opsin expression, whether they are thermoreceptive, chemoreceptive, or mechanosensitive (Schorscher-Petcu et al., 2021; Dedek et al., 2023; Iredale et al., 2023; Burdge et al., 2023; Mickle and Gereau, 2018). Such ‘pure’ stimuli do not occur in nature but offer crucial spatial, temporal, and genetic precision (Klein et al., 2021; Madden et al., 2016; Cheah et al., 2017). Our system enables delivery of multiple wavelengths of light separately or together, to support combinations of opsins from the vast optogenetic toolbox. Opsins can be used to activate or silence neurons, with a range of kinetic properties, diverse light wavelength profiles allowing multi-color manipulations, or control different downstream signaling effectors (Emiliani et al., 2022). Thermal stimuli are also used routinely in research (Pai et al., 2022; Dedek et al., 2023; Mitchell et al., 2010) but slow thermal dissipation can require mice to be stationary for consistent stimulation. Automation provides opportunities for the development of analgesics, particularly for integrating reflexes with spontaneous, free operant behaviors. Indeed, cutaneous stimulation in naturalistic environments can be readily combined with approaches to quantify behavior (Mathis et al., 2018; Jones et al., 2020; Wiltschko et al., 2020; Hsu and Yttri, 2021; Zhang et al., 2022; Weinreb et al., 2024; Bohic et al., 2023; Pereira et al., 2020).

The system has many applications for the study of sensorimotor transformations, perception, memory, learning, and action. It is flexible enough to trigger stimulation based on various states, including periods of inactivity or locomotion, at specific spatial locations and with precise timing. Future work made possible by this system is expected to include examining how cutaneous input can interrupt and modulate specific swing phases (Gatto et al., 2021), self-grooming, posture states (Browne et al., 2017), and other spontaneous behavioral syllables (Wiltschko et al., 2020). It can facilitate investigations of naturalistic learning, whether through mazes, social interactions, or engagement with the environment or objects (Choi and Kim, 2010; Lai et al., 2024), and of sleep fragmentation (Alexandre et al., 2024), anxiety (Orefice et al., 2019; La Vu et al., 2020), fear (Klein et al., 2021), and stress (Bonapersona et al., 2022). Finally, it has the potential to provide free operant methods for analgesic development for chronic pain. The system may be combined with existing tools to record neural activity in freely moving mice, such as fiber photometry, miniscopes, or large-scale electrophysiology, and manipulations of this neural activity, such as optogenetics and chemogenetics. This can allow mechanistic dissection of cell and circuit biology in the context of naturalistic behaviors.

Establishing how behavior is shaped by somatosensation requires that mice can be stimulated while freely behaving. We describe a system that addresses this need, delivering cutaneous stimuli in a manner that is precise, remote, state-dependent, dynamic, and fully automated to target freely behaving mice that are actively exploring complex environments.

Methods

Key resources table.

Reagent type (species) or resource Designation Source or reference Identifiers Additional information
Strain, strain background (Mus musculus) R26-CAG-LSL-hChR2(H134R)-tdTomato (Ai27D) Jackson Laboratory Stock #: 012567 RRID:IMSR_JAX:012567 PMID:22446880
Strain, strain background (Mus musculus) Trpv1-IRES-Cre (TRPV1-Cre) Jackson Laboratory Stock #: 017769 RRID:IMSR_JAX:017769 PMID:21752988
Strain, strain background (Mus musculus) Wild-type C57BL/6J Jackson Laboratory Stock #: 000664 RRID:IMSR_JAX:000664
Software, algorithm Python http://www.python.org/ RRID:SCR_008394
Software, algorithm NI-DAQmx https://nidaqmx-python.readthedocs.io
Software, algorithm Arduino C++ https://www.arduino.cc RRID:SCR_024884 Version 1.8.18
Software, algorithm DeepLabCut https://github.com/DeepLabCut RRID:SCR_021391 PMID:30127430 Version 2.2.0.2
Software, algorithm DeepLabCut-Live! https://github.com/DeepLabCut/DeepLabCut-live PMID:33289631
Version 1.0
Software, algorithm Basler Pylon https://www.baslerweb.com/en/software/pylon Version 6.2.4.9387
Software, algorithm Cobalt Monitor https://hubner-photonics.com/downloads/
Software, algorithm Thorlabs Kinesis https://www.thorlabs.com/kinesis-software
Software, algorithm Original code https://github.com/browne-lab/closed-loop-somatosensory-stimulation RRID:SCR_028036 See Data availability section
Software, algorithm Seaborn http://www.seaborn.pydata.org RRID:SCR_018132
Software, algorithm Adobe Illustrator http://www.adobe.com RRID:SCR_010279 Version 24.0

Animals

Mice were housed at 21±2°C, 55% relative humidity, following a 12 hr light: 12 hr dark cycle with ad libitum access to food and water. Optogenetic experiments were performed using mice with ChR2 selectively expressed in nociceptors (Trpv1::ChR2). Heterozygous Trpv1-IRES-Cre (TRPV1-Cre) mice, which have Cre recombinase inserted downstream of the Trpv1 gene (RRID:IMSR_JAX:017769, B6.129-Trpv1tm1(cre)Bbm/J; Cavanaugh et al., 2011), were crossed with mice homozygous for Cre-dependent ChR2(H134R)-tdTomato (RRID:IMSR_JAX:012567, Ai27(RCL-hChR2(H134R))/tdT-D ChR2-tdTomato; Madisen et al., 2012). This produced progeny heterozygous for both transgenes (Trpv1::ChR2) and control littermates that do not encode Cre recombinase but do encode Cre-dependent ChR2-tdTomato. Blue light directed to the glabrous plantar surface of the hind paw in Trpv1::ChR2 mice results in the direct time-locked activation of broad-class nociceptors with single action potential resolution (Browne et al., 2017). Experiments with the infrared (IR) laser were performed using wild-type mice (RRID:IMSR_JAX:000664, C57BL/6J). Equal numbers of male and female adult mice were used (aged between 6 and 40 weeks), with 2–5 cohorts of mice per experiment. Sample sizes reflected common practice in the field, and exact n is provided in figure legends. Conditions were randomized and experiments were performed blind to group allocation. Predefined exclusion criteria were applied only when stated (e.g. insufficient maze-task engagement). All animal work was carried out according to the UK Animal Scientific Procedures Act (1986), approved by the UCL Animal Welfare and Ethical Review Body (AWERB) and performed under licenses released by the UK Home Office.

Design and development

Several substantial improvements were made to the optical design (Schorscher-Petcu et al., 2021) to enable automated, multi-color, closed-loop optical stimulation across a large environment. Part lists are provided in Supplementary files 1–3.

The optical system was mounted on a large aluminum breadboard (0.75 m×0.75 m) to provide more space for optical components and stability to the large glass platform. The diode laser beam (blue light, 473 nm, Cobolt, 06–01 MLD) was focused to the center of the galvanometers using two broadband dielectric mirrors (M1 and M2) via an axial adjustable lens (L1, 30 mm focal length), a collimating lens (L2, 150 mm focal length), and a long focal length lens (L3, 500 mm focal length). We added a second laser beam path to enable multi-color stimulation, using separate mirrors and lenses and an appropriate dichroic mirror. The infrared (IR) laser (785 nm, SLOC, RLM785TA-1500) beam passed through an optical beam shutter (Thorlabs, SH05RM) to pulse the light with a controller (Thorlabs, KSC101). Two additional mirrors (M3 and M4) aligned the IR beam through a long focal length lens (750 mm) to the DM, where the beam path was aligned to converge with the blue light laser beam path into a pair of galvanometer mirrors (GM).

For the large environment, a 0.55 m×0.55 m glass stimulation platform was held in place above the optical components via a vertical optical construction rail (95 mm×95 mm×1500 mm) attached to the aluminum breadboard, as shown in Figure 2A. Aluminum construction rails (25 mm×25 mm× 500 mm) were secured at each corner of the glass platform frame and the opposite side of the platform to the optical rail to ensure stability. The blue light laser spot size (1/e2 width) was calibrated to 2.3 mm2 using the non-rotating L1 adjustable lens housing and an optical beam profiler (BP209-VIS/M, Thorlabs). For the experiment using the IR laser, two near-IR hot mirrors (Thorlabs, FM201) were placed on top of the USB 3.0 camera (acA1920-40um camera, Basler) lens to minimize how much IR light was imaged by the camera.

For real-time markerless pose estimation to support automated, closed-loop stimulation, an additional camera was positioned below the glass stimulation platform. Behavior was captured at 30 frames per second (fps) via a USB 3.0 to the primary computer (C1), which controls video recording, pose estimation, calculations, and directs the galvanometer mirrors to target lasers.

Optical system calibration

The optical parameters of the system were characterized using the blue laser due to the high-quality beam. The uniformity of blue light diode laser spot size across the glass stimulation platform was measured with an optical beam profiler (Thorlabs, BP209-VIS/M) placed at 16 locations across the platform. The beam profiler aperture was positioned at these locations using a custom laser-cut acrylic plate. Laser power was attenuated by 25% with an ND filter (Thorlabs, NE506B, optical density 0.6) to be within the operating range of the beam profiler. Absolute power (mW) at the 16 locations was assessed with a S121C photodiode measured by an optical power meter (Thorlabs, PM100D). The laser beam area and the optical power (mW) were calculated at each location (Figure 2—figure supplement 1A).

There was negligible distortion in the acquisition camera across the glass platform. This was determined by imaging a chessboard camera calibration pattern of 20 mm×20 mm squares in a 14×10 grid at five different locations across the glass. OpenCV was used to measure square sizes, and we calculated the min-max range of all squares was <1 pixel, at 0.89 pixels, which is considered negligible. The Euclidean norm was computed for a matrix of the corners of all squares, providing a scale factor of 0.45 mm/pixel.

To generate a pixel-voltage coordinate dictionary that can be used to convert x, y pixel coordinates to x, y galvanometer voltage coordinates, the following steps were carried out. First, the galvanometers were raster stepped to direct the blue laser spot to a grid of 10,000 points (100×100), capturing these with the pose-estimation camera. For every point of the raster, the x, y voltages were mapped to the peak intensity pixel. The x, y voltages were then computed for every pixel by interpolation, fitting with a two-dimensional polynomial equation. This automated procedure took <30 min and resulted in a pre-computed pixel-voltage dictionary. Entering an x, y coordinate for a body part, inferred from the camera feed, returns the interpolated x, y voltages to target the laser to the same location. We repeated the mapping once every week over the course of 10 weeks to ensure the stability of the mapping. This was done during extensive experimentation to account for potential movements during cleaning and changes in arenas.

Pose estimation

Training a DeepLabCut network model

DeepLabCut installation (v2.2.0.2; Mathis et al., 2018; Nath et al., 2019) was coupled to TensorFlow-GPU (v2.5.0, with CUDA v11.2 and cuDNN v8.1). Training of the DeepLabCut neural network model was used with default network and training settings in an Anaconda environment with Python v3.8.13 installed. Videos were selected based on their representation of the whole breadth of behavioral responses, and k-means clustering was used to select the training images. 437 frames were labeled from 22 selected videos, and the network was trained for 200,000 iterations. Following further optimization of lighting, 210 frames from 11 additional videos were manually labeled, and machine labels from 171 outlier frames from nine videos were manually refined. These were fed back to the training dataset and the network retrained for a further 200,000 iterations. Training resulted in an MAE of 3.29 pixels, which is comparable to human ground truth variability quantified elsewhere (see Mathis et al., 2018). This model was used for all pose estimation. The video resolution (1920×1200) required a processing time longer than the frame interval (33.33 ms), resulting in real-time pose estimation on a sub-sample of all frames recorded. Therefore, post-hoc pose estimation was carried out to analyze all frames.

Real-time tracking

DLC-Live! SDK (v1.0; Kane et al., 2020) was installed on a computer with fast processing capabilities (AMD Ryzen 5 3600 six-core CPU (3.6–4.2 GHz), NVIDIA GeForce RTX 2080 Ti GPU, 64 GB RAM, Windows 10, custom manufactured by PC Specialist Ltd.) in an Anaconda virtual environment (Python v3.7.10) with DeepLabCut (v2.1.10.4) installed. DLC-Live! SDK installation was coupled to TensorFlow-GPU (v1.13, with CUDA v10 and cuDNN v7.4). Integration of the Basler camera and the DLC-Live! GUI (DLG) utilized a Python wrapper, pypylon (v1.7.2, Basler), to facilitate communication with the pylon Camera Software Suite through a Linux subsystem in Windows 10 (WSL Ubuntu, v20.04). The trained DeepLabCut network model was loaded into the DLG, which captures the data from the camera and performs real-time pose estimation on the incoming camera feed. Custom code was written in Python for each experimental design; this comprised the conditions that defined the behavioral protocol and controlled stimulation as required (see Figure 2).

Optical system characterization

We characterized the latencies for real-time tracking, targeting, and stimulation. Control signals for the camera, mirror galvanometers, and laser were measured simultaneously at 100 kHz using a Digidata 1440 a (Molecular Devices). During the exposure of each 5 ms frame, the tracking camera sent a voltage signal from its GPIO. The x- and y-axis scanner position outputs from the two mirror galvanometer drivers were used to monitor the movement of the mirrors. A 1 ms laser signal was sent to a microcontroller (Arduino Uno) to generate parallel digital outputs, which triggered the laser and monitored its timings. All four control signals were recorded during four 5 min sessions with wild-type mice (C57BL/6J) exploring a circular arena. The tracking camera was set to record at a resolution of 1100 pixels×1100 pixels, with a 5 ms exposure at 30 fps. The processor code identified frames with a likelihood >0.8 for the ‘left_hindpaw_mid’ keypoint. The x, y pixel location was then converted to mirror galvanometer x, y voltage signals using a pixel-voltage coordinate dictionary. A multifunction DAQ device (USB-6002, National Instruments) was used to send these x, y voltages and subsequently send a 1 ms command to the laser-triggering microcontroller. The laser was triggered only if more than 500 ms had passed since the previous stimulation. The camera signal confirmed an exposure time of 5 ms and a frame rate of 30 fps. The latency between camera acquisition and stimulation was calculated by collecting timestamps immediately after stimulation (acquisition timestamp) and comparing these to the frame timestamp on which pose estimation was carried out (processing timestamp). We estimated a processing latency of 84±12 ms (mean ± SD) by subtracting the frame acquisition timestamp from the frame processing timestamp contained in DeepLabCut output files for 16,000 processed frames recorded across four mice (4000 frames each). The latency between galvanometers moving and laser stimulation was determined by comparing the timings of galvanometer jumps and laser signals. This delay was 3.3±0.5 ms (mean ± SD, for 245 trials). To synchronize the four voltage signals with frame and stimulation timestamps, we determined the timing of the first galvanometer jump when pose estimation was initialized. In the current configuration, the end-to-end closed-loop delay is 87 ms from the combination of the processing latency and other delays.

The accuracy of real-time tracking for the ‘left_hindpaw_mid’ keypoint was assessed by manually identifying its coordinates (ground truth) and comparing these to the coordinates predicted by the DeepLabCut network model in real time on frames extracted from five videos of different mice exploring an open arena. Frames with a likelihood >0.8 were selected, as in experimental protocols. Euclidean distances were calculated pairwise between ground truth coordinates and model-generated coordinates and averaged to give the mean average Euclidean error (MAE). The MAE between the predicted and actual coordinates was 1.36 mm (calculated on 1281 frames).

The accuracy of body part targeting was determined using a high-speed Basler acA2000-165μm NIR camera recording frames at 648×650 pixels, 270 fps during the 5 min sessions described above. We used a>0.8 likelihood for the ‘left_forepaw’ keypoint in additional sessions. High-speed recordings captured each 1 ms laser pulse, and frames containing these pulses were identified using the reflection of the laser. We manually assessed 1279 frames and classified them as a ‘hit’ or ‘miss,’ and whether a ‘hit’ was on the targeted paw to quantify confusion during keypoint tracking.

The accuracy of hitting the body part depended on how fast the mice were moving. To demonstrate this, we segmented the keypoint series using four speed categories: stationary, low, medium, and high. Speed was calculated using the Euclidean distance the ‘tail_base’ keypoint moved in each frame, dividing this by the time elapsed and smoothing the speed with a 10-frame rolling mean filter. The speed histogram informed the windows of categories (<20, 20–120, 120–220, >220 pixels per second, for stationary, low, medium, and high, respectively). The accuracy of hitting the ‘left_hindpaw_mid’ keypoint was calculated on frames across each speed category: 156 frames for stationary, 159 frames for low, 155 frames for medium, and 187 frames for high. Similarly, the accuracy of hitting the ‘left_forepaw’ keypoint was calculated on 155 frames for stationary, 156 frames for low, 155 frames for medium and 156 frames for high.

The error between the ground truth keypoint and the laser spot for the ‘left_hindpaw_mid’ keypoint was determined by manually identifying the body part coordinates (ground truth) on frames immediately prior to stimulation and then the coordinates for the laser spot on subsequent stimulation frames. These estimates were first made for all pre-stimulation frames and then for the set of stimulation frames. The mean average Euclidean error (MAE) was approximately 1.3 mm across all locomotion speed categories (463 frames).

Multi-chamber real-time pose estimation

To target and stimulate individual mice when multiple mice were present in chambers on the stimulation platform, we performed chamber-based cropping and subsequent real-time pose estimation. Nine mice were placed into nine chambers (100 mm×100 mm wide, 120 mm tall). We monitored the motion in each chamber to find mice that were ‘idle’. The camera feed was cropped, body parts estimated, and the laser targeted to the hind paw coordinates.

The frame-to-frame absolute difference in pixel values (motion energy) was calculated in each region of interest for the individual chambers. Background noise was removed below <10 motion energy, and the mouse was defined as ‘idle’ if the summed motion energy was less than a specified threshold (30,000 motion energy) for 2 s. Idle mice that had not been stimulated in the previous 10 s were pseudo-randomly selected and their chamber cropped. The pose estimation (x, y) coordinates generated by the DeepLabCut network model were used to target the laser to the hind paw. We modified the following scripts in the dlclive and dlclivegui packages in DLC-Live! SDK to develop the multi-chamber real-time tracking approach: dlclive, utils (dlclive package) and pose_process (dlclivegui package).

Assembly of a naturalistic task

The maze was constructed of 3 mm matte black acrylic (200 mm in height) and measured 500 mm×180 mm (inner dimensions). The maze was constructed as a single junction, with 40 mm width corridors forming two chambers (70 mm×100 mm) at either end of the junction corridors. The entrance to the maze was connected to a transparent acrylic chamber (100 mm×100 mm, 130 mm tall). There were one-way doors (100 mm tall, 30 mm wide) designed as a push-through flap cut from 0.5 mm styrene and secured to the door frame with butterfly pins. The one-way doors were positioned at the junction and to leave the reward chambers; this created a one-way system, so once the mouse exited either chamber, it was required to go back around the maze and through the junction decision point to re-enter the reward chamber. Each chamber contained a rectangular opening (20.5 mm×11.5 mm) through which a water delivery port (Sanworks mouse behavior port) was fixed to the walls to allow the mouse to collect rewards. A water reward (~5 µl of 10% sucrose water) was delivered when the mouse’s nose broke the IR beam in the water delivery port. The reward delivery system was controlled with an Arduino. In addition to a reward timeout period of 45–60 s, the mouse was required to leave the chamber before the water reward port was reset and another reward could be collected.

Behavioral protocols

Experimental room, arena, and cleaning set-up

The experimental room was maintained at 21°C with relative humidity between 45–65%. All behavior experiments on the system were performed in custom-built arenas laser cut from matte black acrylic and placed on the glass stimulation platform. Two infrared LED panels illuminated opposite sides of the arena to optimize lighting and achieve high-contrast images. White noise at 68 dB was generated with custom Python code, through a L60 Ultrasound Speaker (Petterson Elektronic AB) via a second DAQ device (USB-6211, NI) and amplifier. The white noise played continuously through the duration of the habituation sessions and the experiment. The glass stimulation platform was cleaned twice with 70% ethanol, while the acrylic arena was cleaned twice with an odorless surface disinfectant between each animal to minimize olfactory cues. The lasers were targeted to the hind or fore paw glabrous skin in all experiments, contingent on meeting specific conditions defined in the protocol.

Habituation

Animals were placed in custom matte black acrylic chambers (100 mm×100 mm, 80 mm in height) placed on a von Frey wire mesh grid and underwent two habituation sessions to the experimental room for 1–2 hr. Mice also underwent 1 or 2 handling sessions prior to experiments.

Minimal cutaneous stimulation in an open arena

Mice were placed in an acrylic arena painted matte black (500 mm outer diameter, 150 mm in height, 5 mm thick). Dividers (160 mm tall, 116 mm wide, matte black, 3 mm thick) were slotted onto the arena wall to separate the arena into six segments to enrich the environment. Mice were allowed to freely explore for 60 min. Individual 10 ms duration blue light laser pulses were remotely targeted to the left hind paw with a≥10 min inter-stimulus interval. Each stimulation was delivered contingent on the conditions that the hind paw was still and had not been stimulated within the previous 10 min.

The hind paw was considered still when both the standard deviation of its keypoint (x, y) was <1 pixel and the likelihood of this keypoint was >0.8 throughout a 2 s period. Stimulation was repeated over two sessions on consecutive days. Data were collected from 26 mice in total from five different cohorts. 16 Trpv1::ChR2 mice were split into two groups: 10 mice received blue light stimulation, and 6 mice received no stimulation as a control. Ten littermate controls that received blue light stimulation were also used.

Somatosensory stimulation in multiple chambers

Nine mice were placed in 100 mm x 100 mm individual chambers in a 3×3 configuration, covered by a lid. Mice were habituated to the chambers atop the glass stimulation platform for 2 hr in two sessions prior to the first experimental day.

For the experiment with thermal stimulation, 18 C57BL/6J mice from 2 cohorts were used. Mice were placed in the chambers for 2 hr, and a 10 s laser pulse was targeted to one of the hind paws, with up to 10 stimulations on each paw >1 min apart. IR laser spot size was 2.2 mm2 and the optical power was set to 1.4 W in the first cohort of mice and to 1.65 W in the second cohort of mice to elicit paw responses between 10–12 s.

For the experiment with transdermal optogenetic stimulation, 9 Trpv1::ChR2 and 9 littermate controls from two cohorts were used. Mice were similarly placed in the chambers for 2 hr, with optogenetic stimulations delivered to each hind paw >1 min apart. The stimulation protocol comprised six conditions: a single pulse stimulation at 40 mW/mm2, and a train of pulses (3 ms pulses at 10 Hz for 10 s) at 8, 4, 2, 1, and 0.5 mW/mm2. Spot size was 2.0 mm2. The order of stimulation intensity was pseudorandomized with Euler tours (Bakermans and Behrens, 2021).

Somatosensory stimulation in a maze

Mice were first habituated to the maze without any doors during a 1 hr session. On three separate days following this, they underwent 3 training sessions with the one-way doors in place. Mice were water-deprived 16–18 hr prior to each experimental session to motivate the use of water rewards. A trial was defined as the mouse successfully collecting one reward; the collection of multiple rewards required the mouse to leave the reward chamber. Mice that had not made >10 trials by the third training session were excluded from the subsequent stimulation sessions due to poor engagement. Seven out of 12 Trpv1::ChR2 mice from four cohorts met this criterion. As proof of principle for precise contralateral stimulation in the context of a unilateral pain state, mice received 7 µl of complete Freund’s adjuvant (CFA) via intraplantar injection in the left hind paw. CFA-injected mice showed significant mechanical allodynia compared to saline controls (p=0.039 with the Mann-Whitney test, n=4 mice). After baseline measurements of mechanical sensitivity, mice were injected with CFA, and mechanical allodynia was evaluated in both hind paws 2 days following injection. Mechanical allodynia resulting from injection of CFA into the left hind paw was measured by von Frey testing (Up-Down method). Mice were placed in individual chambers (100 mm×100 mm) on a mesh wire floor and habituated to the test setup prior to testing. The von Frey test was conducted blind to experimental groups. Mice underwent two stimulation sessions in the maze, in which optogenetic stimuli were delivered to the right (uninjected) hind paw in the stimulation zones. There were two stimulation protocols: the left corridor was paired with 3 ms laser pulses at 5 Hz and the right corridor was paired with 3 ms laser pulses at 1 Hz. Laser power density was 40 mW/mm2. Training and experimental sessions lasted 1–2 hr.

Data analysis

Data compression, analysis, and visualization

Videos were acquired in AVI format and fed through offline DeepLabCut pose estimation to generate (x, y) coordinates and likelihoods for each body part. For the analysis of the recordings with multiple chambers, AVI video files were converted to MP4 format using H.264 compression. The MP4 video files were cropped into individual mouse chambers (230×230 pixels) before running pose estimation. Analyses were based on the position of the hind paw or tail base coordinates. All analysis code was written in Python 3 (v3.9.7), using the NumPy, Pandas, and OpenCV packages. Data was visualized using Matplotlib and Seaborn packages.

Calculation of paw response latency with motion energy

Local motion energy was calculated inside a circular ROI (radius = 15 px) centered on the stimulation-side paw keypoint by taking absolute differences between consecutive frames, masking the ROI, suppressing values <3 intensity units, and summing the remaining pixels. The ROI center was anchored to the DLC keypoint at the frame immediately before the nominal stimulation onset. The nominal stimulus time was refined per trial by locating the largest motion-energy peak within ±0.2 s of nominal onset; traces were then time-locked to this real onset and re-windowed from –9.8 to +9.8 s, with the single-frame flash artifact at t=0 set to zero. Motion-energy traces used for detection were denoised with a 3-sample median followed by a 7-sample Gaussian (σ=2) before thresholding. Trials with threshold crossings in the 0–1.5 s window were not considered sufficiently idle. A trial was considered a response if the stimulation-paw motion energy first exceeded a fixed threshold (1000 summed units) within the analysis window of 1.5–9.8 s. Response latency was defined, for responding trials, as the time of the first threshold crossing within this window minus the refined onset time.

Calculation of paw response latency with pose estimation

We calculated the Euclidean distances for the paw keypoint during the trial window (–2 to +10 s; optogenetic stimulus at t=0) relative to its mean baseline coordinate (2–0 s). Analysis was conducted on the keypoint on the hind paw toes to reduce stimulation artifacts from light delivered to the center of the hind paw using coordinates with >0.8 likelihood values. If the keypoint moved more than three pixels within the stimulation trial window, the trial was classified as a response. For the responses, the latency was determined by taking the time where the movement first exceeds three pixels, relative to the stimulation onset time.

Calculation of speed

The estimated tail base coordinates were used to visualize trajectories in the open arena and maze. These estimated coordinates were used if the likelihood >0.8 (open arena) and >0.85 (maze). Tracking errors were removed when the Euclidean distance jumped >30 pixels in a single frame, and linear interpolation was performed using the three frames either side of the removed values. Speed was calculated by taking the difference in Euclidean distance (∆d) between frames as a function of the respective difference in frame times (∆t) and converted to mm/s using the scale factor calculated above. To reduce frame-to-frame jitter and suppress tracking noise while preserving changes in movement, the speed trace was smoothed using a rolling median filter with a window of 10 samples. For the maze, we calculated the speed (vigor) by capturing each ‘corridor run’ from the point the tail base entered the corridor to when it exited the corridor. Speed for the corridor run was calculated within this time window as above.

Calculation of movement state dependence

Movement state clusters (fast-direct and slow-assess) were identified from tail-base speed and heading coherence in the 2 s window prior to stimulation. Speed was determined as Euclidean displacement divided by the frame interval, smoothed with a 10-frame rolling median, and the mean over the 2 s window was taken. Heading coherence was calculated from the frame-to-frame heading angle of the tail-base keypoint: headings were circularly smoothed by averaging unit vectors over a 10-frame window, and coherence was defined as the mean resultant length (R, 0–1) over the 2 s window. Plotting speed and coherence for the first stimulus hit in each trial revealed two discrete populations, consistent across all four mice. Gaussian mixture modeling assigned trials to two clusters whose speed and coherence differed significantly. Taking speed and coherence in the 2 s post-stimulation window allowed paired analysis within trials to evaluate how the behavioral change depends on its prior state.

Statistical analysis

Statistical analysis was performed in Python, with the SciPy, Statsmodels, and Pingouin packages. Normality was determined using the Shapiro-Wilk normality test. The specific tests used for each comparison are detailed in the text. Statistical significance was considered as p<0.05. Data are reported as mean ± standard error of the mean (SEM) unless stated otherwise. The mouse was the experimental unit.

Materials availability

System configurations will be made available upon reasonable request to L.E.B.

Acknowledgements

We are grateful to Patrick Haggard and Andrew MacAskill for their comments on the initial manuscript. This work was supported by a Sir Henry Dale Fellowship jointly funded by the Wellcome Trust and the Royal Society (109372/Z/15/Z) and funding from the Medical Research Council (MR/N013867/1).

Funding Statement

The funders had no role in study design, data collection and interpretation, or the decision to submit the work for publication. For the purpose of Open Access, the authors have applied a CC BY public copyright license to any Author Accepted Manuscript version arising from this submission.

Contributor Information

Liam E Browne, Email: liam.browne@ucl.ac.uk.

Theanne N Griffith, University of California, Davis, United States.

Michael A Taffe, University of California, San Diego, United States.

Funding Information

This paper was supported by the following grants:

  • Wellcome Trust and the Royal Society 10.35802/109372 to Liam E Browne.

  • Medical Research Council MR/N013867/1 to Isobel Parkes.

Additional information

Competing interests

No competing interests declared.

Author contributions

Data curation, Software, Formal analysis, Validation, Investigation, Visualization, Methodology, Writing – original draft, Writing – review and editing.

Methodology, Writing – review and editing.

Methodology, Writing – review and editing.

Conceptualization, Resources, Software, Formal analysis, Supervision, Funding acquisition, Validation, Investigation, Visualization, Methodology, Writing – original draft, Project administration, Writing – review and editing.

Ethics

All animal work was carried out according to the UK Animal Scientific Procedures Act (1986), approved by the UCL Animal Welfare and Ethical Review Body (AWERB) and performed under licenses released by the UK Home Office.

Additional files

Supplementary file 1. Optics.

This table details the optical components for the assembly of the system.

elife-106033-supp1.docx (18.6KB, docx)
Supplementary file 2. Mounting components.

This table details the parts for mounting optics in the system.

elife-106033-supp2.docx (17.3KB, docx)
Supplementary file 3. Acquisition and control components.

This table details the parts for acquisition and control.

MDAR checklist

Data availability

The manuscript is a Tools and Resources study that provides a new method. Code to use this method is openly accessible at https://github.com/browne-lab/closed-loop-somatosensory-stimulation (Parkes et al., 2026). Data is available on Dryad at https://doi.org/10.5061/dryad.rr4xgxdhs.

The following dataset was generated:

Parkes I, Schorscher-Petcu A, Gan Q, Browne LE. 2026. Precision cutaneous stimulation in freely moving mice. Dryad Digital Repository.

References

  1. Alexandre C, Miracca G, Holanda VD, Sharma A, Kourbanova K, Ferreira A, Bicca MA, Zeng X, Nassar VA, Lee S, Kaur S, Sarma SV, Sacré P, Scammell TE, Woolf CJ, Latremoliere A. Nociceptor spontaneous activity is responsible for fragmenting non-rapid eye movement sleep in mouse models of neuropathic pain. Science Translational Medicine. 2024;16:eadg3036. doi: 10.1126/scitranslmed.adg3036. [DOI] [PMC free article] [PubMed] [Google Scholar]
  2. Bakermans JJW, Behrens TEJ. Controlling precedence in sequential stimulus presentation with euler tours. PsyArXiv. 2021 doi: 10.31234/osf.io/y8r6k. [DOI]
  3. Black CJ, Allawala AB, Bloye K, Vanent KN, Edhi MM, Saab CY, Borton DA. Automated and rapid self-report of nociception in transgenic mice. Scientific Reports. 2020;10:13215. doi: 10.1038/s41598-020-70028-8. [DOI] [PMC free article] [PubMed] [Google Scholar]
  4. Blivis D, Haspel G, Mannes PZ, O’Donovan MJ, Iadarola MJ. Identification of a novel spinal nociceptive-motor gate control for Aδ pain stimuli in rats. eLife. 2017;6:e23584. doi: 10.7554/eLife.23584. [DOI] [PMC free article] [PubMed] [Google Scholar]
  5. Bohic M, Pattison LA, Jhumka ZA, Rossi H, Thackray JK, Ricci M, Mossazghi N, Foster W, Ogundare S, Twomey CR, Hilton H, Arnold J, Tischfield MA, Yttri EA, St John Smith E, Abdus-Saboor I, Abraira VE. Mapping the neuroethological signatures of pain, analgesia, and recovery in mice. Neuron. 2023;111:2811–2830. doi: 10.1016/j.neuron.2023.06.008. [DOI] [PMC free article] [PubMed] [Google Scholar]
  6. Bonapersona V, Schuler H, Damsteegt R, Adolfs Y, Pasterkamp RJ, van den Heuvel MP, Joëls M, Sarabdjitsingh RA. The mouse brain after foot shock in four dimensions: temporal dynamics at a single-cell resolution. PNAS. 2022;119:e2114002119. doi: 10.1073/pnas.2114002119. [DOI] [PMC free article] [PubMed] [Google Scholar]
  7. Boyle KA, Gradwell MA, Yasaka T, Dickie AC, Polgár E, Ganley RP, Orr DPH, Watanabe M, Abraira VE, Kuehn ED, Zimmerman AL, Ginty DD, Callister RJ, Graham BA, Hughes DI. Defining a spinal microcircuit that gates myelinated afferent input: implications for tactile allodynia. Cell Reports. 2019;28:526–540. doi: 10.1016/j.celrep.2019.06.040. [DOI] [PMC free article] [PubMed] [Google Scholar]
  8. Browne LE, Latremoliere A, Lehnert BP, Grantham A, Ward C, Alexandre C, Costigan M, Michoud F, Roberson DP, Ginty DD, Woolf CJ. Time-resolved fast mammalian behavior reveals the complexity of protective pain responses. Cell Reports. 2017;20:89–98. doi: 10.1016/j.celrep.2017.06.024. [DOI] [PMC free article] [PubMed] [Google Scholar]
  9. Buetfering C, Zhang Z, Pitsiani M, Smallridge J, Boven E, McElligott S, Häusser M. Behaviorally relevant decision coding in primary somatosensory cortex neurons. Nature Neuroscience. 2022;25:1225–1236. doi: 10.1038/s41593-022-01151-0. [DOI] [PMC free article] [PubMed] [Google Scholar]
  10. Burdge J, Jhumka A, Ogundare S, Baer N, Fulton S, Bistis B, Foster W, Toussaint A, Li M, Morizawa YM, Yadessa L, Khan A, Delinois A, Mayiseni W, Loran N, Yang G, Abdus-Saboor I. Remote automated delivery of mechanical stimuli coupled to brain recordings in behaving mice. eLife. 2023;13:RP99614. doi: 10.7554/eLife.99614.1. [DOI] [PMC free article] [PubMed] [Google Scholar]
  11. Campagner D, Evans MH, Chlebikova K, Colins-Rodriguez A, Loft MSE, Fox S, Pettifer D, Humphries MD, Svoboda K, Petersen RS. Prediction of choice from competing mechanosensory and choice-memory cues during active tactile decision making. The Journal of Neuroscience. 2019;39:3921–3933. doi: 10.1523/JNEUROSCI.2217-18.2019. [DOI] [PMC free article] [PubMed] [Google Scholar]
  12. Caterina MJ, Schumacher MA, Tominaga M, Rosen TA, Levine JD, Julius D. The capsaicin receptor: a heat-activated ion channel in the pain pathway. Nature. 1997;389:816–824. doi: 10.1038/39807. [DOI] [PubMed] [Google Scholar]
  13. Cavanaugh DJ, Chesler AT, Jackson AC, Sigal YM, Yamanaka H, Grant R, O’Donnell D, Nicoll RA, Shah NM, Julius D, Basbaum AI. Trpv1 reporter mice reveal highly restricted brain distribution and functional expression in arteriolar smooth muscle cells. The Journal of Neuroscience. 2011;31:5067–5077. doi: 10.1523/JNEUROSCI.6451-10.2011. [DOI] [PMC free article] [PubMed] [Google Scholar]
  14. Cheah M, Fawcett JW, Andrews MR. Assessment of thermal pain sensation in rats and mice using the hargreaves test. Bio-Protocol. 2017;7:e2506. doi: 10.21769/BioProtoc.2506. [DOI] [PMC free article] [PubMed] [Google Scholar]
  15. Cheng L, Duan B, Huang T, Zhang Y, Chen Y, Britz O, Garcia-Campmany L, Ren X, Vong L, Lowell BB, Goulding M, Wang Y, Ma Q. Identification of spinal circuits involved in touch-evoked dynamic mechanical pain. Nature Neuroscience. 2017;20:804–814. doi: 10.1038/nn.4549. [DOI] [PMC free article] [PubMed] [Google Scholar]
  16. Chiu IM, Heesters BA, Ghasemlou N, Von Hehn CA, Zhao F, Tran J, Wainger B, Strominger A, Muralidharan S, Horswill AR, Bubeck Wardenburg J, Hwang SW, Carroll MC, Woolf CJ. Bacteria activate sensory neurons that modulate pain and inflammation. Nature. 2013;501:52–57. doi: 10.1038/nature12479. [DOI] [PMC free article] [PubMed] [Google Scholar]
  17. Choi JS, Kim JJ. Amygdala regulates risk of predation in rats foraging in a dynamic fear environment. PNAS. 2010;107:21773–21777. doi: 10.1073/pnas.1010079108. [DOI] [PMC free article] [PubMed] [Google Scholar]
  18. Choi S, Hachisuka J, Brett MA, Magee AR, Omori Y, Iqbal NUA, Zhang D, DeLisle MM, Wolfson RL, Bai L, Santiago C, Gong S, Goulding M, Heintz N, Koerber HR, Ross SE, Ginty DD. Parallel ascending spinal pathways for affective touch and pain. Nature. 2020;587:258–263. doi: 10.1038/s41586-020-2860-1. [DOI] [PMC free article] [PubMed] [Google Scholar]
  19. Corder G, Ahanonu B, Grewe BF, Wang D, Schnitzer MJ, Scherrer G. An amygdalar neural ensemble that encodes the unpleasantness of pain. Science. 2019;363:276–281. doi: 10.1126/science.aap8586. [DOI] [PMC free article] [PubMed] [Google Scholar]
  20. Datta SR, Anderson DJ, Branson K, Perona P, Leifer A. Computational neuroethology: a call to action. Neuron. 2019;104:11–24. doi: 10.1016/j.neuron.2019.09.038. [DOI] [PMC free article] [PubMed] [Google Scholar]
  21. Decosterd I, Woolf CJ. Spared nerve injury: an animal model of persistent peripheral neuropathic pain. Pain. 2000;87:149–158. doi: 10.1016/S0304-3959(00)00276-1. [DOI] [PubMed] [Google Scholar]
  22. Dedek C, Azadgoleh MA, Prescott SA. Reproducible and fully automated testing of nocifensive behavior in mice. Cell Reports Methods. 2023;3:100650. doi: 10.1016/j.crmeth.2023.100650. [DOI] [PMC free article] [PubMed] [Google Scholar]
  23. Dennis EJ, El Hady A, Michaiel A, Clemens A, Tervo DRG, Voigts J, Datta SR. Systems neuroscience of natural behaviors in rodents. The Journal of Neuroscience. 2021;41:911–919. doi: 10.1523/JNEUROSCI.1877-20.2020. [DOI] [PMC free article] [PubMed] [Google Scholar]
  24. Drake RAR, Steel KA, Apps R, Lumb BM, Pickering AE. Loss of cortical control over the descending pain modulatory system determines the development of the neuropathic pain state in rats. eLife. 2021;10:e65156. doi: 10.7554/eLife.65156. [DOI] [PMC free article] [PubMed] [Google Scholar]
  25. Emanuel AJ, Lehnert BP, Panzeri S, Harvey CD, Ginty DD. Cortical responses to touch reflect subcortical integration of LTMR signals. Nature. 2021;600:680–685. doi: 10.1038/s41586-021-04094-x. [DOI] [PMC free article] [PubMed] [Google Scholar]
  26. Emiliani V, Entcheva E, Hedrich R, Hegemann P, Konrad KR, Lüscher C, Mahn M, Pan ZH, Sims RR, Vierock J, Yizhar O. Optogenetics for light control of biological systems. Nature Reviews. Methods Primers. 2022;2:55. doi: 10.1038/s43586-022-00136-4. [DOI] [PMC free article] [PubMed] [Google Scholar]
  27. Esmaeili V, Tamura K, Foustoukos G, Oryshchuk A, Crochet S, Petersen CC. Cortical circuits for transforming whisker sensation into goal-directed licking. Current Opinion in Neurobiology. 2020;65:38–48. doi: 10.1016/j.conb.2020.08.003. [DOI] [PubMed] [Google Scholar]
  28. Gan Z, Li H, Naser PV, Oswald MJ, Kuner R. Suppression of neuropathic pain and comorbidities by recurrent cycles of repetitive transcranial direct current motor cortex stimulation in mice. Scientific Reports. 2021;11:9735. doi: 10.1038/s41598-021-89122-6. [DOI] [PMC free article] [PubMed] [Google Scholar]
  29. Gangadharan V, Zheng H, Taberner FJ, Landry J, Nees TA, Pistolic J, Agarwal N, Männich D, Benes V, Helmstaedter M, Ommer B, Lechner SG, Kuner T, Kuner R. Neuropathic pain caused by miswiring and abnormal end organ targeting. Nature. 2022;606:137–145. doi: 10.1038/s41586-022-04777-z. [DOI] [PMC free article] [PubMed] [Google Scholar]
  30. Gatto G, Bourane S, Ren X, Di Costanzo S, Fenton PK, Halder P, Seal RP, Goulding MD. A functional topographic map for spinal sensorimotor reflexes. Neuron. 2021;109:91–104. doi: 10.1016/j.neuron.2020.10.003. [DOI] [PMC free article] [PubMed] [Google Scholar]
  31. Guo ZV, Li N, Huber D, Ophir E, Gutnisky D, Ting JT, Feng G, Svoboda K. Flow of cortical activity underlying a tactile decision in mice. Neuron. 2014;81:179–194. doi: 10.1016/j.neuron.2013.10.020. [DOI] [PMC free article] [PubMed] [Google Scholar]
  32. Hong YK, Lacefield CO, Rodgers CC, Bruno RM. Sensation, movement and learning in the absence of barrel cortex. Nature. 2018;561:542–546. doi: 10.1038/s41586-018-0527-y. [DOI] [PMC free article] [PubMed] [Google Scholar]
  33. Hsu AI, Yttri EA. B-SOiD, an open-source unsupervised algorithm for identification and fast prediction of behaviors. Nature Communications. 2021;12:5188. doi: 10.1038/s41467-021-25420-x. [DOI] [PMC free article] [PubMed] [Google Scholar]
  34. Iredale JA, Pearl AJ, Callister RJ, Dayas CV, Manning EE, Graham BA. 'Optical von-Frey’ method to determine nociceptive thresholds: a novel paradigm for preclinical pain assessment and analgesic screening. bioRxiv. 2023 doi: 10.1101/2023.11.02.565390. [DOI]
  35. Jones JM, Foster W, Twomey CR, Burdge J, Ahmed OM, Pereira TD, Wojick JA, Corder G, Plotkin JB, Abdus-Saboor I. A machine-vision approach for automated pain measurement at millisecond timescales. eLife. 2020;9:e57258. doi: 10.7554/eLife.57258. [DOI] [PMC free article] [PubMed] [Google Scholar]
  36. Juarez-Salinas DL, Braz JM, Etlin A, Gee S, Sohal V, Basbaum AI. GABAergic cell transplants in the anterior cingulate cortex reduce neuropathic pain aversiveness. Brain. 2019;142:2655–2669. doi: 10.1093/brain/awz203. [DOI] [PMC free article] [PubMed] [Google Scholar]
  37. Juavinett AL, Bekheet G, Churchland AK. Chronically implanted neuropixels probes enable high-yield recordings in freely moving mice. eLife. 2019;8:e47188. doi: 10.7554/eLife.47188. [DOI] [PMC free article] [PubMed] [Google Scholar]
  38. Kane GA, Lopes G, Saunders JL, Mathis A, Mathis MW. Real-time, low-latency closed-loop feedback using markerless posture tracking. eLife. 2020;9:e61909. doi: 10.7554/eLife.61909. [DOI] [PMC free article] [PubMed] [Google Scholar]
  39. Klein AS, Dolensek N, Weiand C, Gogolla N. Fear balance is maintained by bodily feedback to the insular cortex in mice. Science. 2021;374:1010–1015. doi: 10.1126/science.abj8817. [DOI] [PubMed] [Google Scholar]
  40. LaBuda CJ, Fuchs PN. A behavioral test paradigm to measure the aversive quality of inflammatory and neuropathic pain in rats. Experimental Neurology. 2000;163:490–494. doi: 10.1006/exnr.2000.7395. [DOI] [PubMed] [Google Scholar]
  41. Lai AT, Espinosa G, Wink GE, Angeloni CF, Dombeck DA, MacIver MA. A robot-rodent interaction arena with adjustable spatial complexity for ethologically relevant behavioral studies. Cell Reports. 2024;43:113671. doi: 10.1016/j.celrep.2023.113671. [DOI] [PubMed] [Google Scholar]
  42. La Vu M, Tobias BC, Schuette PJ, Adhikari A. To approach or avoid: an introductory overview of the study of anxiety using rodent assays. Frontiers in Behavioral Neuroscience. 2020;14:145. doi: 10.3389/fnbeh.2020.00145. [DOI] [PMC free article] [PubMed] [Google Scholar]
  43. Madden VJ, Catley MJ, Grabherr L, Mazzola F, Shohag M, Moseley GL. The effect of repeated laser stimuli to ink-marked skin on skin temperature-recommendations for a safe experimental protocol in humans. PeerJ. 2016;4:e1577. doi: 10.7717/peerj.1577. [DOI] [PMC free article] [PubMed] [Google Scholar]
  44. Madisen L, Mao T, Koch H, Zhuo J, Berenyi A, Fujisawa S, Hsu YWA, Garcia AJ, Gu X, Zanella S, Kidney J, Gu H, Mao Y, Hooks BM, Boyden ES, Buzsáki G, Ramirez JM, Jones AR, Svoboda K, Han X, Turner EE, Zeng H. A toolbox of Cre-dependent optogenetic transgenic mice for light-induced activation and silencing. Nature Neuroscience. 2012;15:793–802. doi: 10.1038/nn.3078. [DOI] [PMC free article] [PubMed] [Google Scholar]
  45. Mathis A, Mamidanna P, Cury KM, Abe T, Murthy VN, Mathis MW, Bethge M. DeepLabCut: markerless pose estimation of user-defined body parts with deep learning. Nature Neuroscience. 2018;21:1281–1289. doi: 10.1038/s41593-018-0209-y. [DOI] [PubMed] [Google Scholar]
  46. Mickle AD, Gereau RW. A bright future? Optogenetics in the periphery for pain research and therapy. Pain. 2018;159 Suppl 1:S65–S73. doi: 10.1097/j.pain.0000000000001329. [DOI] [PMC free article] [PubMed] [Google Scholar]
  47. Middleton SJ, Perini I, Themistocleous AC, Weir GA, McCann K, Barry AM, Marshall A, Lee M, Mayo LM, Bohic M, Baskozos G, Morrison I, Löken LS, McIntyre S, Nagi SS, Staud R, Sehlstedt I, Johnson RD, Wessberg J, Wood JN, Woods CG, Moqrich A, Olausson H, Bennett DL. Nav1.7 is required for normal C-low threshold mechanoreceptor function in humans and mice. Brain. 2022;145:3637–3653. doi: 10.1093/brain/awab482. [DOI] [PMC free article] [PubMed] [Google Scholar]
  48. Mitchell K, Bates BD, Keller JM, Lopez M, Scholl L, Navarro J, Madian N, Haspel G, Nemenov MI, Iadarola MJ. Ablation of rat TRPV1-expressing Adelta/C-fibers with resiniferatoxin: analysis of withdrawal behaviors, recovery of function and molecular correlates. Molecular Pain. 2010;6:94. doi: 10.1186/1744-8069-6-94. [DOI] [PMC free article] [PubMed] [Google Scholar]
  49. Moy JK, Kuhn JL, Szabo-Pardi TA, Pradhan G, Price TJ. eIF4E phosphorylation regulates ongoing pain, independently of inflammation, and hyperalgesic priming in the mouse CFA model. Neurobiology of Pain. 2018;4:45–50. doi: 10.1016/j.ynpai.2018.03.001. [DOI] [PMC free article] [PubMed] [Google Scholar]
  50. Nath T, Mathis A, Chen AC, Patel A, Bethge M, Mathis MW. Using DeepLabCut for 3D markerless pose estimation across species and behaviors. Nature Protocols. 2019;14:2152–2176. doi: 10.1038/s41596-019-0176-0. [DOI] [PubMed] [Google Scholar]
  51. Orefice LL, Mosko JR, Morency DT, Wells MF, Tasnim A, Mozeika SM, Ye M, Chirila AM, Emanuel AJ, Rankin G, Fame RM, Lehtinen MK, Feng G, Ginty DD. Targeting peripheral somatosensory neurons to improve tactile-related phenotypes in ASD models. Cell. 2019;178:867–886. doi: 10.1016/j.cell.2019.07.024. [DOI] [PMC free article] [PubMed] [Google Scholar]
  52. Pai J, Ogasawara T, Bromberg-Martin ES, Ogasawara K, Gereau RW, Monosov IE. Laser stimulation of the skin for quantitative study of decision-making and motivation. Cell Reports Methods. 2022;2:100296. doi: 10.1016/j.crmeth.2022.100296. [DOI] [PMC free article] [PubMed] [Google Scholar]
  53. Parkes I, Browne L, browne-lab Closed-loop-somatosensory-stimulation. 5506ebbGitHub. 2026 https://github.com/browne-lab/closed-loop-somatosensory-stimulation
  54. Pereira TD, Tabris N, Li J, Ravindranath S, Papadoyannis ES, Wang ZY, Turner DM, McKenzie-Smith G, Kocher SD, Falkner AL, Shaevitz JW, Murthy M. SLEAP: multi-animal pose tracking. Nature Methods. 2020;19:486–495. doi: 10.1038/s41592-022-01426-1. [DOI] [PMC free article] [PubMed] [Google Scholar]
  55. Ranade SS, Woo S-H, Dubin AE, Moshourab RA, Wetzel C, Petrus M, Mathur J, Bégay V, Coste B, Mainquist J, Wilson AJ, Francisco AG, Reddy K, Qiu Z, Wood JN, Lewin GR, Patapoutian A. Piezo2 is the major transducer of mechanical forces for touch sensation in mice. Nature. 2014;516:121–125. doi: 10.1038/nature13980. [DOI] [PMC free article] [PubMed] [Google Scholar]
  56. Rosenberg M, Zhang T, Perona P, Meister M. Mice in a labyrinth show rapid learning, sudden insight, and efficient exploration. eLife. 2021;10:e66175. doi: 10.7554/eLife.66175. [DOI] [PMC free article] [PubMed] [Google Scholar]
  57. Schorscher-Petcu A, Takács F, Browne LE. Scanned optogenetic control of mammalian somatosensory input to map input-specific behavioral outputs. eLife. 2021;10:e62026. doi: 10.7554/eLife.62026. [DOI] [PMC free article] [PubMed] [Google Scholar]
  58. Schwaller F, Bégay V, García-García G, Taberner FJ, Moshourab R, McDonald B, Docter T, Kühnemund J, Ojeda-Alonso J, Paricio-Montesinos R, Lechner SG, Poulet JFA, Millan JM, Lewin GR. USH2A is a Meissner’s corpuscle protein necessary for normal vibration sensing in mice and humans. Nature Neuroscience. 2021;24:74–81. doi: 10.1038/s41593-020-00751-y. [DOI] [PubMed] [Google Scholar]
  59. Uhelski ML, Morris-Bobzean SA, Dennis TS, Perrotti LI, Fuchs PN. Evaluating underlying neuronal activity associated with escape/avoidance behavior in response to noxious stimulation in adult rats. Brain Research. 2012;1433:56–61. doi: 10.1016/j.brainres.2011.11.016. [DOI] [PubMed] [Google Scholar]
  60. Weinreb C, Pearl JE, Lin S, Osman MAM, Zhang L, Annapragada S, Conlin E, Hoffmann R, Makowska S, Gillis WF, Jay M, Ye S, Mathis A, Mathis MW, Pereira T, Linderman SW, Datta SR. Keypoint-MoSeq: parsing behavior by linking point tracking to pose dynamics. Nature Methods. 2024;21:1329–1339. doi: 10.1038/s41592-024-02318-2. [DOI] [PMC free article] [PubMed] [Google Scholar]
  61. Wiltschko AB, Tsukahara T, Zeine A, Anyoha R, Gillis WF, Markowitz JE, Peterson RE, Katon J, Johnson MJ, Datta SR. Revealing the structure of pharmacobehavioral space through motion sequencing. Nature Neuroscience. 2020;23:1433–1443. doi: 10.1038/s41593-020-00706-3. [DOI] [PMC free article] [PubMed] [Google Scholar]
  62. Zhang Z, Roberson DP, Kotoda M, Boivin B, Bohnslav JP, González-Cano R, Yarmolinsky DA, Turnes BL, Wimalasena NK, Neufeld SQ, Barrett LB, Quintão NLM, Fattori V, Taub DG, Wiltschko AB, Andrews NA, Harvey CD, Datta SR, Woolf CJ. Automated preclinical detection of mechanical pain hypersensitivity and analgesia. Pain. 2022;163:2326–2336. doi: 10.1097/j.pain.0000000000002680. [DOI] [PMC free article] [PubMed] [Google Scholar]
  63. Zong W, Obenhaus HA, Skytøen ER, Eneqvist H, de Jong NL, Vale R, Jorge MR, Moser MB, Moser EI. Large-scale two-photon calcium imaging in freely moving mice. Cell. 2022;185:1240–1256. doi: 10.1016/j.cell.2022.02.017. [DOI] [PMC free article] [PubMed] [Google Scholar]

eLife Assessment

Theanne N Griffith 1

This important study combines real-time key point tracking with transdermal activation of sensory neurons as a general technique to explore how somatosensory stimulation impacts behavior in freely moving mice. After addressing concerns about classification of the behavioral responses to nociceptor stimulation, the authors now convincingly demonstrate a state-dependence in the behavioral response following nociceptor activation, highlighting how their real-time optogenetic stimulation capabilities can yield new insights into complex sensory processing. This work is a technological advancement that will be of interest to a broad readership, in particular labs studying somatosensation, enabling rigorous investigation of behaviors that were previously difficult or impossible to study.

Reviewer #1 (Public review):

Anonymous

Summary:

This study presents a system for delivering precisely controlled cutaneous stimuli to freely moving mice by coupling markerless real-time tracking to transdermal optogenetic stimulation, using the tracking signal to direct a laser via galvanometer mirrors. The principal claims are that the system achieves sub-mm targeting accuracy with a latency of <100 ms. Due to the nature of mouse gait, this enables accurate targeting of forepaws even when mice are moving.

Strengths:

The study is of high quality and the evidence for the claims is convincing. There is increasing focus in neurobiology in studying neural function in freely moving animals, engaged in natural behaviour. However, a substantial challenge is how to deliver controlled stimuli to sense organs under such conditions. The system presented here constitutes notable progress towards such experiments in the somatosensory system and is, in my view, a highly significant development that will be of interest to a broad readership.

My comments on the original submission have been fully addressed.

Reviewer #2 (Public review):

Anonymous

Parkes et al. combined real-time keypoint tracking with transdermal activation of sensory neurons to examine the effects of recruitment of sensory neurons in freely moving mice. This builds on the authors' previous investigations involving transdermal stimulation of sensory neurons in stationary mice. They illustrate multiple scenarios in which their engineering improvements enable more sophisticated behavioral assessments, including (1) stimulation of animals in multiple states in large arenas, (2) multi-animal nociceptive behavior screening through thermal and optogenetic activation, and (3) stimulation of animals running through maze corridors. Overall, the experiments and the methodology, in particular, is written clearly. The revised manuscript nicely demonstrates a state-dependence in the behavioral response to activation of TrpV1 sensory neurons, which is a nice demonstration of how their real-time optogenetic stimulation capabilities can yield new insights into complex sensory processing.

Comments on revisions:

I agree that your revisions have substantially improved the clarity and quality of the work.

Reviewer #3 (Public review):

Anonymous

Summary:

To explore the diverse nature of somatosensation, Parkes et al. established and characterized a system for precise cutaneous stimulation of mice as they walk and run in naturalistic settings. This paper provides a framework for real-time body part tracking and targeted optical stimuli with high precision, ensuring reliable and consistent cutaneous stimulation. It can be adapted in somatosensation labs as a general technique to explore somatosensory stimulation and its impact on behavior, enabling rigorous investigation of behaviors that were previously difficult or impossible to study.

Strengths:

The authors characterized the closed-loop system to ensure that it is optically precise and can precisely target moving mice. The integration of accurate and consistent optogenetic stimulation of the cutaneous afferents allows systematic investigation of somatosensory subtypes during a variety of naturalistic behaviors. Although this study focused on nociceptors innervating the skin (Trpv1::ChR2 animals), this setup can be extended to other cutaneous sensory neuron subtypes, such as low-threshold mechanoreceptors and pruriceptors. This system can also be adapted for studying more complex behaviors, such as the maze assay and goal-directed movements.

Weaknesses:

Although the paper has strengths, its weakness is that some behavioral outputs could be analyzed in more detail to reveal different types of responses to painful cutaneous stimuli. For example, paw withdrawals were detected after optogenetically stimulating the paw (Figures 3E and 3F). Animals exhibit different types of responses to painful stimuli on the hindpaw in standard pain assays, such as paw lifting, biting, and flicking, each indicating a different level of pain. The output of this system is body part keypoints, which are the standard input to many existing tools. Analyzing these detailed keypoints would greatly strengthen this system by providing deeper biological insights into the role of somatosensation in naturalistic behaviors. Additionally, if the laser spot size could be reduced to a diameter of 2 mm², it would allow the activation of a smaller number of cutaneous afferents, or even a single one, across different skin types in the paw, such as glabrous or hairy skin.

Comments on revisions:

The authors successfully addressed all of my questions and concerns.

eLife. 2026 Mar 12;14:RP106033. doi: 10.7554/eLife.106033.3.sa4

Author response

Isobel Parkes 1, Ara Schorscher-Petcu 2, Qinyi Gan 3, Liam E Browne 4

The following is the authors’ response to the original reviews.

Public Reviews:

Reviewer #1 (Public review):

Summary:

This study presents a system for delivering precisely controlled cutaneous stimuli to freely moving mice by coupling markerless real-time tracking to transdermal optogenetic stimulation, using the tracking signal to direct a laser via galvanometer mirrors. The principal claims are that the system achieves sub-mm targeting accuracy with a latency of <100 ms. The nature of mouse gait enables accurate targeting of forepaws even when mice are moving.

Strengths:

The study is of high quality and the evidence for the claims is convincing. There is increasing focus in neurobiology in studying neural function in freely moving animals, engaged in natural behaviour. However, a substantial challenge is how to deliver controlled stimuli to sense organs under such conditions. The system presented here constitutes notable progress towards such experiments in the somatosensory system and is, in my view, a highly significant development that will be of interest to a broad readership.

Weaknesses:

(1) "laser spot size was set to 2.00 } 0.08 mm2 diameter (coefficient of variation = 3.85)" is unclear. Is the 0.08 SD or SEM? (not stated). Also, is this systematic variation across the arena (or something else)? Readers will want to know how much the spot size varies across the arena - ie SD. CV=4 implies that SD~7 mm. ie non-trivial variation in spot size, implying substantial differences in power delivery (and hence stimulus intensity) when the mouse is in different locations. If I misunderstood, perhaps this helps the authors to clarify. Similarly, it would be informative to have mean & SD (or mean & CV) for power and power density. In future refinements of the system, would it be possible/useful to vary laser power according to arena location?

We thank the reviewer for their comments and for identifying areas needing more clarity. The previous version was ambiguous: 0.08 refers to the standard deviation (SD). We have removed the ambiguity by stating mean ± SD and reporting a unitless coefficient of variation (CV).

The revised text reads “laser spot size was set to 2.00 ± 0.08 mm2 (mean ± SD; coefficient of variation = 0.039).” This makes clear that the variability in spot size is minimal: it is 0.08 mm2 SD (≈0.03 mm SD in diameter). This should help clarify that spot size variability across the arena is minute and unlikely to contribute meaningfully to differences in stimulus intensity across locations. The power was modulated depending on the experiment, so we provide the unitless CV here in “The absolute optical power and power density were uniform across the glass platform (coefficient of variation 0.035 and 0.029, respectively; Figure 2—figure supplement)”. We are grateful to the reviewer for spotting these omissions.

The reviewer also asks whether, in the future, it is “possible/useful to vary laser power according to arena location”. This is already possible in our system for infrared cutaneous stimulation using analog modulation (Figure 4). We have added the following sentence to make this clearer: “Laser power could be modulated using the analog control.”

(2) "The video resolution (1920 x 1200) required a processing time higher than the frame interval (33.33 ms), resulting in real-time pose estimation on a sub-sample of all frames recorded". Given this, how was it possible to achieve 84 ms latency? An important issue for closed-loop research will relate to such delays. Therefore please explain in more depth and (in Discussion) comment on how the latency of the current system might be improved/generalised. For example, although the current system works well for paws it would seem to be less suited to body parts such as the snout that do not naturally have a stationary period during the gait cycle.

We captured and stored video with a frame-to-frame interval of 33.33 ms (30 fps). DeepLabCut-live! was run in a latency-optimization mode, meaning that new frames are not processed while the network is busy - only the most recent frame is processed when free. The processing latency is measured per processed frame, and intermediate frames are thus skipped while the network is busy. Although a wide field of view and high resolution is required to capture the large environment, increasing the per-frame compute time, the processing latency remained small enough to track and stimulate moving mice. This processing latency of 84 ± 12 ms (mean ± SD) was calculated using the timestamps stored in the output files from DeepLabCut-live!: subtracting the frame acquisition timestamp from the frame processing timestamp across 16,000 processed frames recorded across four mice (4,000 each). In addition, there is a small delay to move the galvanometers and trigger the laser, calculated as 3.3 ± 0.5 ms (mean ± SD; 245 trials). This is described in the manuscript, but can be combined with the processing latency to indicate a total closed-loop delay of ≈87 ms so we have expanded on the ‘Optical system characterization’ subsection in the Methods, adding “We estimated a processing latency of 84 ± 12 ms (mean ± SD) by subtracting…” and that “In the current configuration the end-to-end closed-loop delay is ≈87 ms from the combination of the processing latency and other delays”. To the Discussion, we now comment on how this latency can be reduced and how this can allow for generalization to more rapidly moving body parts.

Reviewer #2 (Public review):

Parkes et al. combined real-time keypoint tracking with transdermal activation of sensory neurons to examine the effects of recruitment of sensory neurons in freely moving mice. This builds on the authors' previous investigations involving transdermal stimulation of sensory neurons in stationary mice. They illustrate multiple scenarios in which their engineering improvements enable more sophisticated behavioral assessments, including (1) stimulation of animals in multiple states in large arenas, (2) multi-animal nociceptive behavior screening through thermal and optogenetic activation, and (3) stimulation of animals running through maze corridors. Overall, the experiments and the methodology, in particular, are written clearly. However, there are multiple concerns and opportunities to fully describe their newfound capabilities that, if addressed, would make it more likely for the community to adopt this methodology:

The characterization of laser spot size and power density is reported as a coefficient of variation, in which a value of ~3 is interpreted as uniform. My interpretation would differ - data spread so that the standard deviation is three times larger than the mean indicates there is substantial variability in the data. The 2D polynomial fit is shown in Figure 2 - Figure Supplement 1A and, if the fit is good, this does support the uniformity claim (range of spot size is 1.97 to 2.08 mm2 and range of power densities is 66.60 to 73.80 mW). The inclusion of the raw data for these measurements and an estimate of the goodness of fit to the polynomials would better help the reader evaluate whether these parameters are uniform across space and how stable the power density is across repeated stimulations of the same location. Even more helpful would be an estimate of whether the variation in the power density is expected to meaningfully affect the responses of ChR2-expressing sensory neurons.

We thank the reviewer for their comments. As also noted in response to Reviewer 1, the coefficient of variation (CV) is now reported in unitless form (rather than a percentage) to ensure clarity. For avoidance of doubt, the CV is 0.039 (3.9%), so the variation in laser spot size is minimal – there is negligible spot size variability across the system. The ranges are indeed consistent with uniformity. We have included the goodness-of-fit estimates in the appropriate figure legend “fit with a two-dimensional polynomial (area R2 = 0.91; power R2 = 0.75)”. This indicates that the polynomials fit well overall.

The system already allows for control of spot size. To examine whether the variation in the power density affects the responses of ChR2-expressing sensory neurons, we examined this in our previous work that focused more on input-output relationships, demonstrating a steep relationship between spot size (range of 0.02 mm2 to 2.30 mm2) and the probability of paw response, demonstrating a meaningful change in response probability (Schorscher-Petcu et al. eLife, 2021). In future studies, we aim to use this approach to “titrate” cutaneous inputs as mice move through their environments.

While the error between the keypoint and laser spot error was reported as ~0.7 to 0.8 mm MAE in Figure 2L, in the methods, the authors report that there is an additional error between predicted keypoints and ground-truth labeling of 1.36 mm MAE during real-time tracking. This suggests that the overall error is not submillimeter, as claimed by the authors, but rather on the order of 1.5 - 2.5 mm, which is considerable given the width of a hind paw is ~5-6 mm and fore paws are even smaller. In my opinion, the claim for submillimeter precision should be softened and the authors should consider that the area of the paw stimulated may differ from trial to trial if, for example, the error is substantial enough that the spot overlaps with the edge of the paw.

We thank the reviewer for identifying a discrepancy in these reported errors. We clarify this below and in the manuscript

The real-time tracking error is the mean absolute Euclidean distance (MAE) between ground truth and DLC on the left hind paw where likelihood was relatively high. More specifically, ground truth was obtained by manual annotation of the left hind paw center. The corresponding DLC keypoint was evaluated in frames with likelihood >0.8 (the stimulation threshold). Across 1,281 frames from five videos of freely exploring mice (30 fps), the MAE was 1.36 mm.

The targeting error is the MAE between ground truth and the laser spot location, so should reflect the real-time tracking error plus errors from targeting the laser. More specifically, this metric was determined by comparing the manually determined ground truth keypoint of the left hind paw and the actual center of the laser spot. Importantly, this metric was calculated using four five-minute high-speed videos recorded at 270 fps of mice freely exploring the open arena (463 frames) and frames were selected with a likelihood threshold >0.8. This allowed us to resolve the brief laser pulses but inadvertently introduced a difference in spatial scaling. After rescaling, the values give a targeting error MAE now in line with the real-time tracking error (see corrected Figure 2L). This is approximately 1.3 mm across all locomotion speeds categories. These errors are small and are limited by the spatial resolution of the cameras. We thank the reviewer for noting this discrepancy and prompting us to get to its root cause.

We have amended the subtitle on Figure 2L as “Ground truth keypoint to laser spot error” and have avoided the use of submillimeter throughout. We have added the following sentence to clarify this point: “As laser targeting relies on real-time tracking to direct the laser to the specified body part, this metric includes any errors introduced by tracking and targeting”.

As the major advance of this paper is the ability to stimulate animals during ongoing movement, it seems that the Figure 3 experiment misses an opportunity to evaluate state-dependent whole-body reactions to nociceptor activation. How does the behavioral response relate to the animal's activity just prior to stimulation?

The reviewers suggest analysis of state-dependent responses. In the Figure 3 experiment, mice were stimulated up to five times when stationary. Analysis of whole body reactions in stationary mice has been described in (Schorscher-Petcu et al. eLife, 2021) and doing this here would be redundant, so instead we now analyse the responses of moving mice in Figure 5. This new analysis shows robust state-dependent responses during movement as suggested by the reviewer. We find two behavioral clusters: one that is for faster, direct (coherent) movement and the other that is for slower assessment (incoherent) movement. Stimulation during the former results in robust and consistent slowing and shift towards assessment, whereas stimulation during the former results in a reduction in assessment. We describe and interpret these new data in the Results and Discussion sections and add information in the Methods and Figure legend, as given below. We believe that demonstrating movement statedependence is a valuable addition to the paper and thank the reviewer for suggesting this.

Given the characterization of full-body responses to activation of TrpV1 sensory neurons in Figure 4 and in the authors' previous work, stimulation of TrpV1 sensory neurons has surprisingly subtle effects as the mice run through the alternating T maze. The authors indicate that the mice are moving quickly and thus that precise targeting is required, but no evidence is shared about the precision of targeting in this context beyond images of four trials. From the characterization in Figure 2, at max speed (reported at 241 +/- 53 mm/s, which is faster than the high speeds in Figure 2), successful targeting occurs less than 50% of the time. Is the initial characterization consistent with the accuracy in this context? To what extent does inaccuracy in targeting contribute to the subtlety of affecting trajectory coherence and speed? Is there a relationship between animal speed and disruption of the trajectory?

We thank the reviewer for pointing out the discrepancy in the reported maximum speed. We have corrected the error in the main text: the average maximum speed is 142 ± 26 mm/s (four mice).

The self-paced T-maze alternation task in Figure 5 demonstrates that mice running in a maze can be stimulated using this method. We did not optimize the particular experimental design to assess the hit accuracy, as this was determined in Figure 2. Instead, we optimized for the pulse frequencies, meaning the galvanometers tracked with processed frames but the laser was triggered whether or not the paw was actually targeted. However, even in this case with the system pulsing in the free-run mode, the laser hit rate was 54 ± 6% (mean ± sem, n = 7 mice). We have weakened references to submillimeter as it was only inferred from other experiments and was not directly measured here. We find in this experiment that stimulation in freely moving mice can cause them to briefly halt and evaluate. In the future, we will use experimental designs to more optimally examine learning.

The reviewer also asks if there is a relationship between speed and disruption of the trajectory. We find that this is the case as described above with our additional analysis.

Reviewer #3 (Public review):

Summary:

To explore the diverse nature of somatosensation, Parkes et al. established and characterized a system for precise cutaneous stimulation of mice as they walk and run in naturalistic settings. This paper provides a framework for real-time body part tracking and targeted optical stimuli with high precision, ensuring reliable and consistent cutaneous stimulation. It can be adapted in somatosensation labs as a general technique to explore somatosensory stimulation and its impact on behavior, enabling rigorous investigation of behaviors that were previously difficult or impossible to study.

Strengths:

The authors characterized the closed-loop system to ensure that it is optically precise and can precisely target moving mice. The integration of accurate and consistent optogenetic stimulation of the cutaneous afferents allows systematic investigation of somatosensory subtypes during a variety of naturalistic behaviors. Although this study focused on nociceptors innervating the skin (Trpv1::ChR2 animals), this setup can be extended to other cutaneous sensory neuron subtypes, such as low-threshold mechanoreceptors and pruriceptors. This system can also be adapted for studying more complex behaviors, such as the maze assay and goal-directed movements.

Weaknesses:

Although the paper has strengths, its weakness is that some behavioral outputs could be analyzed in more detail to reveal different types of responses to painful cutaneous stimuli. For example, paw withdrawals were detected after optogenetically stimulating the paw (Figures 3E and 3F). Animals exhibit different types of responses to painful stimuli on the hind paw in standard pain assays, such as paw lifting, biting, and flicking, each indicating a different level of pain. Improving the behavioral readouts from body part tracking would greatly strengthen this system by providing deeper insights into the role of somatosensation in naturalistic behaviors. Additionally, if the laser spot size could be reduced to a diameter of 2 mm², it would allow the activation of a smaller number of cutaneous afferents, or even a single one, across different skin types in the paw, such as glabrous or hairy skin.

We thank the reviewer for highlighting how our system can be combined with improved readouts of coping behavior to provide deeper insights. Optogenetic and infrared cutaneous stimulation are well established generators of coping behaviors (lifting, flicking, licking, biting, guarding). Detection of these behaviors is an active and evolving field with progress being made regularly (e.g. Jones et al., eLife 2020 [PAWS]; Wotton et al., Mol Pain 2020; Zhang et al., Pain 2022; Oswell et al., bioRxiv 2024 [LUPE]; Barkai et al., Cell Reports Methods 2025 [BAREfoot], along with more general tools like Hsu et al., Nature Communications 2021 [B-SOiD]; Luxem et al., Communications Biology 2022 [VAME]; Weinreb et al,. Nature Methods 2024 [Keypoints-MoSeq]). One output of our system is bodypart keypoints, which are the typical input to many of these tools. We will leave the readers and users of the system to decide which tools are appropriate for their experimental designs - the focus of this current manuscript is describing the novel stimulation approach in moving animals.

Recommendations for the authors:

Reviewer #1 (Recommendations for the authors):

(1) It is hard to see how the rig is arranged from the render of Figure 2AB due to the components being black on black. A particularly useful part of Fig2AB is the aerial view in panel B that shows the light paths. I suggest adding the labelling of Figure 2A also to that. The side/rear views could perhaps be deleted, allowing the aerial view to be larger.

We appreciate this suggestion and have revised Figure 2B to improve the visibility of the optomechanical components. We have enlarged the side and aerial views, removed the rear view, and added further labels to the aerial view.

(2) MAE - to interpret the 0.54 result, it would be useful to state the arena size in this paragraph.

Thank you. We have added the arena size in this paragraph and also added scales in the relevant figure (Figure 2).

(3) "pairwise correlations of R = 0.999 along both x- and y-axes". Is this correlation between hindpaw keypoint and galvo coordinates?

Yes, we have added the following to clarify: “...between galvanometer coordinates and hind paw keypoints”

(4) Latency was 84 ms. Is this mainly/entirely the delay between DLC receiving the camera image and outputting key point coordinates?

Yes, we hope that the additional detail in the Methods and Discussion described above will now clarify the current closed-loop latencies.

(5) "Mice move at variable speeds": in this sentence, spell out when "speed" refers to mouse and when it refers to hindpaw. Similarly, Fig 2i. The sentence is potentially confusing to general readers (paws stationary although the mouse is moving). Presumably, it's due to gait. I suggest explaining this here.

The speed values that relate to the mouse body and paws are now clearer in the main text and in the legend for Figure 2I.

(6) Figure 2k and associated main text. It is not clear what "success/hit rate" means here.

We have added the following sentence in the main text: “Hit accuracy refers to the percentage of trials in which the laser successfully targeted (‘hit’) the intended hind paw.” and use hit accuracy throughout instead of success rate.

(7) Figure 2L. All these points are greater than the "average" 0.54 reported in the text. How is this possible?

The MAE of 0.54 mm refers to the “predicted and actual laser spot locations” (that is, the difference between where the calibration map should place the laser spot and where it actually fell), while Figure 2L MAE values refers to the error between the ground truth keypoint to laser spot (that is, the error between the human-observed paw target and where the laser spot fell). The latter error will include the former error so is expected to be larger. We have clarified this point throughout the text, for example, stating “As laser targeting relies on real-time tracking to direct the laser to the specified body part, this metric inherently accounts for any errors introduced by the tracking and targeting.”. This is also discussed above in response to Reviewer 2.

(8) "large circular arena". State the size here

We have added this to the Figure 2 legend.

(9) Figure 3c-left. Can the contrast between the mouse and floor be increased here?

We have improved the contrast in this image.

(10) Figure 5c. It is unclear what C1, C2, etc refers to. Mice?

Yes, these refer to mice. We have removed reference to these now as they are not needed.

(11) Discussion. A comment. There is scope for elaborating on the potential for new research by combining it with new methods for measurements of neural activity in freely moving animals in the somatosensory system.

Thank you. We agree and have added more detail on this in the discussion stating “The system may be combined with existing tools to record neural activity in freely-moving mice, such as fiber photometry, miniscopes, or large-scale electrophysiology, and manipulations of this neural activity, such as optogenetics and chemogenetics. This can allow mechanistic dissection of cell and circuit biology in the context of naturalistic behaviors.”

Reviewer #3 (Recommendations for the authors):

(1) Include the number of animals for behavior assays for the panels (e.g., Figures 4G).

Where missing, we now state the number of animals in panels.

(2) If representative responses are shown, such as in Figures 3E and 4F, include the average response with standard deviation so readers can appreciate the variation in the responses.

We appreciate the suggestion to show variability in the responses. We have made several changes to Figures 3 and 4. Specifically, to illustrate the variability across multiple trials more clearly, Figure 3E now shows representative keypoint traces for each body part from two mice during their 5 trials. For Figure 4, we have re-analyzed the thermal stimulation trials and shown a raster plot of keypoint-based local motion energy (Figure 4E) sorted by response latency for hundreds of trials. Figure 4G now presents the cumulative distribution for all trials and animals for thermal (18 wild-type mice, 315 trials) and optogenetic stimulation trials (9 Trpv1::ChR2 mice, 181 trials). We also now provide means ± SD for the key metrics for optogenetic and thermal stimulation trials in Figure 4 in the Results section. This keeps the manuscript focused on the methodological advances while showing the trial variability.

(3) "optical targeting of freely-moving mice in a large environments" should be "optical targeting of freely-moving mice in a large environment".

Corrected

(4) Define fps when you first mention this in the manuscript.

Added

(5) Data needs to be shown for the claim "Mice concurrently turned their heads toward the stimulus location while repositioning their bodies away from it".

We state this observation to qualify that the stimulation of stationary mice resulted in behavioral responses “consistent with previous studies”. It would be redundant to repeat our full analysis and might distract from the novelty of the current manuscript. We have restricted this sentence to make it clearer: “Consistent with previous studies, we observed the whole-body behaviors like head orienting concurrent with local withdrawal (Browne et al., Cell Reports 2017; Blivis et al., eLife, 2017.)”

Associated Data

    This section collects any data citations, data availability statements, or supplementary materials included in this article.

    Data Citations

    1. Parkes I, Schorscher-Petcu A, Gan Q, Browne LE. 2026. Precision cutaneous stimulation in freely moving mice. Dryad Digital Repository. [DOI] [PMC free article] [PubMed]

    Supplementary Materials

    Supplementary file 1. Optics.

    This table details the optical components for the assembly of the system.

    elife-106033-supp1.docx (18.6KB, docx)
    Supplementary file 2. Mounting components.

    This table details the parts for mounting optics in the system.

    elife-106033-supp2.docx (17.3KB, docx)
    Supplementary file 3. Acquisition and control components.

    This table details the parts for acquisition and control.

    MDAR checklist

    Data Availability Statement

    The manuscript is a Tools and Resources study that provides a new method. Code to use this method is openly accessible at https://github.com/browne-lab/closed-loop-somatosensory-stimulation (Parkes et al., 2026). Data is available on Dryad at https://doi.org/10.5061/dryad.rr4xgxdhs.

    The following dataset was generated:

    Parkes I, Schorscher-Petcu A, Gan Q, Browne LE. 2026. Precision cutaneous stimulation in freely moving mice. Dryad Digital Repository.


    Articles from eLife are provided here courtesy of eLife Sciences Publications, Ltd

    RESOURCES