Introduction

Yawning is a fixed action pattern widespread across vertebrate taxa including fish (Salvelinus leucomaenis)1, amphibians (Pheognathus hubrichti)2, reptiles (Geochelone carbonaria)3, birds (Melopsittacus undulatus)4, and mammals (Homo sapiens5, Pan troglodytes6, Mandrillus leucophaeus7, Panthera leo8). The evolutionary conserved trait of yawning and its presence at an early ontogenetic stage2,9 suggest the importance of this behavior in physiological regulation processes10. In endothermic species, three different phases have been operationally identified during a yawning event i) slow mouth opening and air inhalation, ii) maximum jaw stretching for a short period (acme), and iii) rapid mouth closing and air exhalation5,8,11, although some emerging data are indicating a certain degree of variability in the yawning execution12,13,14. Despite its apparent simplicity and automaticity, one of the most challenging aspects in the study of yawning in species living in different environments (terrestrial vs aquatic)15 and phylogenetically distant to humans is the unbiased detection of the behavior.

Yawning seems to be involved in the regulation of various physiological functions. It is suggested to have originally evolved as a thermoregulatory mechanism, particularly in endotherm vertebrates like mammals and birds16,17,18. Moreover, the behavior has been linked to physiological arousal, increasing heart rate and intracranial circulation through deep inhalation and jaw stretching19,20 and to brain cooling promoting wakefulness and cognitive performance16,21. Although most of the research on yawning has focused on endotherms, there is increasing evidence that yawning in ectotherms may also play a role in physiological state regulation such as thermoregulatory functions22. For instance, studies on ectotherm species have shown that yawning often occurs before a shift in behavioral states, suggesting a role in preparing for increased activity (fish1,23,24; amphibians2,25 and reptiles22). In endotherms, the state-change hypothesis posits that yawning functions as a mechanism to induce a behavioral transition from resting to activity, thus increasing physiological arousal (macaques12; drills7; chimpanzees13, lions8).

If yawning is widely observed across vertebrates, yawn contagion, the phenomenon of responding to others’ yawns with a yawn, has frequently been reported in endothermic social species5,20,26,27. To our knowledge, the only study focusing on yawn contagion in an ectotherm species (red footed tortoise, Geochelone carbonaria3) failed to find the phenomenon. One of the most parsimonious explanations for yawn contagion is the ‘chameleon effect,’ which posits that perceiving a behavior leads the observer to unconsciously imitate the gesture, aligning individuals’ activities26,27,28. Recent studies also indicate that yawn contagion may play a role in synchronizing group behavior. In lions (Panthera leo), yawn contagion among group members facilitates behavioral alignment, ensuring synchronized activity8. Such behavioral synchronization is vital for maintaining social cohesion and plays a key role in the cooperative dynamics of social species27,28. Despite being the subject of intense and lively scientific debate29,30,31, yawn contagion seems also to be involved in some empathic processes, being considered a phenomenon driven by emotional contagion, a building block of empathy32,33.

To understand the evolutionary roots of yawn contagion, we explored these phenomena in the zebrafish (Danio rerio), a freshwater fish, that are a valuable model in behavioral neuroscience research, complementing mammalian systems34,35, also considering that they share over 70% of genes with humans36. Due to its social habits and ability to transmit emotions to group members37,38, the species is highly suitable for studying yawn contagion, which has never been demonstrated in any ectothermic species3.

Spontaneous yawning has been already qualitatively described in fishes1,39. However, since clearly identifying yawning from simply breathing actions in aquatic vertebrates is challenging, some authors refer to the behavior as “mouth gaping” or “yawn-like” pattern40,41.

Here, we employed a deep learning approach to objectively distinguish yawning from breathing events in zebrafish. After clearly identifying yawning using a convolutional neural network (CNN), we experimentally tested for the presence of yawn contagion by using the previously deep learning-based classification of yawning and breathing events to create video stimuli.

Results

Deep learning classification of yawning and breathing events

