Introduction

Serotonin (5-hydroxytryptamine, 5-HT), known as the “feel-good” molecule, is a key monoaminergic neurotransmitter that exerts an expansive influence across the central nervous system (16), regulating essential physiological and behavioral processes such as locomotion (715), sleep (1620), emotion (2123), and learning (2428). Within the vertebrate brain, the dorsal raphe nucleus (DRN) serves as the primary hub for serotonergic synthesis, providing the dominant source of ascending serotonin to widespread brain regions (2, 29). The DRN 5-HT system has long been implicated in the regulation of sleep and arousal; yet, its precise contribution to the sleep–wake cycle remains one of the most enduring enigmas in neurobiology (19, 30, 31). For more than half a century, a central controversy has persisted: whether serotonergic signaling functions as a primary driver of sleep induction or as a promoter of cortical arousal (16, 17, 19, 3034).

The larval zebrafish (Danio rerio) provide an excellent model for reconciling these conflicting perspectives. They exhibit well-defined sleep behavior, characterized by reduced locomotor activity, sustained immobility, elevated arousal thresholds, and homeostatic sleep rebound following sleep deprivation (3541). The zebrafish serotonergic system is highly conserved with mammals in anatomy and function (18, 4244). The small size and optical transparency of the larval zebrafish brain enable whole-brain, cellular-resolution imaging, offering a unique opportunity to dissect serotonergic modulation across the entire neural population.

In zebrafish, increased DRN 5-HT neuron activity is often associated with locomotor suppression, suggesting that serotonergic signaling promotes sleep. Optogenetic activation of these neurons induces sleep-like behavior, while their ablation disrupts sleep-promoting pathways(18, 20), supporting a sleep-promoting role. Yet several lines of evidence suggest the opposite. Electrophysiological recordings show that DRN 5-HT neurons fire at higher rates during the day than at night (18), which is the opposite of the sleep rhythm, indicating a wake-related component of serotonergic activity. Transient water-flow stimulation and exposure to conspecific alarm substances both enhance DRN 5-HT neuron activity and sensory responsiveness, even when locomotion is suppressed (44, 45).

Beyond arousal and sleep, DRN 5-HT neurons are consistently more active in behavioral states with reduced locomotion. During exploitation in naturalistic foraging, zebrafish exhibit decreased movement, increased predation, and elevated DRN activity (46). DRN 5-HT neurons are essential for motor adaptation under visuomotor mismatch, where higher 5-HT levels correlate with reduced tail movements and reticulospinal excitability (4750). These findings indicate that serotonergic activity is tightly linked to locomotor suppression across diverse behavioral contexts.

These seemingly contradictory studies pose a central question: How do changes in serotonin levels modulate an animal’s internal state and behavior, such that they either produce enhanced sensitivity to external stimuli, as in vigilance, or reduced sensitivity, as in sleep? We address this using a custom all-optical system for simultaneous optogenetic manipulation of DRN 5-HT neurons and whole-brain calcium imaging in behaving larval zebrafish. Zebrafish spontaneously alternate between locomotor and quiescent states, with DRN activity markedly elevated during quiescence. Optogenetic activation of DRN 5-HT neurons induced behavioral quiescence and reduced responsiveness to acoustic stimuli, in a state distinct from natural sleep. Whole-brain light-field imaging with demixed principal component analysis (dPCA) revealed separate neural subspaces associated with DRN activation, auditory processing, and motor activity. Our findings reveal that serotonergic modulation promotes behavioral quiescence through hierarchical control of motor circuits without altering auditory stimulus encoding, elucidating how the 5-HT system shapes brain states and behavioral flexibility.

Results

DRN 5-HT activation creates a quiescent, non-sleep state

We developed a custom optical system (51) for stable, long-term whole-brain imaging, tracking, and targeted optogenetic stimulation in freely swimming larval zebrafish (Fig. 1A). We recorded 60-minute spontaneous behavior and brain-wide neural activity in elavl3:H2B-jGCaMP8s transgenic larvae. The fish alternated naturally between locomotor and quiescent states (Fig. 1B). Consistent with previous work (46), whole-brain imaging revealed sustained and elevated DRN neuronal activity during the quiescent state (Fig. 1C, Fig. 1D). We then optogenetically activated DRN serotonergic neurons in the Tg(tph2:ChrimsonR-mKate2) transgenic fish (Fig. 2A). Although the tph2 promoter primarily drives expression in DRN 5-HT neurons, minor expression in the pineal gland of the forebrain was minimized by spatially restricting 588 nm laser stimulation to the DRN (30 µW, 50 Hz galvo scanning, Fig. 1A). Each 5-min stimulation was repeated 2–4 times per fish. DRN activation markedly suppressed locomotor activity, inducing a near-quiescent state, whereas control fish lacking ChrimsonR showed no effect (Fig. 2B). Low-frequency optogenetic stimulation also produced a similar reduction in locomotor activity (Fig. S1A-B).

DRN neuronal activity increased during quiescence.