We recorded videos lasting about 30 min for each of three groups of six adult zebrafish. Here, based on the existing literature1, we define yawning in fish as comprising three distinct phases: 1) mouth opening slowly and widely, reaching the maximum mouth size 2) mouth gaping typically accompanied by the expansion of the gill covers and by a noticeable stretching of the jaw, 3) rapid mouth closing. To empirically validate this distinction, we analyzed videos frame-by-frame and measured the duration of each yawning phase. Our results confirm that the third phase, characterized by rapid mouth closing (0.143 s ± 0.099), is consistently shorter than the first phase (0.339 s ± 0.148) as already reported for other vertebrate species12,14,15. A summary of the durations for the phases of each yawning event is provided in Supplementary Table 1.

We collected a total of 136 yawning and breathing events from all 18 individually identified subjects (Nfemales = 9; Nmales = 9). All the 136 yawning and 136 breathing events analyzed frame-by-frame were considered to start in correspondence with the first frame in which the lips appeared parted and to end in the correspondence with the frame in which the lips appeared closed. The goal was to extract a total of 11 frames centered around the acme of the event of interest (yawning or breathing), with 5 frames before and 5 frames after the specified moment. Then, these frames were utilized to fine-tune a CNN model (YOLOv8n) for the classification of different behaviors.

The CNN model was fine-tuned to classify three behaviors: yawning, breathing, and mouth closing (MC). Early stopping occurred at epoch 166 out of 200 since no further improvements were detected, with 36.8 ms of inference time, and a computational time of 7.135 h using an Apple M2 Pro CPU (Fig. 1a–c). The optimal network configuration has 73 layers, a total of 1,438,723 parameters, and a computational complexity of 3.3 GFLOPs. The proposed approach achieved an accuracy of 89% on the validation set. The CNN achieved a perfect 100% precision, recall, and F1-score for the mouth closing class, while for the breathing class, the network obtained a precision of 83%, recall of 85%, and F1-score of 84%. For the yawning class, the precision was 84%, recall 82%, and F1-score 84% on the validation set. On the test set, the CNN maintained a perfect 100% precision, recall, and F1-score for the mouth closing class. The CNN achieved a precision of 80%, recall of 86%, and F1-score of 83% for the breathing class, while for the yawning class, the network obtained a precision of 85%, recall of 78%, and F1-score of 81%. Overall, the CNN achieved an accuracy of 88% on the test set.

Fig. 1: Demonstrating the difference between yawning and breathing events.
figure 1

Performance of the CNN model in the classification task: training and validation loss curves show the model learning progress over epochs; the average accuracy achieved on the validation set is shown over epochs, along with the top accuracy among the three classes (A). Normalized confusion matrices for the validation (B) and test (C) sets. The boxplot (D) represents the duration of yawning (Y, light green) and breathing events (B event, light blue). Individual scores are shown as colored points. The boxes display the median value and first and third quartiles, whiskers are extended to the most extreme value inside the 1.5-fold interquartile range. A zebrafish (E) during mouth closing (MC) at the center of the image, during a breathing event (B) on the left and during a yawning event (Y) on the right. Credits for the drawings: Fosca Mastrandrea.

Basically, the deep learning classification overlaps with the a priori classification made by the two operators (A.G. and S.A.). Supplementary Fig. 1 presents twelve representative prediction samples selected from the test dataset, categorized by class (yawning, breathing, mouth closing) in descending order. These visually demonstrate the network’s ability to accurately classify the three target behaviors.

Yawning and breathing differ in their duration and motor actions

The duration of yawning and breathing events was compared (Linear Mixed Model, LMM, MODELduration). To investigate whether the DURATION (dependent variable, Gaussian distribution) differed between yawning and breathing, we compared a full model including yawning/breathing as fixed factor and the identity of the subjects (IDfish) as random factor with a null model including only the random factor. The models significantly differed (likelihood ratio test: χ2 = 195.97, df = 1, P < 0.01; Supplementary Table 2; Fig. 1d), with yawning events (00:00.92 s ±00:00.42 SE) lasting longer than breathing events (00:00.16 s ±00:00.02 SE). See Supplementary Data 1.

Additionally, out of a total of 136 yawns, in 75 cases (55.15%) we observed that yawning was not only associated with a mouth movement but also with appendage motor actions such as fin stretching and tail lowering (Fig. 1e; Supplementary Movie 1 and 2). The mean duration of fin stretching and tail lowering was 0.247 s, with a minimum of 0.014 and a maximum of 1.096 s. Notably, fin stretching and tail lowering always occurred within the entire duration of the yawn; there were no instances where these bodily motor actions started before the onset or ceased after the end of the yawn (Fig. 2a). Fin stretching and tail lowering were never recorded during breathing events (Fig. 1e; Supplementary Movie 3).

Fig. 2: Fin stretching and tail lowering during yawning.
figure 2

The panel (A) is a descriptive illustration showing that a fin stretching and tail lowering event always falls within the yawning time window. In the panel (B) the boxplot depicts the duration of yawns with (red) or without (yellow) the stretching event. The dots represent raw data points. The boxes display the median and the first and third quartiles, with whiskers extending to the most extreme values within 1.5 times the interquartile range.

Yawning with stretching lasts longer than yawning without stretching

To investigate whether the DURATION (dependent variable, Gaussian distribution) differed between yawning characterized by the presence/absence of stretching phase, we compared a full model including the presence of stretching phase as fixed factor and the identity of the subjects (IDfish) as random factor with a null model including only the random factor (Linear Mixed Model, LMM, MODELstretching). The models significantly differed (likelihood ratio test: χ2 = 34.149, df = 1, P < 0.01; Supplementary Table 2; Fig. 2b), with yawning events characterized by the presence of stretching phase lasting longer than yawning without this phase. See Supplementary Data 2.

Yawn contagion

To create the video stimuli for the yawn contagion experiment, we used the yawning and breathing events previously classified by the CNN. The stimuli were then edited using DaVinci Resolve 19 software: a 4-min experimental video (Yawningvideo) featuring the demonstrator performing yawning events, which included three repetitions of an empty tank period (1 min) alternated with three repetitions of 10 yawning events. The control video (Breathingvideo) was built following the identical protocol but for the presence of breathing events instead of yawning events (Fig. 3a). We tested 12 females and 10 males over eight different days. Each fish was tested with both stimuli (Breathingvideo and Yawningvideo) on the same day with a minimum interval of six hours.

Fig. 3: Yawn contagion in zebrafish.
figure 3

The (A) part of the figure illustrates the experimental setting. Each gray box represents 25 s of empty tank image, each light blue box illustrates 10 breathing events, and each light green box illustrates 10 yawning events. The observations were conducted for 13 min starting from the last breathing or yawning event of the first block. The boxplot (B) shows the median of the number of yawns recorded under the two different conditions: the control (Breathingvideo, light blue) and experimental (Yawningvideo, light green). The dots show raw data. The boxes display the median value and first and third quartiles, whiskers are extended to the most extreme value inside the 1.5-fold interquartile range.

We ran a Generalized Linear Mixed Model (GLMM, MODELcontagion) to investigate whether the Yawning NUMBER (response variable, Poisson distribution with Zero-inflation) was more likely under Yawningvideo than Breathingvideo. The full model included CONDITION (Yawningvideo/Breathingvideo), SEX of the tester (male/female), ORDER OF TREATMENT (sequence in which stimuli were presented), and TIME of day (morning/afternoon) as fixed factors and IDfish as a random factor. This model was compared with a control model including all the fixed factors but CONDITION and SEX. The full model significantly differed from the control model (likelihood ratio test: χ2 = 9.467, df = 2, P = 0.008; Supplementary Table 3). The results show that the probability to obtain a yawn response under Yawningvideo was higher than during Breathingvideo (Fig. 3b). See Supplementary Data 3.

As a further control, we tested whether the likelihood of a breathing event differed between the Yawningvideo and the Breathingvideo conditions. The full and the control models for the MODELcontrol-contagion were built in an identical way to the MODELcontagion. We found that the full model did not significantly differ from the control model (likelihood ratio test: χ2 = 0.793, df = 2, P = 0.672). See Supplementary Data 4.

Yawn response latency