A. A schematic of our all-optical system that integrates tracking, dual-color volumetric fluorescence imaging, and optogenetic manipulation. B. Example zebrafish exhibited alternating locomotor and quiescent states during spontaneous behavior. C. Maximum intensity projection (MIP) of whole-brain imaging in a zebrafish, showing 30 s averaged neural activity during locomotor (left) and quiescent (middle) states; their difference is shown on the right. The red circle marks the dorsal raphe nucleus (DRN). Scale bar, 100 µm. D. Relationship between locomotor speed and neural activity in DRN (n = 3).

DRN 5-HT activation induces a quiescent but non-sleep-like state.

A. MIP of whole-brain data from a 7 dpf Tg(tph2:ChrimsonR-mKate2 × elav3:h2b-jGCaMP8s) zebrafish acquired by two-photon microscopy. Scale bar, 100 µm. B. Locomotor velocity changes in Tg(tph2:ChrimsonR) and control zebrafish during DRN 5-HT neuron activation (n = 6). Yellow shading marks optogenetic stimulation. C. Top: Body roll angle (rotation in the Y–Z plane) increases during natural sleep, indicating loss of postural stability. Body roll angle in control (n = 8), sleep-deprived (SD, n = 6), and Tg(tph2:ChrimsonR) zebrafish (n = 12). Yellow indicates optogenetic stimulation. In Tg(tph2:ChrimsonR) fish, light versus no-light conditions were compared with the Wilcoxon matched-pairs signed rank test. Tg(tph2:ChrimsonR) versus control and sleep-deprived versus Tg(tph2:ChrimsonR) were compared with the Mann–Whitney U test. ****p < 0.0001. D. Top: Experimental timeline over two light–dark cycles (14 h light/10 h dark). The first cycle was normal; in the second, optogenetic stimulation was applied during the first 6 h of the dark period. Average locomotor speed and sleep duration in the 4 h after stimulation were compared with the corresponding 4 h of the first dark period. Bottom: Differences in average locomotor speed and sleep duration between Tg(tph2:ChrimsonR) (n = 24) and control zebrafish (n = 24), analyzed with the Mann–Whitney U test.

Optogenetic activation of DRN 5-HT neurons suppressed locomotion in freely swimming zebrafish. This effect has been interpreted as either promoting sleep (18) or vigilance-related immobility (44). To test whether this quiescence resembles sleep, we examined postural control. Unlike natural sleep, which causes postural instability and increased roll angles(52), DRN 5-HT activation did not significantly alter roll angles, whereas sleep-deprived (SD) zebrafish showed clear instability during quiescence (Fig. 2C, Fig. S1C-D). We next tested whether DRN activation during the dark (sleep) phase would block sleep rebound: if this quiescent state were sleep, no rebound would be expected. Instead, stimulation led to a rebound comparable to controls (Fig. 2D, Fig. S1E-F). Together, these results suggest that DRN activation induces a quiescent but non-sleep state in larval zebrafish.

DRN 5-HT activation modulates brain state

To assess how optogenetic activation of DRN 5-HT neurons alters global neural dynamics, we applied demixed principal component analysis (dPCA) to whole-brain activity data (53). dPCA separates neural population activity into components tied to specific experimental variables, allowing us to isolate DRN-dependent changes (Methods). Components associated with DRN activation explained significantly more variance in Tg(tph2:ChrimsonR) zebrafish than in controls (Fig. 3A), indicating a strong serotonergic impact on brain-wide neural activity. The small stimulation-related variance in controls likely reflected visual responses to laser. Projection of whole-brain activity onto the first demixed principal component (dPC1 score), which accounted for over half of the data variance (Fig. 3A), revealed a pronounced and reversible state transition during DRN activation (Fig. 3B). Brain regions with high dPC1 weights (Fig. 3C) showed activity more strongly correlated with locomotor behavior than randomly selected regions (Fig. 3D and Method). Thus, DRN 5-HT activation rapidly reorganizes global neural states and selectively engages motor-related circuits.

DRN 5-HT activation modulates brain state.

A. Cumulative variance explained by demixed principal components (dPCs) related to optogenetic stimulation in Tg(tph2:ChrimsonR) zebrafish (n = 5) and controls (n = 5). B. Time course of whole-brain activity projected onto dPC1 in Tg(tph2:ChrimsonR) zebrafish (n = 5). Yellow shading marks optogenetic stimulation. C. Left: Histogram of brain-region weight distribution in dPC1. Yellow shading highlights high-weight regions (|weight| > 0.03, 272 regions). Right: Spatial distribution of these regions in the zebrafish brain. Scale bar, 100 µm. D. R2 between neural activity in dPC1 high-weight regions and locomotor behavior, compared with randomly selected regions (n = 272; Mann–Whitney U test, ****p<0.0001).

DRN 5-HT activation modulates motor circuits to suppress sound-evoked responses

Across species, sleep features an increased arousal threshold and reduced responsiveness to external stimuli (54). In contrast, a recent study shows that DRN 5-HT neuron activation enhances zebrafish vigilance to aversive cues (44), lowering the auditory response threshold – an effect opposite to the sleep-promoting effect of DRN activation (18). To test how DRN 5-HT neurons regulate behavioral states, we present auditory stimuli during DRN activation. Based on larval auditory sensitivity (55), a 350 Hz pure tone (500 ms, 100 dB) was delivered every 60 s (Fig. 4A). Tg(tph2:ChrimsonR) larvae exhibited strong locomotor suppression and near-complete loss of sound-evoked escape responses during stimulation (Wilcoxon matched-pairs signed rank test, **p = 0.0039), both of which recovered afterwards (Fig. 4B). Control fish showed no significant changes in swimming speed or escape probability but displayed weak habituation across trials (Fig. 4B, (56)).

DRN 5-HT activation modulates motor circuits to reduce sound-evoked responses.

A. Experimental protocol for sound stimulus experiments. B. Probability of sound-evoked escape in Tg(tph2:ChrimsonR) and control zebrafish before, during, and after optogenetic stimulation. Yellow shading marks optogenetic activation. Wilcoxon matched-pairs signed rank test, **p = 0.0039. C. Population raster plot of simultaneously recorded neurons during DRN 5-HT activation and control. Blue lines mark sound onset. D. Schematic of sound, motor, and DRN activation subspaces identified by dPCA. Left and right MIPs show brain regions with high weights in each subspace in an example zebrafish (bottom right panel is the same as the panel shown in Figure 3C). E. Left: Similarity matrix of sound-evoked population responses during DRN activation vs. control. Right: Same analysis comparing awake and drug-induced sleep. F. Principal angle analysis shows the motor subspace is significantly aligned with the DRN activation subspace, while the sound subspace is nearly orthogonal (p-values from a nonparametric permutation test, 1000 iterations).

To examine how DRN 5-HT neuron activation affects sensorimotor processing (Fig. 4C), we next recorded whole-brain neural activity in head-fixed, tail-free larvae embedded in agarose to capture transient calcium signals with minimal motion artifacts. dPCA revealed neural subspaces associated with auditory processing, motor activity, and DRN 5-HT activation (Fig. 4D, Fig. S2A). Interestingly, DRN activation preserved the structure of the auditory population code, measured by cosine similarity between trials (Fig. 4E, Fig. S2B). Because head-fixed larvae rarely enter natural sleep, we applied 1 mM mepyramine, a sleep-promoting antihistamine, to induce a sleep-like state (41), which markedly changed auditory responses (Fig. 4E, Fig. S2C). Using both strong and weak auditory stimuli (Fig. S2D), we found no evidence that DRN 5-HT activation altered sound-evoked responses at either intensity (Fig. S2E). Principal angle analysis revealed a significant alignment between DRN activation and motor-related neural subspaces, with the sound-related subspace being nearly orthogonal (Fig. 4F and Methods). Thus, DRN 5-HT neuron activation selectively modulates motor-related activity while preserving auditory encoding, thereby reshaping sensorimotor processing.

DRN 5-HT neuron activation produces bout type–dependent, graded suppression of the motor subspace

We constructed a linear regression model using baseline tail movements to predict neural activity (57). After detecting bouts, we computed each bout’s direction and amplitude and classified them into 12 types. Based on the timing of each bout type, we defined 12 regressors (r1r12) with corresponding coefficients (β1-β12) (Fig. 5A, Methods). Using spontaneous behavioral data and motor-correlated dPC1 weight (Fig. S3A), we identified motor-correlated neurons and calculated the coefficient of variation (CV) across the 12 coefficients for each neuron. Some neurons exhibited activity related to all bout types with similar amplitudes, yielding low coefficient variability, whereas others responded selectively to specific bout types – typically those with larger tail amplitudes and turning angles – exhibiting higher variability in regression coefficients (Fig. 5B).

DRN 5-HT neuron activation exerts graded suppression on motor subspace.

A. Schematic of the linear regression analysis. B. Example neurons with low (top) and high (bottom) variability in regression coefficients. Left, middle, and right panels show regression coefficients, mean activity across bout types, and neuronal spatial locations. C. Two motor-related regions with distinct modulation after DRN 5-HT activation. Left, middle, and right panels show their spatial locations, activity in control and optogenetic trials, and trial-averaged activity. D. Spatial distribution of motor-correlated neurons differentially modulated by DRN 5-HT activation. Neural magnitude is quantified by variance. Neurons are color-coded by variance reduction (darker red, stronger suppression; lighter red, weaker effect), as in (Fig. 5E,F). E. Relationship between DRN 5-HT–induced modulation and the coefficient of variation (CV) of regression coefficients across motor-correlated neurons. F. Hyperbolic multidimensional scaling (HMDS) of neural correlation distances shown in a 3D Poincaré ball (left) and a 2D projection (right). Top: functional embedding during DRN 5-HT activation; bottom: control period.

We next applied the linear model to predict neural activity during both control and DRN 5-HT activation periods. Although zebrafish exhibited markedly reduced locomotion during DRN 5-HT activation, some motor-correlated neurons maintained control-like activity levels (Fig. 5C, top). However, the neural activity no longer drove movements, indicating a decoupling between neuronal activity and behavior and reducing the variance in neural activity explained by the linear model. In contrast, other neurons displayed a pronounced reduction in activity during 5-HT activation (Fig. 5C, bottom). Using the differences in neuronal activity between control and DRN 5-HT activation, we mapped the spatial distribution of motor-correlated neurons with distinct modulation patterns (Fig. 5D). Interestingly, neurons least affected by DRN 5-HT activation (light red) had lower variability in their regression coefficients, whereas the most affected neurons (dark red) had higher variability (Fig. 5E, Fig. S3C-E). Together, these results suggest that serotonergic modulation exerts a graded suppression on the motor network, preferentially inhibiting downstream neurons involved in specific motor actions to reduce locomotion.