Latency was defined as the difference between the exact time-interval from the end of the first stimulus yawn to the onset of the response yawn. We ran a Generalized Linear Mixed Model (GLMM, MODELlatency_first) to investigate whether the LATENCY of the first yawn response (response variable, Poisson distribution) was shorter in Yawningvideo than in Breathingvideo. The full model included CONDITION (Yawningvideo/Breathingvideo), SEX of the tested subject (male/female), ORDER OF TREATMENT (sequence in which stimuli were presented), and TIME of day (morning/afternoon) as fixed factors and IDfish as a random factor. This model was compared with a control model including all the fixed factors but CONDITION. The full model significantly differed from the control model (likelihood ratio test: χ2 = 11.116, df = 1, P < 0.01; Supplementary Table 4). The results show that the latency of the first yawn response was shorter in Yawningvideo than in Breathingvideo (Fig. 4a). See Supplementary Data 5.

Fig. 4: Latency of yawn responses.
figure 4

A Violin plot showing the distribution of the first yawn response latency (A) and the latencies for all yawn responses (B) under the two conditions: Yawn Condition (Yawningvideo, light green) and Control Condition (Breathingvideo, light blue). The dots show raw data. The violin plot displays the distribution of a numerical variable through its estimated density. The colored areas represent the data distribution, with its width indicating the estimated density of values at each level.

We repeated an identical model with all the yawn responses present in each trial as response variable to assess if the yawn responses are more time-blocked under the Yawningvideo compared to the Breathingvideo. The full and the control models for the MODELlatency_all were built in an identical way to the MODELlatency_first (Supplementary Table 4). We found that the full model significantly differed from the control model (likelihood ratio test: χ2 = 9.643, df = 1, P < 0.001) indicating that the latency of the yawn responses was shorter under Yawningvideo than during Breathingvideo (Fig. 4b).

Behavioral state change

A behavioral state change was considered when, within the second following the yawn, there was a change in direction (shift in movement orientation) or activity (from a stationary state to movement, or vice versa). We ran a binomial Generalized Linear Mixed Model (GLMM) to assess whether yawning with or without stretching influenced the probability of an immediate behavioral state CHANGE (response variable, binomial distribution). The full model included presence/absence of STRETCHING and the CONDITION (Yawningvideo/Breathingvideo) as fixed factors and IDfish and TRIAL NUMBER as random factors. The full model was compared with a control model including the CONDITION and the random factors. The full model significantly differed from the control model (likelihood ratio test: χ² = 25.414, df = 2, p < 0.001; Supplementary Table 5). The results showed that yawns accompanied by stretching were more likely to be followed by a change in behavioral state (Fig. 5).

Fig. 5: Yawning and behavioral state change.
figure 5

The bar plot shows the proportion of a behavioral state change following yawning events as a function of presence (blue) and absence (orange) of stretching.

Discussion

The CNN has intercepted with a high level of accuracy the differences between yawning and breathing events in zebrafish thus confirming that the yawning event is present as a distinct pattern in this species. Moreover, a yawn differed from a breathing event in the duration of the motor execution implying a profound mandibular stretching accompanied by the protrusion of oral bones. Such motor patterns are strongly similar to those recorded during yawning in other vertebrates10. Additionally, further motor bodily components involving fin stretching and tail lowering were present in more than half of yawning events (55%) (Fig. 1e, Supplementary Movie 1 and Supplementary Movie 2) and always started after the onset of the mandibular stretching (Fig. 2a). Moreover, those yawns including fin and tail stretching lasted longer than those without such bodily motor activation (Fig. 2b). Stretching different body districts while yawning is a phenomenon known as pandiculation or stretch-yawning syndrome, well reported in many mammals39 and birds41. In terrestrial vertebrates, pandiculation has a role in re-activating the central nervous system after resting periods thus preparing organisms to properly and rapidly react to environmental stimuli. Such re-activation seems to be present also in zebrafish. The analysis of the behavior state change after a simple yawn and after a yawn accompanied by body stretching revealed that the probability of a behavioral shift was higher in the latter than the former situation (Fig. 5). It is difficult to say if yawning and pandiculation are homologous traits across vertebrate taxa, however, the evidence of these phenomena in zebrafish suggests possible convergences in their functions1. A further interesting issue regarding spontaneous yawning in ectotherms is its covariation with temperature and physiological arousal, as recently demonstrated in reptiles22. This finding appears to align with the data already available for endotherms.

Our data indicate that yawn contagion is present in zebrafish that were more than twice as likely to yawn while visually detecting others’ yawns. An incidence which is very similar to that reported for humans5. We found not only that the yawning responses were significantly higher during Yawningvideo compared to Breathingvideo, but also that the latency of responses were shorter in the former than in the latter condition (Supplementary Table 4, Fig. 4). The deep learning analysis made us confident that the Yawningvideo and Breathingvideo provided to the tested fish actually included the yawning and breathing stimuli, respectively. Moreover, the environmental conditions (e.g., temperature, light-dark yawn contagion, pH, manipulative phases, tank uniformly illuminated) were kept constant across all stages of the experiment, and the experiments were conducted away from feeding phases. Therefore, the differences in the number of yawns emitted in the yawning and breathing conditions can be ascribed to the different visual dynamic components of the stimulus administered and not to other environmental stimuli. The ability to visually perceive the yawns of others aligns with the zebrafish visual perception capabilities, which are, from a neural perspective, particularly sophisticated and complex42.

The presence of yawn contagion in fish raises thought-provoking evolutionary questions, thus inviting deeper reflection particularly regarding the origin of the phenomenon. According to evolutionary biology theories, yawn contagion may have two possible origins. On one hand, its demonstration could trace the origins of this motor resonance phenomenon back in evolutionary history, at least coinciding with the emergence of modern teleosts (200–250 million years ago), followed by the secondary loss of this trait in certain taxa (absence of yawn contagion: Geochelone carbonaria3, Corvus corax43, Gorilla gorilla44; presence of yawn contagion: Melopsittacus undulatus45, Pan paniscus46). On the other hand, it may represent a result of convergent evolution, with yawn contagion emerging independently in different evolutionary lineages as a response to the need for synchronization of motor actions within social groups. Further studies on other vertebrate taxa (e.g., amphibians) could help address the intricate issue on the evolution of contagious yawning.

Yawn contagion in zebrafish can be interpreted in light of both proximate (e.g., social cognitive abilities) and ultimate factors (e.g., evolutionary advantages) (sensu Tinbergen47). Recent studies on this species’ ability to share others’ emotional states48, whether positive or negative49, reveal intriguing parallels with mammalian neural systems involved in emotional contagion, which is well-documented in humans50. Zebrafish can share the fear or distress of others both behaviorally and physiologically. They are more likely to engage with distressed individuals than with those in neutral states, even though the distress may signal potential risks51. The approaches of zebrafish towards distressed individuals can provide various tangible benefits to the interacting agents such as stress buffering35, enhanced vigilance, attack mitigation, and antipredator advantages52.

The presence of yawn contagion in zebrafish may also be explained by its potential evolutionary advantages. Yawning serves as a dependable predictor of upcoming behavioral state changes52,53 and there are empirical data showing that yawn contagion between two agents facilitates their subsequent behavioral alignment7 and vigilance state54. Synchronization at a group-level derives from synchronization at the dyadic level32. In line with the concept of perception-action coupling proposed by de Waal and Preston33, the ability to mirror the behaviors of others becomes exceptionally beneficial for animals whose survival and reproductive success depend on qualities like unity and social connection. Synchronization makes the school formation and maintenance possible in fish. Schooling acts as a vital cohesive social system offering numerous advantages, such as decreased risk of predation (e.g., vigilance, dilution effect) and enhanced efficiency in food searching54. Although it remains uncertain whether yawn contagion enhances spatial and social alignment, its presence in zebrafish hints at potential implications for their social behavior. It would be interesting to investigate whether yawn contagion occurs in solitary fish species that do not engage in schooling or shoaling. This could help determine if and to what extent social synchronization plays a role in the emergence of this motor resonance phenomenon.

In sum, here we overcame the challenges of detecting and classifying yawns in fish using a deep learning model thus underlining the importance of artificial intelligence in comparative studies. Then, we obtained robust results, consistent across diverse experimental conditions in highly controlled environments, demonstrating that yawn contagion in zebrafish is not a mere coincidence but a genuine motor resonance phenomenon. Our findings challenge the prevailing assumption that yawn contagion is confined to mammal and bird species thus opening new avenues for exploring the neurobiological mechanisms underlying this phenomenon and its potential functions from an evolutionary perspective.