Finally, we applied Bayesian multi-dimensional scaling (MDS) of neural correlation distances (58) (Fig. S4A) to assess how serotonin reorganizes the motor population. Interestingly, when DRN 5-HT activation nearly abolished locomotion, a hyperbolic embedding with negative curvature K = − λ2 preserved pairwise distances better than an equally dimensional Euclidean space (Fig. S4C), with optimal dimensionality d = 6 (Fig. S4B) and strong curvature λ = 3.34 (Methods). Hyperbolic geometry indicates complex hierarchical organization (59, 60). In the Poincaré ball representation, hyperbolic distances diverge logarithmically as the neurons approach the boundary. Under serotonergic activation, two neuronal ensembles segregated to opposite poles of the Poincaré ball (Fig. 5F), reflecting a rapid expansion in functional diversity. In contrast, during control periods, the neural representation was more coherent, occupying a compact central region within the Poincaré ball with near-flat curvature (λ = 0.07, d = 6), consistent with Euclidean embedding (Fig. S4D). These findings suggest that DRN 5-HT activation diversifies motor network activity, suppressing locomotion and promoting quiescence.

Discussion

Activation of DRN 5-HT neurons generally suppresses locomotion in zebrafish, a phenomenon controversially interpreted as sleep or vigilance (18, 44). In this study, DRN 5-HT activation nearly abolished locomotion without altering body posture, and nighttime stimulation still produced normal sleep rebound. Thus, the induced quiescent state represents motor suppression rather than sleep. Unlike mammals, whose sleep states are determined through electroencephalogram (EEG) and electromyogram (EMG) recordings, zebrafish sleep is typically inferred based on several minutes of sustained immobility due to technical limitations (18, 36, 40). Since movement inhibition diminishes responsiveness to external stimuli, this resting yet awake state may be misclassified as sleep in zebrafish.

Indeed, multiple non-sleep behavioral states can also produce pronounced locomotor suppression; previous studies have demonstrated that serotonin contributes to movement suppression across diverse behavioral contexts (44, 46, 48, 49, 52, 61). In our study, zebrafish exhibited spontaneous alternations between locomotor and quiescent states, resembling the previously described “exploitation” and “exploration” modes (46). However, because no prey were present in our experimental conditions, the observed reduction in locomotion cannot be equated with the exploitation state. Additionally, elevated activity of DRN serotonergic neurons has been reported both during REM-like sleep (52) and in the quietly vigilant state (44). A common feature shared by these distinct behavioral states is a pronounced reduction in movement. We therefore propose that the activation of DRN serotonergic neurons is not sufficient to specify any particular behavioral state but instead plays a primary role in driving motor suppression.

In mammals, although the serotonergic system has traditionally been regarded as part of the arousal-promoting network, numerous studies have also reported that elevated 5-HT levels suppress locomotion (9, 6265). This kind of wakeful quiescent state serves important physiological functions. During intense or prolonged physical activity, serotonin levels in the brain and spinal cord rise, inhibiting motor neuron activity and inducing central fatigue, thereby reducing movement to prevent muscle and other bodily damage (66, 67). In a recent study, sick mice activated IL-1R1–expressing serotonergic neurons in the DRN via cytokine signaling, which in turn triggered social withdrawal and reduced locomotion—responses that promote recovery and limit pathogen transmission (65).

In our study, activating DRN 5-HT neurons did not significantly alter the representation of auditory information. The effects on other senses, such as vision or nociception, may differ, and the animal’s state could also modify how 5-HT influences sensory encoding. Previous research has observed 5-HT enhancing sensory information encoding under specific conditions (44, 45). In addition, previous studies have shown that under high-threat or punishment-based behavioral paradigms in mice (13), activation of DRN 5-HT neurons can instead increase locomotor activity. Consistently, the environmental threat level may also modulate the effects of DRN serotonergic activity on locomotion in zebrafish.

Finally, our analysis revealed that DRN 5-HT activation does not uniformly inhibit the motor network but instead exerts graded suppression. Neurons with broad tuning across multiple bout types remained largely unaffected, whereas those selectively responsive to specific motor patterns–particularly high-amplitude or turning movements–were strongly suppressed. This hierarchical organization suggests that serotonergic modulation acts at multiple levels of the motor circuitry, preferentially dampening specialized components that drive vigorous or directional movements. Such selective suppression may serve as a mechanism to reduce overall motor output while maintaining baseline motor tone, thereby facilitating rapid transitions between active and quiescent states. This implies that “no-action” is not merely the absence of movement but a strategic policy that prioritizes future state accessibility over immediate output (68), thereby creating the low-noise ‘offline’ environment (69) essential for learning, neural replay, and memory consolidation.