Methods

Zebrafish care

Zebrafish AB strains adults were housed in 3.5-liter tanks (28 cm ×11 cm × 17 cm) in social groups of 16 fishes per tank on a 14 h light/10 h dark yawn contagion. Fish water was maintained at a constant temperature of 28 °C, with a pH of 7.2 and conductivity of 700 μS. Zebrafish were fed twice daily with dry pellets and brine shrimp. On the day of the experiment, the fish were fed 12 h prior to the test. Husbandry and experimental procedures were carried out in accordance with European Legislation for the Protection of Animals used for Scientific Purposes (Directive 2010/63/EU), the Italian (D.lgs. 26/ 2014) animal protection standards, and the local Ethical Committee of the University of Pisa (authorization n.99/2012-A, 19.04.2012).

Deep learning classification of yawning and breathing events

We collected videos of 18 subjects, each individually identified by their body size, colors, and stripe patterns. Video recordings were conducted over three different days at various times of the day in a quiet room. The videos commenced after a 1-h acclimation period to habituate the fish to the presence of the video camera. A full HD video camera (Sony FDR-AX43A) was consistently mounted on a stand to ensure high video quality. Videos were analyzed via Pot-Player software that allows slowing down the frames of interest. We recorded all the yawning events and the same amount of breathing events per each subject. For each event, we listed: i) the exact time of the day, ii) the identity of the yawner, iii) notes about the good visibility of the display.

Inter-observer reliability was calculated throughout the analysis. Every 30 yawning and breathing events, 5 events were randomly selected and independently scored by two observers. Cohen’s κ reached a score of 0.98 for the yawning events and 0.94 for the breathing events.

We selected the events on the basis of the best quality images obtaining 1080 frames from 18 subjects. To extract the 11 specific frames from each yawning and breathing event, we utilized the ‘subprocess’ module in Python to execute the FFmpeg command. The frames were used to fine-tune a CNN for the classification of different behaviors.

The model was fine-tuned to accurately differentiate yawning from other events (breathing/mouth closing) in zebrafish, ensuring precise and unbiased identification for further analysis. We chose the YOLOv8n (You Only Look Once, version 8 nano) model due to its exceptional performance in object detection, especially in real-time applications. YOLOv8n offers a good balance between detection accuracy and computational efficiency, making it suitable for processing large datasets like ours, where precise classification of similar behaviors is required. This model also has a well-documented architecture and training process, which supports the replicability of our study. The model was fine-tuned using frames previously extracted from the video data collected. Data augmentation techniques were applied to increase the diversity of the training data, thereby improving the model’s robustness to variations in the visual presentation of the events. The model was fine-tuned using a pre-trained version of YOLOv8n (nano), which had been trained on the ImageNet dataset. The selected model leverages a CNN architecture comprising three core components: backbone, neck, and head. The backbone, a modified CSPDarknet53, employs a feature pyramid network to facilitate multi-scale object detection. The pre-trained model, consists of 99 layers, 1,442,131 parameters, with a computational requirement of 3.4 GFLOPs. The dataset, containing 1080 images evenly distributed across three classes (yawning; breathing, and mouth closing events), was divided into training, validation, and testing sets with a 70-20-10 ratio. For the training process, we used a batch size of 32 over 200 epochs, implementing early stopping with a patience of 100 to prevent overfitting. Standard data augmentation techniques were applied. Model evaluation encompassed loss, accuracy, precision, recall, and F1-score metrics. The detailed documentation of our training process, model selection, and data handling methods ensures that this phase of the study is replicable. Training and subsequent analyses were executed using Ultralytics in Python.

Yawn contagion