Methods

Zebrafish

All larval zebrafish were raised in 0.5 × E2 Embryo Media at 28.5°C and a 14/10 hr light/dark cycle. The 0.5 × E2 Embryo Media consists of 7.5 mM NaCl, 0.25 mM KCl, 0.5 mM MgSO4, 75 µM KH2PO4, 25 µM Na2HPO4, 0.5 mM CaCl2, 0.35 mM NaHCO3. Larval zebrafish aged 6-11 days post-fertilization (dpf) were used for all experiments. Sex discrimination was not included since the sex of zebrafish is not specified at this stage.

All-optical system

Neural activity and behavior were recorded using a custom-built all-optical system, as previously described (51). The system consists of three main components: a 3D tracking module, a dual-color fluorescence imaging module, and an optogenetic manipulation module. A convolutional neural network (CNN) was used to detect the lateral positions of the fish’s head from dark-field images captured by the near-infrared (NIR) tracking camera. A tracking model converted the real-time positional information into analog signals to drive the high-speed motorized stage and compensate for fish movement. An autofocus camera with a microlens array acquired multi-perspective images; the fish’s z-position was estimated via light-field principles, and a PID controller used this data to drive a piezo for axial tracking. The neural activity-dependent green fluorescence signal and the activity-independent red fluorescence signal were split into two beams by a dichroic mirror before entering the two sCMOS cameras separately. Both the red and green fluorophores can be excited by a blue laser (488 nm). A 2D galvo system deflected a yellow laser (588 nm) to a user-defined ROI in the fish brain for real-time optogenetic manipulation with the aid of a fast whole-brain image reconstruction and registration algorithm.

Experimental procedures for whole-brain imaging and optogenetic manipulation

For freely swimming zebrafish, we employed a custom-designed circular chamber with a diameter of 20 mm and a height of 800 µm. The top and bottom surfaces of the chamber were coverslips, ensuring unobstructed optical access from both above and below. To prevent the chamber edges from occluding fluorescent signals, a 1.5% low-melting-point agarose solution (Thermo Fisher Scientific, product no. 16520050) was used to form an approximately 1 mm wide annular agarose ring around the chamber perimeter. For zebrafish not expressing optogenetic proteins ChrimsonR, the 488 nm laser was operated at 30 mW with a 10 Hz flashing mode and an exposure time of 1 ms per pulse. For zebrafish expressing optogenetic proteins, a long-exposure mode with a reduced power of 0.3 mW was applied to minimize potential interference with the ChrimsonR.

For head-fixed zebrafish, 1.5% low-melting-point agarose was used for immobilization. After the agarose had fully solidified, the agarose surrounding the head (for pharmacological experiments) and tail was carefully removed. Because head fixation substantially reduces motion-induced noise, we used a lower-power 488 nm excitation (0.03 mW) to further minimize interference with the optogenetic proteins ChrimsonR.

In the all-optical system, we incorporated a high-precision patterned optogenetic stimulation module that allowed selective activation of 5-HT neurons within the DRN in both freely swimming and head-fixed zebrafish. The stimulation pattern was spatially restricted to user-defined regions and avoided illumination of the pineal gland. Optogenetic activation was performed using a 588 nm yellow laser. A ROI (160 × 160µm) was positioned to fully encompass the DRN. The laser power was 30 µW, and Galvo-based scanning produced an effective stimulation frequency of 50 Hz. Each optogenetic trial lasted 5 min, with 2–4 repetitions per fish. For experiments that included auditory stimulation, the duration of optogenetic activation was extended as needed to ensure sufficient trial numbers.

Whole-brain image processing pipeline

Whole-brain neural activity was extracted from reconstructed 3D image stacks acquired by the all-optical system. Because both channels originate from the same optical path, spatial transformations are equivalent; registration was therefore first performed on the red channel, which is unaffected by neural activity, and the resulting transformation was applied to the green channel.

Registration included cropping, rigid registration, and non-rigid registration. Reconstructed 3D images (600 × 600 × 250 voxels) were rotated to a standard orientation based on head orientation and cropped to 308 × 380 × 210 voxels to match the ZBB standard brain template. A sharp reference frame without motion blur was selected; all other frames were aligned to this reference and subsequently registered to the standard brain using affine transformations from the Computational Morphology Toolkit (CMTK, NIH). After rigid registration, small deformations caused by physiological movements were corrected using Demons-based diffeomorphic non-rigid registration. To improve alignment accuracy, an averaged template was generated from 10 frames per 100 frame sequence, and each frame was aligned to this template using optical flow-based registration.

After applying the transformation from the red channel to the green channel, brain regions were segmented based on voxel-wise temporal correlations of the green channel fluorescence. For each voxel, the average correlation with its 14 neighboring voxels was computed to generate a correlation map. The map was segmented using a watershed algorithm to define preliminary regions, and voxels with low correlation to the regional mean were removed. The resulting segmentation was then applied to the red channel.

Fluorescence time series from each brain region were denoised and deconvolved using the OASIS algorithm to infer neural activity.

Behavioral recording and sleep analysis