To create Yawningvideo and Breathingvideo, we used the yawning and breathing events classified by the CNN (see Results for details). We also edited a 10-min video of the housing tank without fish, used as a background video during acclimatization. During the tests, the videos were displayed on monitors as life-size images. The experiments were conducted in a test tank (13 × 28 × 7 cm), illuminated by a LED which provided a homogeneously diffused light, with an LCD monitor (RedMi Note 11 Pro 5 G or iPhone X) placed on one of the two long sides of the tank, visible through the glass walls. The remaining part of the tank was covered with black cardboard sheeting to block light and prevent visual interference from external stimuli. The focal fish were kept in overnight isolation, housed individually in the test. The following day, after correctly positioning the monitor, a camera (SONY FDR-AX43A 4K) was placed on the opposite side of the monitor. Recording was started just before the stimulus began. Each fish was tested with both stimuli (Breathingvideo and Yawningvideo) on the same day with a minimum interval of 6 h. The fish were tested with one of the two stimuli in random order after a coin toss. The focal fish (N = 22) were not familiar with the demonstrators in the video (i.e., they never had prior contact). During the entire duration of the experiments, no one had access to the laboratory. The videos of the tested subjects were then analyzed using the same methods previously employed. All the yawning and the breathing events were classified and counted by AG and SA obtaining the following inter-observer variability scores: 0.97 for the yawning events and 0.95 for the breathing events.

Subsequently, the yawning and breathing events, independently classified by two authors, were evaluated using the deep learning model to assess the accuracy of the initial classifications made by the operators.

Statistics and reproducibility

Modelduration

To examine whether yawning and breathing events differ in their duration, we ran a LMM (glmmTMB R-package55; Version 1.4.1717). As for the variables included in the model see Results.

Modelstretching

To test whether yawning with stretching phase and yawning without stretching phase differ in their duration, we ran a LMM (glmmTMB R-package55). As for the variables included in the model, see Results. For this model and the previous one we verified the normal distribution and homogeneity of the model’s residuals by looking at the Q-Q plot and plotting the residuals against the fitted values.

MODELcontagion

To test for the presence of YAWN CONTAGION (number of yawns under Yawningvideo and Breathingvideo conditions), we ran a GLMM56. As for the variables included in the model, see Results. We found no evidence of collinearity among the fixed factors (VIFmin = 1.02; VIFmax = 1.11). As a further control, we also ran a second GLMM (MODELcontrol-contagion), in which the response variable was the number of breathing events under Yawningvideo and Breathingvideo conditions. As for the variables included in the model, see Results. We found no evidence of collinearity among the fixed factors (VIFmin = 1.02; VIFmax = 1.11).

MODELlatency

To test for the LATENCY of the first yawn response under Yawningvideo and Breathingvideo conditions, we ran a GLMM56. As for the variables included in the model, see Results. We found no evidence of collinearity among the fixed factors (VIFmin = 1.02; VIFmax = 1.08).

MODELchangestate

To test for the probability of having a behavioral CHANGE state after a yawn with stretching or without under Yawningvideo and Breathingvideo conditions, we ran a GLMM56. As for the variables included in the model, see Results. We found no evidence of collinearity among the fixed factors (VIFmin = 1.01; VIFmax = 1.81).

By using a likelihood ratio test (LRT, Anova with argument test “Chisq”57), we tested the significance of each full model57. Then, the p-values for the individual predictors were calculated based on the likelihood ratio tests between the full and the null/control model by using the R-function Anova in the R-package car 3.0-1058.

To ensure reproducibility, our study employed a rigorous experimental design with 18 zebrafish (AB strain) individually identified by body size, coloration, and stripe patterns. Video recordings were conducted over three separate days at different times, with each subject tested under controlled conditions following a standardized protocol. To minimize variability, fish were acclimated for 1 h before testing, and all experiments were conducted in a quiet, controlled environment. Husbandry conditions were meticulously maintained. All behavioral events (yawning and breathing) were manually annotated and validated through inter-observer reliability checks (Cohen’s κ = 0.98 yawning, 0.94 breathing) to enhance accuracy. To facilitate replication, all video data, annotation workflows, and deep learning classification models (YOLOv8n) were documented and executed using standardized pipelines in Python. The complete dataset was divided into training, validation, and testing subsets following a 70-20-10 split, ensuring balanced representation across behavioral categories. For testing yawn contagion, we used a double-control approach. Each fish was tested with both stimuli (Yawningvideo and Breathingvideo). Additionally, we ran a control model to verify that breathing responses did not differ between conditions, confirming that the observed yawning responses were specific to the yawning stimulus.

Reporting summary

Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article.