The experiment began at 18:00 on Day 1 and continued until 12:00 on Day 3, covering two dark cycles. To avoid edge obstruction during imaging, zebrafish larvae were housed in a custom-designed 24 well plate. The light/dark cycle was maintained using white LED illumination (lights on at 08:00 and off at 22:00). A 940 nm infrared light source was used for video recording. Optogenetic stimulation was delivered using a 530 nm LED light source (THORLABS M530L3) during the first 6 hours of the second dark phase. At 14:00 on Day 2, E2 embryo medium and live paramecia were added to prevent dehydration and starvation. Infrared videos were acquired at 1 fps using a Basler acA2000-165kmNIR camera. Illumination control and data acquisition were managed by a custom-written C++ program.

Videos were analyzed using ZebraZoom (https://zebrazoom.org/) to extract the locomotor activity of zebrafish larvae. Periods during which swimming speed remained below 0.0667 mm/s (corresponding to 1 pixel in the video, to avoid detection error) for at least 60 s were defined as a quiescent minute. To exclude abnormal data, episodes of continuous immobility lasting longer than 1 hour were removed. The average swimming speed and total immobility duration during the last 4 hours of the first dark phase were then calculated and compared with those from the last 4 hours of the second dark phase to assess the effects of optogenetic stimulation on locomotor activity and sleep-related behavior.

Body roll angle

Zebrafish larvae were approximated as rigid bodies; therefore, the whole brain roll angle was used to estimate the body roll angle. Three-dimensional whole-brain fluorescence data were used for this calculation. Because only the roll angle was required and details of neural activity were not considered, images were downsampled from 2048 × 2048 to 512 × 512 pixels to accelerate processing, followed by deconvolution with 10 iterations. After reconstruction, the 3D images were binarized using adaptive thresholding, and the largest connected component was identified as the head region. Volumes with the largest connected component smaller than 100,000 voxels were considered to correspond to cases in which the fish deviated from the field of view; these data were excluded and filled by interpolation. Principal component analysis (PCA) was applied to determine its principal axis, representing the longitudinal axis of the brain. The brain was then rotated to align this axis with that of a standard reference brain. After alignment, a maximum intensity projection of the 3D image onto the Y–Z plane was generated, and PCA was applied to this projection to determine its principal axis. The angle between this axis and the horizontal vector is defined as the body roll angle of the zebrafish.

At 6 dpf, zebrafish reared under a normal light–dark cycle were subjected to continuous sleep deprivation for 3 days (41). Larvae were placed in a circular tank containing 200 mL of 0.5× E2 embryo medium. The tank was mounted on a shaker and oscillated around its central axis at a frequency of 1 Hz to prevent the larvae from entering a sleep state. Continuous light exposure was provided throughout the 24 h deprivation period. Paramecia were supplied twice daily to prevent starvation. The medium was replaced daily to maintain optimal water quality. All experiments were conducted during the dark phase (22:00 or later).

Auditory stimuli

Auditory stimuli were integrated into the all-optical system. Binaural sound stimuli (350 Hz, 500 ms duration, 100 dB intensity) were delivered at 60 s intervals. The experimental protocol consisted of an initial baseline period of 10–20 minutes to determine the baseline locomotor speed of each zebrafish, followed by approximately 1 hour of auditory stimulation. During the auditory stimulation period, optogenetic activation was applied using a 588 nm laser in multiple epochs, each lasting 5–10 minutes, with an inter-stimulation interval of at least 10 minutes. Zebrafish behavior was recorded at 50 fps using an infrared camera (Basler acA2000-165kmNIR), and locomotor speed was calculated from the tracked positional data.

For drug-treatment experiments, the protocol consisted of four sequential phases. First, a 20-minute baseline period was recorded. This was followed by a 30-minute auditory stimulation. Subsequently, all E2 embryo medium was removed and replaced with E2 medium containing 1 mM mepyramine. After a 30-minute incubation period to allow the drug to take effect, auditory stimulation was applied again for an additional 30 minutes.

In freely swimming zebrafish, an escape response was defined as an increase in swimming speed exceeding 50% of the baseline average within 1 s following stimulus onset. In head-fixed zebrafish, a DeepLabCut model was trained to detect six key points along the tail to extract locomotor kinematics. Bouts were identified based on the cumulative tail curvature over 0.5 s sliding window, after removing slow trends using a moving average filter with a 9 s window. Bouts occurring within 1 s of auditory stimulus onset were considered stimulus-evoked.

dPCA

dPCA was performed using the MATLAB implementation provided by the Machens laboratory (https://github.com/machenslab/dPCA). Prior to analysis, whole-brain neural activity traces were z-score normalized across time. To reduce the influence of sampling noise and motion artifacts, brain regions with volumes smaller than 50 voxels were excluded.

For the identification of the DRN 5-HT activation–related neural subspace, all data were first registered to the standard brain, after which the DRN region itself was removed to prevent direct optogenetic activation effects from dominating the observed activity differences. Neural activity was segmented into trials based on the presence or absence of optogenetic stimulation, without regard to the behavioral state of the fish or the presence of auditory stimuli. Each trial had a fixed duration of 11 s. dPCA was then applied to these trial-structured data. After applying dPCA, we found that in Tg(tph2:ChrimsonR) zebrafish, the first demixed principal component (dPC1) explained more than 50% of the total variance, whereas the remaining dPCs accounted for substantially smaller proportions. Therefore, all subsequent analyses were based on dPC1, which was defined as the DRN activation–related subspace. To enable comparisons across animals, whole-brain activity projected onto dPC1 was normalized to a range of -1 to 1. Brain regions with high absolute weights on dPC1 were selected, and their spatial distributions were visualized. A linear regression model was used to quantify the fraction of variance in these regions that could be explained by motor behavior (R2; Methods). To assess the specificity of this relationship, an equal number of neurons was randomly sampled from the remaining whole-brain population (excluding previously removed regions), and their R2 values were calculated and statistically compared with those of the dPC1-weighted regions.

To identify sound-evoked and motor-correlated neural subspaces, neural activity was categorized into four trial types according to the presence or absence of auditory stimulation and locomotor behavior. Trials containing optogenetic stimulation were excluded from this analysis to avoid confounding effects. Neural activity was temporally aligned either to the onset of auditory stimuli or to the initiation of locomotor bouts. dPCA was then applied using auditory stimulation or movement as the decoding variable to extract sound-related and motor-related neural components. Because the first demixed principal components (dPC1-sound and dPC1-motor) consistently accounted for a substantially larger fraction of the variance than higher-order components, whole-brain activity was projected onto these components.

Similarity analysis

To quantify the similarity of population neural responses in the sound-evoked subspace across trials under different optogenetic and drug-induced conditions, we constructed trial-by-trial similarity matrices using cosine similarity. Neural activity was z-score normalized across time for each neuron prior to analysis. Trials were defined as the time of auditory stimulus onset and the following 2 s. For each trial, neural activity within the corresponding time window was extracted. Activity for each neuron was then averaged over time to obtain a neurons × 1 vector representing the population response. Population response vectors from all trials were concatenated to form a neurons × trials matrix. Pairwise similarity between trials was computed using cosine similarity across neurons.

Subspace angle analysis

To assess the alignment between the DRN activation–related neural subspace and either the motor-related or sound-evoked subspaces, we quantified subspace similarity using principal angles. For each subspace, the first two dimensions were retained to define the corresponding low-dimensional representation. Orthonormal bases for the DRN activation, motor-related, and sound-evoked subspaces were obtained using the MATLAB function orth. Principal angles between each subspace and the DRN activation subspace were then computed using the subspace function.

To evaluate the statistical significance of the observed subspace alignment, we performed a nonparametric permutation test. To generate a null distribution, 1,000 random subspaces were constructed by randomly selecting time points from the spontaneous neural activity matrix and orthonormalizing the resulting activity vectors using orth. For each random subspace, principal angles relative to the DRN activation subspace were computed using the same procedure, yielding a null distribution of mean principal angles under the hypothesis of random alignment. The observed mean principal angle between the DRN subspace and either the motor-related or sound-related subspace was then compared against the null distribution. Two-tailed empirical p-values were calculated as the proportion of permuted means that were equal to or more extreme than the observed value.

Linear regression

We constructed a linear regression model based on kinematic features extracted from tail motion to quantify how tail movements explain whole-brain neural activity in larval zebrafish. Swimming direction and distance were derived from tail movements, with distance defined as the area swept by the tail during a bout and direction defined as the cumulative tail bending angle within a single bout. Based on these two parameters, a polar coordinate system was constructed, and swimming bouts were classified into 12 discrete types.

For each bout type, a corresponding binary regressor was generated, which took a value of 1 during the occurrence of that bout and 0 otherwise. Each regressor was then convolved with the experimentally measured jGCaMP8s calcium response kernel. The resulting regressors formed the matrix X.For each neuron, the linear regression model was defined as

where y(t) denotes the neural activity time series, Xi(t) represents the convolved regressor for the i-th bout type, βi is the corresponding regression coefficient, β0 is the intercept, and ε(t) denotes the residual error.

Model fitting was performed using the MATLAB function fitlm with ordinary least squares estimation. The coefficient of determination (R2) was calculated for each neuron to quantify the proportion of variance in neural activity explained by motor behavior.

For each fish, to avoid confounding effects, only tail movement data recorded during the baseline period without optogenetic stimulation or auditory stimulation were used to construct the model. Fish whose baseline tail movements were insufficient to cover all 12 bout types were excluded from further analysis. Motor-related neurons were then identified based on both the proportion of variance in neural activity explained by movement (R2) and their weights in the motor-related subspace. To quantify the effect of optogenetic stimulation on motor-related neurons, the model fitted during the baseline period was used to predict their neural activity during both the control (no stimulation) and DRN 5-HT activation periods.

Hyperbolic and Euclidean Multidimensional Scaling

We analyzed the geometry of motor population activity using multidimensional scaling (MDS) on pairwise neural correlation distance matrices, normalized to [0, 2] for consistent scaling across conditions.

Our main analysis used Bayesian hyperbolic MDS (HMDS) to embed the data in a Poincaré ball, following Praturu et al. (58). Using the metric_HMDS Python library, we jointly optimized the embedded coordinates and a global curvature parameter λ (constant negative curvature K = − λ2) so that hyperbolic distances δij best matched the neural distances Dij:

The embedding dimension (d = 6) was chosen by minimizing the Bayesian Information Criterion (BIC) over candidate dimensions, defined as

where is the maximized model likelihood, k is the number of free parameters, and n is the number of observations. For a distance matrix of N points, n = N (N − 1)/2. For the HMDS model with embedding dimension d, the effective number of parameters is

accounting for N points in d dimensions, one global curvature λ, N point-specific uncertainty parameters, and adjusting for the rotational symmetry of hyperbolic space. For comparison, we applied classical Euclidean MDS (scikit-learn, dissimilarity=‘precomputed’, metric=True) with the same dimension. Its BIC used N × d coordinate parameters and one global variance parameter.

To estimate intrinsic variability in pairwise neural correlation distances from non-stationary brain dynamics, we performed a time-window–based uncertainty analysis. Each recording was divided into non-overlapping 60 s windows. For each window, we computed population activity vectors and the corresponding pairwise correlation distance matrix. We then calculated, for each unique pair, the variance of its distance across windows, yielding a distribution of temporal stability. This produced a variance matrix ΣD with the same dimensions as the averaged distance matrix D, where ΣD(i, j) is the empirical temporal variance of the distance between neurons i and j. These variance estimates were incorporated into both HMDS and Euclidean MDS by weighting each pairwise distance in the likelihood function inversely by its variance.

We visualized the embeddings to interpret the geometry. For dimensions > 3, we projected the coordinates into 3D using PCA and displayed them within the Poincaré ball. Embedding quality was evaluated with Shepard diagrams, plotting original distances against embedded distances.

Statistical analysis

Wilcoxon matched-pairs signed rank test and Mann–Whitney U test were used and data are expressed as the mean ± min-max in Fig. 2C. Mann–Whitney U test was used and data are expressed as the mean ± min-max in Fig. 2D and Fig. 3D. Wilcoxon matched-pairs signed rank test was used in Fig. 4B. P-values obtained via a nonparametric permutation test in Fig. 4F. Data are expressed as the mean ± SD in Fig. 1B, Fig. 2B, Fig. 5B, Fig. 5C.

Supplementary figures

DRN 5-HT activation suppresses locomotion and induces a quiescent state distinct from sleep.

A. Schematic of burst and tonic optogenetic stimulation paradigms. B. Top: locomotor speed of a zebrafish during burst stimulation. Bottom: locomotor speed of a zebrafish during tonic stimulation. C. Relationship between body roll angle and swimming speed in Tph2:ChrimsonR zebrafish. Each point represents one second; yellow points indicate periods of DRN 5-HT activation. D. Relationship between body roll angle and swimming speed in sleep-deprived zebrafish. E. Quiescence per hour in Tph2:ChrimsonR zebrafish. F. Quiescence per hour in control zebrafish.

DRN 5-HT activation did not alter neural dynamics within the sound-evoked subspace.

A. Temporal evolution of whole-brain neural activity projected onto the sound-evoked subspace and the motor-correlated subspace in an example Tg(tph2:ChrimsonR) zebrafish. Yellow shading indicates periods of optogenetic stimulation. B. Similarity matrices of sound-evoked neuronal population responses during DRN 5-HT activation and control periods for fish 2–4 (fish 1 shown in Fig. 4E). C. Same analysis as in panel B, but comparing the awake state with the drug-induced sleep state. D. Schematic of auditory stimulation paradigms with different sound intensities. E. Similarity matrices of sound-evoked neuronal population responses for strong (left) and weak (right) sound stimuli during DRN 5-HT activation and control periods.

DRN 5-HT activation exerts graded suppression on the motor subspace.

A. Relationship between dP C1motor weights and R2. Red points indicate the motor-correlated neurons included in the analysis. B-D. Relationship between DRN 5-HT activation–induced modulation of neural activity and the coefficient of variation (CV) of regression coefficients in motor-correlated neurons for fish 2–4 (fish 1 shown in Fig. 5D–E).

DRN 5-HT activation diversifies motor network activity.

A. Cosine distance matrices of motor-correlated neurons during DRN activation (left) and control (right) periods. Neural activity magnitude was quantified by the variance. Neurons were ranked by changes in variance between DRN 5-HT activation and control periods. B. Embedding dimension as a function of BIC, see Methods. C. Shepard diagram showing pairwise distances in the embedding space vs. data pairwise distances in A during DRN activation. Left: Euclidean embedding, BIC = -210054; Right: Hyperbolic embedding, BIC = -227165. The dimensionality d = 6. D. Same as C, but during control period.

Data availability

The data will be made available upon publication of the paper.

Acknowledgements

The authors are grateful to Danqian Liu for experimental suggestions, Yu Mu for sharing the optogenetic fish line, Takashi Kawashima for sharing unpublished datasets, and Rubén Moreno Bote for discussions. This research was supported by the STI2030–Major Projects (Grant No. 2022ZD0211900), under the subproject “New Technologies for Whole-Brain-Scale Neuronal Mesoscopic Atlas” (Grant No. 2022ZD0211904).