Abstract
Male Drosophila courtship behavior is a key model for studying temporal decision-making. While courtship index (CI) is widely used to quantify mating activity, other timing metrics like courtship latency, copulation latency (CL), and mating duration (MD) remain understudied. Traditional methods for quantifying these behaviors are often labor-intensive and prone to human error.
In this study, we present a protocol combining a modular chamber system and automated software (DrosoMating) to quantify 6 key timing metrics during male courtship. High-resolution video tracking enable precise analysis of courtship initiation, persistence, and mating dynamics under controlled conditions. Validation shows <0.05% error rates and 98–99% agreement with manual scoring for CL, CI, and MD. The protocol supports genetic and neural circuit manipulations, detecting subtle genetic, social, and environmental behavioral variations.
By minimizing manual effort and standardizing data collection, this approach facilitates scalable, reproducible studies on adaptive trade-offs, learning, and neural mechanisms in mating behavior. This method streamlines timing analysis in male courtship, offering reproducible metrics for behavioral genetics.”
Highlight
A fully automated, high-throughput software pipeline for the continuous detection and temporal profiling of Drosophila melanogaster mating behaviour.
An accompanying, open-hardware platform that can be assembled at minimal cost while maintaining experimental rigor.
The system attains near-manual accuracy and outputs Temporal Measurement Parameters data that are readily adaptable to—and quantifiable within—diverse behavioural paradigms.
Introduction
Time perception is critical for survival, enabling organisms to estimate intervals between events and execute adaptive behaviors. Male Drosophila courtship behavior, a genetically well-characterized model (Singh and Singh, 2016), provides a robust framework for studying temporal control in action sequences. A widely used metric to quantify mating activity is the ‘Courtship Index (CI)’, defined as the percentage of time a male engages in courtship behaviors (e.g., following, wing vibration, abdominal curling) toward a female during a standardized observation window. CI reflects both the intensity and persistence of courtship, serving as a sensitive readout for dissecting genetic, environmental, or experimental perturbations on mating behavior, as demonstrated in studies investigating genetic mutations, environmental perturbations, and neuronal manipulations (Benton, 2015; Greenspan and Ferveur, 2000a; Kim, 2009; Pavlou and Goodwin, 2013; Yamamoto and Koganezawa, 2013).
Despite extensive research on courtship displays (Chen et al., 2024a), other critical metrics remain poorly characterized, especially as their representative characteristics as timing behaviors. ‘Courtship latency’ (time until a male initiates courtship after detecting a female) may reflect motivational state or sensory processing deficits but is rarely quantified in terms of genetics (Eastwood and Burnet, 1977a). ‘Copulation Latency (CL)’ (time from courtship initiation to successful mating) and ‘Copulation (Mating) Duration (MD)’ (length of mating itself) are similarly underexplored, though both likely impact reproductive success. Prolonged MD enhances paternity assurance by maximizing sperm transfer and suppressing female remating, but it simultaneously increases predation risks and energy expenditure (Bretman et al., 2009). Conversely, reduced MD may decrease a male’s paternity share due to incomplete sperm transfer or female resistance, yet it reduces exposure to ecological threats (e.g., predators, rivals) and conserves metabolic resources (Lee et al., 2023a). These traits may be influenced by cryptic factors such as male age, rival presence, or environmental stressors (e.g., temperature), yet their genetic and neural bases are unclear. While studies focus on stereotyped courtship actions, these “temporal metrics” offer insights into decision-making, persistence, and adaptive trade-offs—areas ripe for investigation (Huang et al., 2024; Kim et al., 2012a, 2013a, 2016, 2024; Lee et al., 2022; D. Sun et al., 2024; Y. Sun et al., 2024; Wong et al., 2019; T. Zhang et al., 2024b, 2024a; X. Zhang et al., 2024).
Numerous software tools have been developed to measure male mating behavior in Drosophila, yet many laboratories still rely on manual methods. Traditional approaches, such as the “courtship wheel”, have been widely used to assess male courtship activity (Hall, 1994; Neckameyer and Bhatt, 2016; Vosshall, 2007). However, quantifying the full repertoire of mating behaviors metrics has historically been labor-intensive (Ejima and Griffith, 2007; Sokolowski, 2001). Recent advances in automation have addressed these challenges. For instance, Dankert et al., introduced a machine vision system to quantify male-female interactions, though its application has been more focused on studying male-male aggression (Dankert et al., 2009a). With the rapid development of machine learning and image processing, tools such as ‘Ctrax’ (Branson et al., 2009), ‘idTracker’ (Pérez-Escudero et al., 2014), Cadabra (Stern et al., 2015), ‘FlyTracker’ and MATLAB combined with ‘JAABA’ (Barwell et al., 2021; Kabra et al., 2013) have enabled precise quantification of male-female mating behavior. Recently, Chen et al., introduced an image-processing-based system that addresses this gap by automatically recognizing multiple courtship elements with high accuracy (>97%) and robust identity tracking even during complete fly overlap(Chen et al., 2024b). Despite these advancements, recent efforts to simplify courtship conditioning protocols (Gil-Martí et al., 2023a) still lack of certain timing-related behavioral repertoires after copulation. Consequently, there is a need for more streamlined protocols and software to accurately measure the timing aspects of male mating behavior in Drosophila.
Beyond Drosophila-specific tools, general behavioral video analysis paradigms have been developed to track the movement and behavior of various organisms, including fruit flies. These methods often focus on tracking the position of single or multiple flies (Iyengar et al., 2012; Qu et al., 2022; Simon et al., 2011) or using artificial markers (Gal et al., 2020). Additionally, programs like ‘ToxTrac’ (Rodriguez et al., 2017), ‘UMATracker’ (Yamanaka and Takeuchi, 2018), ‘FIMTrack’ (Risse et al., 2017, 2014), and ‘ilastik’ (Berg et al., 2019) have been employed to analyze body posture, behavior, location, and movement trajectories in diverse species, including flies, bees, mice, and zebrafish. However, these tools often fall short in capturing the nuanced courtship behaviors of Drosophila, as motion data alone may not sufficiently represent complex interactions.
To address these limitations, we have developed a specialized software called ‘DrosoMating’ suite for analyzing and quantifying timing behaviors within male Drosophila courtship. By establishing 6 key indicators related to male courtship, we provide a robust framework for quantifying male mating behavior metrics under controlled conditions. This approach significantly reduces the time and errors associated with manual identification. Through iterative optimization, our system achieves an error rate of less than 0.05% compared to manual scoring. We believe this toolset offers a novel and efficient method for studying timing in male courtship behavior, providing valuable data and theoretical insights while streamlining the analysis process.
Results
Video-Processing Solutions for Precise Drosophila Identification in Multi-Chamber Setups
Accurate identification of Drosophila individuals is essential for behavioral quantification given their small size. DrosoMating addresses this through three integrated video-processing features that enhance recognition fidelity in multi-chamber environments.
First, an effective recognition region function isolates individual wells as discrete analysis zones (Fig. 1A bottom), eliminating interference from adjacent chambers and background artifacts. Second, an image learning function adapts to phenotypic variability across strains. Operators designate three sample flies (Fig. 1B), enabling the algorithm to internalize strain-specific morphological signatures for improved detection. Third, a manual threshold adjustment function permits post-recognition optimization. Users visually validate automated identifications and dynamically refine sensitivity parameters (Fig. 1C), correcting false positives/negatives. Collectively, these features ensure robust tracking accuracy across diverse experimental setups and genetic backgrounds.

Usage of DrosoMating and CAD Parameters of the Chamber
(A) Typing input speed and input board numbers before selecting analyzing area (upper). Schematic representation of the region selection process (lower). Columns should be selected in a clockwise direction starting from the top left corner.. (B) Selection of reference flies for tracking accuracy. Any three reference flies were chosen for the analysis. (C) Use the X-axis, Y-axis, and threshold regulator to adjust the selection area to fit each well. Click “Enter” to run the program. Output file will be in the video folder: [Video Name]_output_[board numbers].csv (D) CAD exploded 3D view of the chamber instruction. (E) CAD parametric data of the chamber (dimensions in mm). (F) 3D diagram of the completed chamber
Development and Validation of DrosoMating for Automated Drosophila Mating Behavior Analysis
To address the labor-intensive nature, high error rates, and limitations in quantifying complex behavioral metrics during manual observation of Drosophila mating, we developed the software DrosoMating. This tool automates analysis of mating videos recorded in a customized chamber. DrosoMating processes videos to generate a CSV file containing 6 key behavioral metrics: courtship duration, MD, CI, courtship start time, mating start time, and mating end time. While these metrics are individually straightforward, they can be combined to quantify diverse aspects of mating behavior metrics.
DrosoMating enables quantification of specific mating behaviors based on research needs. We focused on three core indices:
Courtship Index (CI): Indicates male courtship investment per unit time. Higher CI values (reflecting longer durations of behaviors like wing vibration or female chasing) suggest stronger male courtship motivation or higher female attractiveness (Greenspan and Ferveur, 2000b).
Copulation Latency (CL): Measures the time from courtship initiation to copulation start. Shorter CL indicates efficient male courtship or high female receptivity. Longer CL may reflect male courtship deficits (Eastwood and Burnet, 1977b), intense female rejection, or environmental stressors (Greenspan and Ferveur, 2000b; Singh and Singh, 2014).
Mating Duration (MD): Represents the copulation period length. Longer MD may enhance sperm competition but increases predation risk and energy costs, illustrating an evolutionary trade-off between reproduction and survival (Greenspan and Ferveur, 2000b).
Together, CI, CL, and MD provide a robust framework for characterizing Drosophila behavioral states during mating. Accurate quantification of these metrics is essential.
Because overlapping behaviors occur frequently during courtship and mating. When flies overlap for ≤15 frames, centroid velocity continuity is used to assign identity; if overlap >15 frames, the region is flagged ‘occluded’ and excluded from CI calculation.
We validated DrosoMating by comparing its output for CI, CL, and MD against values from repeated, corrected manual measurements. Differences between software-generated data and manual data were consistently within 10 seconds for all three metrics, with no statistically significant differences (Fig. 2A-C). Manual quantification of these metrics requires several hours of effort and is prone to substantial human error. In contrast, DrosoMating automates the analysis. After a few minutes of initial setup and configuration, the software generates precise behavioral metrics from mating videos.

Comparison of the Accuracy of DrosoMating with Manual Scoring
(A) Copulation latency (CL) of Canton-S males was analyzed using DrosoMating and compared with manual recordings. DBMs represent the ‘difference between means’ for the evaluation of estimation statistics. Asterisks represent significant differences, as revealed by the Student’s t test (* p<0.05, ** p<0.01, *** p<0.001). See the Background for a detailed description of the CL assays used in this study. (B) Courtship index (CI) of Canton-S was analyzed by DrosoMating and manual recording. CI was measured by [courtship time/ (mating time-courtship time) *100%]. For detailed methods, see the BACKGROUND for a detailed description of the CI assays used in this study. (C) Mating Duration (MD) of Canton-S was analyzed by DrosoMating and manual recording. See the BACKGROUND for a detailed description of the MD assays used in this study.
Validation of DrosoMating Across Diverse Drosophila Strains and Behavioral Paradigms
DrosoMating was adapted to quantify mating behaviors metrics across diverse Drosophila strains and experimental conditions. To evaluate its universality and accuracy, mating interactions were analyzed between virgin females and males of four strains: Canton-S (wild-type), Oregon-R (wild-type), w1118(white eye mutant), and y1 (yellow body color mutant). These lines have been extensively employed as standard inbred strains in research contexts for a prolonged period. Wild-type strains (Canton-S and Oregon-R) exhibited significantly higher CI, CL, and MD compared to w1118 and y1 mutants (Fig. 3A–C). This quantitative assessment revealed markedly reduced activity in mutant males across all three behavioral metrics, consistent with known phenotypic limitations: w1118 males displayed restricted courtship due to visual impairment (Krstic et al., 2013), while y1 males demonstrated suboptimal mating performance, aligning with prior reports of courtship deficits (Drapeau et al., 2006).

Behavioral assays of Drosophila males under different rearing conditions.
(A) CL of Canton-S, w1118, y1, and Oregon-R males. (B) CI of Canton-S, w1118, y1, and Oregon-R males. (C) MD of Canton-S, w1118, y1, and Oregon-R males. For detailed methods, see the background for a detailed description of the mating assays used in this study. (D) CL of group-housed and single-reared Canton-S males. (E) CI of group-housed and single-reared Canton-S males. (F) LMD assays of Canton-S males. In the MD assays, white data points denote males that were group-reared (or sexually naïve), whereas blue data points signify males that were singly reared. The dot plots represent the MD of each male fly. The mean value and standard error are labeled within the dot plot. (G) CL of naive and sexually experienced Canton-S males. (H) CI of naive and sexually experienced Canton-S males. (I) SMD assays of Canton-S males. White data points represent sexually-naïve males and pink data points represent sexually-experienced ones.
The software further validated established behavioral paradigms—Longer Mating Duration (LMD) (Kim et al., 2013b, 2012b) and Shorter Mating Duration (SMD) (Lee et al., 2023b)—using Canton-S males subjected to distinct pre-experimental conditioning. DrosoMating accurately detected expected differences in CL, CI, and MD between LMD (group vs. single housing) and SMD (sexually naive vs. sexually experienced) conditions (Fig. 3D–I), confirming its precision in resolving complex, paradigm-specific mating dynamics.
Quantification of Learning-Memory Dynamics and Neural Circuit Integration Using DrosoMating
DrosoMating facilitates the investigation of learning and memory consolidation in Drosophila through quantifiable behavioral metrics. The Learning Index (LI)—calculated as (Fig. 4A), where CI denotes Courtship Index—provides a standardized measure of experience-dependent behavioral modulation. This transformation of abstract behavior into discrete parameters enables rigorous analysis of neural and behavioral plasticity.

behavioral assays of learning in Drosophila which combined with temperature-dependent temporal activation/inhibition methods.
(A) Learning Index (LI) calculation and experimental design for temperature-dependent activation/inhibition of neural circuits in adult Drosophila. This figure illustrates the experimental paradigm for calculating the LI using CI measurements from sham and trained group. The protocol involves rearing flies at 20°C for four days followed by a one-day exposure to 29°C to activate/inhibit temperature-dependent, genetically-encoded neuronal modulators (for example, shits as inhibitor or TrpA1 as activator). (B) CI of training and sham training MB-247-GAL4/UAS-GFP, MB-247-GAL4/UAS-TrpA1 and MB-247-GAL4/UAS-shits flies. (C) CI of different training days (D1: 1 day, D2: 2 days, D3: 3 days) and sham trained Canton-S flies. (D) CI of different training days (D1: 1day, D2: 2 days, D3: 3days) and sham training orbΔ/orbΔQ flies. (E) LI of Canton-S and orbΔ/orbΔQ males. (F) CI of training and sham training rut2080; UAS-rut, rut2080; GAL4ok107, rut2080; GAL4ok107/UAS-rut flies. (G) LI of rut2080; UAS-rut, rut2080; GAL4ok107, rut2080; GAL4ok107/UAS-rut flies.
The software integrates seamlessly with neural manipulation techniques. For acute temporal control, thermogenetic tools (UAS-shibirets(Kitamoto, 2001), UAS-TrpA1 (Kang et al., 2012)) permit precise activation or silencing of circuits during courtship (Fig. 4B and S1A). Targeted perturbation of mushroom body Kenyon cells, critical for memory processing, revealed immediate behavioral consequences (Fig. S1B–C), elucidating their role in behavioral adaptation.
Established courtship conditioning paradigms (Gil-Martí et al., 2023b; Griffith and Ejima, 2009a; Kamyshev et al., 1999; Reza et al., 2013; Wolf et al., 1998) are robustly replicated, validating DrosoMating’s fidelity in experience-driven behavior. (Fig. 4C). Mutant analyses revealed orb2 (Fig. 4D–E) and rut (Fig. 4F-G) dependence of experience-induced CI reduction, consistent with known memory pathways.”
Chronic neural interventions are enabled via tub-GAL80ts-mediated adult-specific silencing or knockdown (Fig. S1D–F). This approach reveals enduring impacts of sustained circuit modulation on courtship plasticity and memory consolidation. Collectively, DrosoMating bridges behavioral quantification and mechanistic inquiry, advancing exploration of learning-memory interplay through precise, scalable experimental frameworks.
Methods and Materials
Fly Stocks and Husbandry
Drosophila stocks were maintained on standard cornmeal-agar food at 25°C and 60-70% relative humidity, with a 12-hour light/dark cycle. When suppression of temperature-sensitive transgene activity was required (e.g., for UAS-shibirets or UAS-TrpA1 experiments), flies were reared at 19-20°C throughout development. Because developmental duration at 19-20°C is approximately twice that at 25°C, experimental scheduling was adjusted to accommodate the delayed eclosion. For the activation of transgenes was achieved by transferring flies to 29°C (shibirets) or 28°C (TrpA1) for 30 mins prior to experiments. To eliminate confounding variables in behavioral assays, control and experimental groups were always raised under identical environmental conditions, including temperature, humidity, and light cycle.


Environmental Control System
The controlled-environment chamber is a dedicated fly room equipped to maintain standardized experimental conditions. It features a precision temperature control unit, which is a programmable apparatus for maintaining constant temperature with an accuracy of ±0.5°C. The chamber also includes automated humidity regulation through a humidifier or climate control system to stabilize relative humidity, typically within the range of 60–70%. Additionally, a programmable LED lighting system with full-spectrum arrays and an integrated timer is used to simulate circadian cycles, allowing for adjustable day/night duration and light intensity.
Mating Behavior Measurement System Setup
Behavioral observation arena: Customizable fly chamber, constructed with [material, e.g., acrylic/polycarbonate] and dimensions [1 × 1 × 0.2 cm] to standardize fly interactions (Fig. 1D-E).
Sex-separation films: Non-permeable acrylic partitions (0.5 mm thickness) to isolate male and female cohorts prior to trials. Customized apparatus components can be fabricated by precision cutting of OHP (overhead projector) film sheets.
Uniform illumination system: Programmable LED panel array (full-spectrum, 6500K color temperature) positioned to optimize contrast for automated tracking software.
High-resolution imaging: OPPO A72 5G main camera (4K resolution, 30 fps) mounted on an adjustable stabilizer for consistent video capture.
Mating Behavior Measurement Preparations
This protocol outlines the collection of male and virgin female Drosophila melanogaster and details the standardized mating behavior assay. To ensure experimental reproducibility, each cohort (genotype or condition) must include ≥100 individuals per sex, with final mating counts reaching at least 20 successful pairs (ideally 70-80) within a 2-hour observation window. The protocol spans developmental stages from egg to adult emergence, with adults requiring 5 days post-eclosion to attain sexual maturity. Flies are reared under controlled environmental conditions (25°C, 60-70% relative humidity, 12-hour light/dark cycle) to minimize physiological variability. To avoid confounding effects of anesthesia on mating behavior, CO2 exposure was strictly minimized during fly handling and sorting; brief, low-intensity exposure was reserved for initial virgin collection and before starting behavioral assays.
1. Preparation of experimental male flies (15–20 days)
Raise flies of the desired genotype (wild-type, mutants, or crosses such as GAL4/UAS combinations) in bottles at the specified temperature (standard: 25°C; alternative: 19°C or 29°C as required) under a 12:12 h light:dark cycle. Maintain 2–3 bottles per genotype, each containing 25 females and 15 males, to yield 25–30 flies per day. Transfer flies to fresh food every 2–3 days to prevent overcrowding.
2. Post-eclosion handling
Collect newly eclosed males (0–8 h post-eclosion) under brief CO₂ anesthesia. Isolate individual males in vials and age them for 5 days at 25°C (or 9 days at 18°C) to ensure complete brain maturation. Clear existing adults from culture vials daily using CO₂ to ensure synchronized collection of newly eclosed males. Group males into cohorts of 40 and rear in vials for 5–9 days to optimize sexual maturity while preserving mating efficiency.
3. Large-scale virgin female collection for high-throughput genetic screening
The Df(1)Exel6234/Yhs-hid (Bloomington Stock Center #7708 with #8846) or the SPRattP/Yhs-hid strain (Bloomington Stock Center #84576 with #8846) were used in this study. Both strains carry a null mutation in the sex-peptide receptor (SPR) gene (Yapici et al., 2008), which disrupts post-mating female refractoriness, thereby enhancing receptivity to remating and heat-inducible hid expression eliminating male progeny and balancer heterozygotes. Maintain cultures below 20°C prior to egg collection to prevent premature hid-induced lethality in Yhs-hid containing stocks.Higher temperatures (>20°C) may activate leaky hs-hid expression, reducing male lethality efficiency during subsequent heat shock.
Place adult Df (1)Exel6234/Yhs-hid flies in fresh bottles for 24 h to deposit eggs at 22°C. Heat shock incubate eggs at 37°C for 75 min to trigger hid-mediated apoptosis of males and balancer heterozygotes. We recommend using a water bath heated to 37°C for efficient heat shock instead of simply placing the samples in a 37°C incubator. Collect surviving female progeny and rear in groups of 40 for 5–8 days under standard conditions at 25°C to produce age-matched, virgin females. Raising at 29°C can speed up the process of obtaining virgin females. Following heat shock treatment, inspect all eclosed adults to confirm complete absence of male progeny. The Df(1)Exel6234/Yhs-hidsystem should yield 100% female populations when properly executed.
4. Chamber specifications
Structure: Reinforced with four stainless steel columns (3 mm diameter) to ensure stability (Fig. 1D-E and 5A).
Material: Four transparent acrylic plates (180 × 75 mm) with alternating thicknesses (1 cm and 0.3 cm), assembled in a “thick-thin-thin-thick” sequence (Fig. 1F and 5C).
Layout: 36 individual chambers arranged in 3×4 clusters (12 chambers per cluster).
Chamber spacing: 1 mm between individual chambers; 2 cm between clusters. Positioned 3 cm from the chamber’s long edge and 1 cm from the short edge (Fig. 1E-F).
Chamber dimensions are not fixed. By simply adjusting the magnification of the recording lens, users can re-scale the field of view and then refine the x (horizontal) and y (vertical) grid values in the DrosoMating interface to enclose the entire fly activity area within the corresponding wells. After this one-step calibration, the pipeline quantifies mating metrics (CL, CI, MD, etc.) with identical accuracy across different chamber sizes.

Setup of mating assay chamber apparatus and architecture of workstation.
(A) Disassembly of the chamber apparatus. Each chamber comprises a roof, two activity areas, and a floor integrated with four pillars. (B) Workstation for the assemble mating assay chambers. Essential required equipments for chamber assembly are shown: a stereomicroscope with an integrated light source, carbon dioxide anesthesia apparatus, a soft brush with feather on the opposite end, chamber apparatus, and fly containing vials. (C) 3D schematic of the mating chamber assembly. Assembly from bottom to top as shown. Briefly, first assemble the floor with one activity area 2 for placing females, then cover the females and separate activity area 1 from activity area 2 using the sex-separation slider. Next, position males and secure the chambers with paper tape. (D) The sex-separation slider is positioned between activity area 1 and activity area 2. (E) The mating chamber assembled with paper tape; the sex-separation slider should be marked with a pen to prevent forgetting to remove it. (F) 3D schematic of single unit of chamber, can hold up to 36 pairs of fruit flies simultaneously. (G) Multiple chambers are set up with four chambers vertically aligned on an LED backlight, allowing the accommodation of 144 pairs of fruit flies across all chambers. (H) Video recording setup. Position a 4K/1080p resolution camera or a smartphone with matching video capabilities above the chambers, turn on the LED backlight, and remove sex-separation slider before recording. (I) Setup for recording mating behavior using a camera mounted on a stand, positioned vertically above chambers arranged on a size-matched LED backlight to ensure uniform illumination. The camera is aligned to capture the entire chamber array, enabling simultaneous recording of mating interactions under controlled lighting conditions.
5. Software implementation
Automated analysis is performed using the DrosoMating pipeline (GitHub https://github.com/hcls-kimlab/DrosoMating), the raw code is under win-ff module. which extracts courtship and mating metrics from video recordings. (Linux version: https://github.com/liuxiao916/Fruit_Flies)
Mating Behavior Assay Step-by-step Procedures
1. Fly preparation
On day 5 post-eclosion, select healthy males (of the desired genotype) and virgin females. Lightly anesthetize flies using ice or CO₂ pad (avoid prolonged exposure to prevent stress) (Fig. 5B). To minimize behavioral perturbations, flies should only be anesthetized at this step. For brief immobilization (e.g., sorting or transferring individuals), use CO₂ anesthesia (≤30 sec exposure). To avoid bias, all experiments should be done blindly. Label fly tubes with random numbers instead of genotypes and keep a separate list matching numbers to genotypes. Only check which numbers correspond to which genotypes after finishing all data analysis.
2. Chamber assembly and fly loading
Using a soft brush, gently place a single female into a chamber hole in Floor (Activity Area 2) (Fig. 5B). Cover the chamber with a transparent film to prevent physical contact while allowing visual/chemical interactions. Align Activity Area 1 on top of the film (Fig. 5C). Introduce a single male into the opposite side of the film using the transparent film as a slider to minimize CO₂ exposure (Fig. 5D). Limit male exposure to CO₂ during this step to avoid behavioral artifacts. Seal the chamber securely with Roof using disposable paper tape (Fig. 5E).
3. Recovery and Mating Initiation
Transfer the assembled chamber to a 25°C incubator (humidity controlled at 60–70% RH) for 90 min to ensure flies recover fully from handling stress. After recovery, gently remove the transparent film to initiate physical mating (Fig. 5E and F).
4. Video Recording Setup
Position an adjustable LED panel beneath the chamber to ensure uniform illumination (Fig. 5G). Record mating behavior at 4K (1080p also meets the requirements) resolution for 1.5–2 hours (adjust duration as needed) (Fig. 5H). A minimal setup for capturing fruit fly mating behaviors can be rapidly established without extensive external facility requirements. The essential components include a camera stand, an LED light panel, and a camera capable of recording at a resolution and frame rate of 4K (60 fps). (Fig. 5I).
Analysis of Drosophila Mating Video Data Analysis and Statistics
The use of the Windows version of Drosomating
Prepare computer equipped either Windows (or Linux) PC with DrosoMating (ff-chose.exe) installed. The original code instructions for use are provided under the win-ff module.
Transfer video files into the computer to be analyzed. Launch DrosoMating and open the video file.
Enter the number of boards and velocity parameter. After entering the information, click “Enter” to proceed to the next step. (Fig. 1A)
. Select the four steel marker pillars in clockwise order (Fig. 1A). Adjust the selection sequence based on the video orientation. For each plate, a preview image will appear. Click on three distinct flies to enhance tracking accuracy (Fig. 1B).
After selecting all regions, return to the DrosoMating home interface. Adjust x (horizontal) and y (vertical) values to align grids with chamber holes. Fine-tune fly detection by modifying the s value (sensitivity threshold) until all flies are correctly identified. Use the grid to segment individual flies (as shown in Fig. 1C).
Run the analysis (Save the processed video but not recommended for routine use).
Export raw data as a CSV or Excel file. Open it in spreadsheet software for further processing.
The usage instructions for the Linux version of Drosomating are presented in Fig. S2
Statistical Analysis
To ensure robust statistical analysis, each experimental group included at least 100 male flies (naïve, sexually experienced, or singly reared). Internal controls were incorporated into every experiment as recommended by Bretman et al. (2011) (Bretman et al., 2011). Normality of the mating duration data was confirmed using the Kolmogorov-Smirnov test (p>0.05). For group comparisons, two-sided Student’s t-tests were applied to calculate significance levels (****p<0.0001, ***p<0.001, **p<0.01, * p<0.05), while estimation statistics (Claridge-Chang and Assam, 2016) were used to visualize effect sizes, mean differences, and precision, avoiding reliance solely on null hypothesis testing. All analyses, including data plotting, were performed using GraphPad Prism software.
Resource availability
Lead contact
Further information and requests for resources and reagents should be directed to and will be fulfilled by the lead contact, Woo Jae Kim (wkim@hit.edu.cn)
Materials availability
This study did not generate new, unique reagents.
Discussion
Advancing Courtship Behavior Analysis in Drosophila: From Manual Tracking to computer-vision classifier
The study of male Drosophila mating behavior represents a cornerstone in neurogenetics, providing critical insights into the neural and molecular mechanisms underlying innate social behaviors (Dauwalder, 2008; Dukas, 2020). Historically, the CI—quantifying the proportion of time spent in courtship activities—has served as a fundamental metric for evaluating mating activity (Greenspan and Ferveur, 2000a; Griffith and Ejima, 2009b; Pavlou and Goodwin, 2013; Sokolowski, 2001; Yamamoto and Koganezawa, 2013). However, traditional methodologies relied on labor-intensive manual observation, limiting their capacity to capture dynamic behavioral repertoires such as orientation, wing extension (“courtship song”), and copulation sequences (Dauwalder, 2008; Dukas, 2020). While machine vision systems like Dankert et al.’s automated platform advanced quantification of social interactions, their primary application skewed toward male-male aggression rather than nuanced courtship dynamics (Dankert et al., 2009b). Concurrently, research into genetic and environmental modulators—including fruitless (fru) and doublesex (dsx) gene pathways, cuticular hydrocarbons, and sensory cues—highlighted the need for scalable, high-resolution tools to dissect multimodal influences on behavior.
Technical Innovation and Validation
DrosoMating addresses these gaps through an integrated framework combining modular environmental chambers, automated video tracking, and machine-based annotation. This system minimizes manual intervention while capturing temporally precise metrics such as CL, CI, and MD. Validation against ground-truth manual scoring demonstrated exceptional accuracy (98–99% agreement; error rates <0.05%), underscoring reliability for high-throughput screens. Crucially, the platform detected subtle behavioral variations across genotypes—e.g., e.g., diminished courtship vigor in w1118 and y1 mutants—and environmental manipulations such as group-rearing or prior sexual experience, which respectively shortened mating duration by ∼8–12 %. This sensitivity enables investigations into adaptive trade-offs, learning phenotypes, and circuit-level mechanisms. For instance, DrosoMating replicated classic deficits in aversive learning following mushroom body ablation and courtship impairments in rutabaga learning mutants, corroborating its utility for behavioral neuroscience (Levin et al., 1992).
Limitations and Future Directions
Despite its advantages, DrosoMating currently lacks granularity for posture-specific interactions (e.g., “wing threat” during aggression or “circling” during courtship) and multisensory integration. Future iterations could incorporate 3D pose estimation algorithms (e.g., DeepLabCut) or integrate JAABA-based classifiers to expand action repertoires (Kabra et al., 2013). Environmental control—though essential for standardization—may limit ecological validity;

Schematic representation and behavioral assays of LMD and SMD in Drosophila which combined with temperature-dependent temporal.
(A) Schematic representation of LMD and SMD assays timeline when flies were crossed with heat-sensitive Drosophila cation channel TrpA1 and shits. (B) MD assays of flies expressing the MB247-GAL4 driver together with UAS-GFP. (C) MD assays of flies expressing the MB247-GAL4 driver together with UAS-shits. (D) Schematic representation of LMD and SMD assays timeline when tub-GAL80ts; UAS-KCNJ2/UAS-NaChBac/UAS-TNT or RNAi flies are crossed with specific GAL4 driver. (E) MD assays of flies expressing the MB247-GAL4 driver together with tub-GAL80ts, UAS-mCherry. (F) MD assays of flies expressing the MB247-GAL4 driver together with tub-GAL80ts, UAS-KCNJ2.

Usage of Linux version of DrosoMating.
(A) Typing input speed and input board numbers before selecting analyzing area (upper). Schematic representation of the region selection process (lower). Columns should be selected in a clockwise direction starting from the top left corner.. (B) Selection of reference flies for tracking accuracy. Any three reference flies were chosen for the analysis. (C) The DrosoMating home interface. In brief, “Open videos” to import the recorded mating video. “Run analysis” to initiate the analysis process. The progress bar indicates the status of the analysis. Export raw data by clicking “Export”.
Data availability
Strains are available upon request. The authors affirm that all data necessary for confirming the conclusions of the article are present within the article, figures, and tables. Our software is freely available at GitHub https://github.com/hcls-kimlab/DrosoMating. (Linux version: https://github.com/liuxiao916/Fruit_Flies)
Acknowledgements
The authors thank Kim lab members for their kind advice on this manuscript. This work was supported by Startup funds from The HIT Center for Life Science (HCLS) to Woo Jae Kim.
Additional information
Authors’ contributions
XL, YS, and DS conceived and designed the study. WK designed the chamber. XL and FJ completed the development of the software underlying code. YS conducted the subsequent software development and testing. YX fabricated all the hardware devices. YS performed the DrosoMating analysis. WK, YS, and DS wrote the manuscript. WK, YS, and DS created the figures and tutorial video. YS and DS revised the manuscript. All authors read, reviewed, and approved the final manuscript.
Funding
Harbin Institute of Technology (HIT) (Startup funds)
Woo Jae Kim
List of abbreviations
CL: Copulation Latency
MD: Mating Duration
CI: Courtship Index
LI: Learning Index
SMD: Shorter Mating Duration
LMD: Longer Mating Duration
CAD: Computer-Aided Design
References
- Versatile method to measure locomotion in adult Drosophila1Genome 64:139–145https://doi.org/10.1139/gen-2020-0044Google Scholar
- Neural Circuits: Male Mating MotifsNeuron 87:912–914https://doi.org/10.1016/j.neuron.2015.08.017Google Scholar
- ilastik: interactive machine learning for (bio)image analysisNat Methods 16:1226–1232https://doi.org/10.1038/s41592-019-0582-9Google Scholar
- High-throughput ethomics in large groups of DrosophilaNat Methods 6:451–457https://doi.org/10.1038/nmeth.1328Google Scholar
- Plastic responses of male Drosophila melanogaster to the level of sperm competition increase male reproductive fitnessProc Royal Soc B Biological Sci 276:1705–1711https://doi.org/10.1098/rspb.2008.1878Google Scholar
- Males Use Multiple, Redundant Cues to Detect Mating RivalsCurr Biol 21:617–622https://doi.org/10.1016/j.cub.2011.03.008Google Scholar
- An automatic system for recognizing fly courtship patterns via an image processing methodBehav Brain Funct 20:5https://doi.org/10.1186/s12993-024-00231-4Google Scholar
- An automatic system for recognizing fly courtship patterns via an image processing methodBehav Brain Funct : BBF 20:5https://doi.org/10.1186/s12993-024-00231-4Google Scholar
- Estimation statistics should replace significance testingNat Methods 13:108–109https://doi.org/10.1038/nmeth.3729Google Scholar
- Automated monitoring and analysis of social behavior in DrosophilaNat Methods 6:297–303https://doi.org/10.1038/nmeth.1310Google Scholar
- Automated monitoring and analysis of social behavior in DrosophilaNat Methods 6:297–303https://doi.org/10.1038/nmeth.1310Google Scholar
- Systems Behavior: Of Male Courtship, the Nervous System and Beyond in DrosophilaCurr Genom 9:517–524https://doi.org/10.2174/138920208786847980Google Scholar
- A cis-regulatory Sequence Within the yellow Locus of Drosophila melanogaster Required for Normal Male Mating SuccessGenetics 172:1009–1030https://doi.org/10.1534/genetics.105.045666Google Scholar
- Natural history of social and sexual behavior in fruit fliesSci Rep 10:21932https://doi.org/10.1038/s41598-020-79075-7Google Scholar
- Courtship latency in maleDrosophila melanogasterBehav Genet 7:359–372https://doi.org/10.1007/bf01077449Google Scholar
- Courtship latency in maleDrosophila melanogasterBehav Genet 7:359–372https://doi.org/10.1007/bf01077449Google Scholar
- Measurement of Courtship Behavior in Drosophila melanogasterCold Spring Harb Protoc 2007 :pdb.prot4847https://doi.org/10.1101/pdb.prot4847Google Scholar
- anTraX, a software package for high-throughput video tracking of color-tagged insectseLife 9:e58145https://doi.org/10.7554/elife.58145Google Scholar
- A simplified courtship conditioning protocol to test learning and memory in DrosophilaStar Protoc 4:101572https://doi.org/10.1016/j.xpro.2022.101572Google Scholar
- A simplified courtship conditioning protocol to test learning and memory in DrosophilaSTAR Protoc 4:101572https://doi.org/10.1016/j.xpro.2022.101572Google Scholar
- Courtship in drosophilaAnnu Rev Genet 34:205–232https://doi.org/10.1146/annurev.genet.34.1.205Google Scholar
- Courtship in drosophilaAnnu Rev Genet 34:205–232https://doi.org/10.1146/annurev.genet.34.1.205Google Scholar
- Courtship learning in Drosophila melanogaster: Diverse plasticity of a reproductive behaviorLearn Mem 16:743–750https://doi.org/10.1101/lm.956309Google Scholar
- Courtship learning in Drosophila melanogaster: Diverse plasticity of a reproductive behaviorLearn Memory 16:743–750https://doi.org/10.1101/lm.956309Google Scholar
- The Mating of a FlyScience 264:1702–1714https://doi.org/10.1126/science.8209251Google Scholar
- Y chromosome genes interplay with interval timing in regulating mating duration of male Drosophila melanogasterGene Rep 36:101999https://doi.org/10.1016/j.genrep.2024.101999Google Scholar
- Automated Quantification of Locomotion, Social Interaction, and Mate Preference in Drosophila MutantsJ Neurogenet 26:306–316https://doi.org/10.3109/01677063.2012.729626Google Scholar
- JAABA: interactive machine learning for automatic annotation of animal behaviorNat Methods 10:64–67https://doi.org/10.1038/nmeth.2281Google Scholar
- Drosophila Conditioned Courtship: Two Ways of Testing MemoryLearn Mem 6:1–20https://doi.org/10.1101/lm.6.1.1Google Scholar
- Modulation of TRPA1 thermal sensitivity enables sensory discrimination in DrosophilaNature 481:76–80https://doi.org/10.1038/nature10715Google Scholar
- A PDF/NPF Neuropeptide Signaling Circuitry of Male Drosophila melanogaster Controls Rival-Induced Prolonged MatingNeuron 80:1190–1205https://doi.org/10.1016/j.neuron.2013.09.034Google Scholar
- A PDF/NPF Neuropeptide Signaling Circuitry of Male Drosophila melanogaster Controls Rival-Induced Prolonged MatingNeuron 80:1190–1205https://doi.org/10.1016/j.neuron.2013.09.034Google Scholar
- Contribution of visual and circadian neural circuits to memory for prolonged mating induced by rivalsNat Neurosci 15:876–883https://doi.org/10.1038/nn.3104Google Scholar
- Contribution of visual and circadian neural circuits to memory for prolonged mating induced by rivalsNat Neurosci 15:876–883https://doi.org/10.1038/nn.3104Google Scholar
- Sexually experienced male Drosophila melanogaster uses gustatory-to-neuropeptide integrative circuits to reduce time investment for matingBiorxiv https://doi.org/10.1101/088724Google Scholar
- Peptidergic neurons with extensive branching orchestrate the internal states and energy balance of male Drosophila melanogasterbioRxiv https://doi.org/10.1101/2024.06.04.597277Google Scholar
- Handbook of Behavior Geneticspp. 317–330https://doi.org/10.1007/978-0-387-76727-7_22Google Scholar
- Conditional modification of behavior in Drosophila by targeted expression of a temperature-sensitive shibire allele in defined neuronsJ Neurobiol 47:81–92https://doi.org/10.1002/neu.1018Google Scholar
- Influence of the White Locus on the Courtship Behavior of Drosophila MalesPLoS ONE 8:e77904https://doi.org/10.1371/journal.pone.0077904Google Scholar
- Multisensory inputs control the regulation of time investment for mating by sexual experience in male Drosophila melanogasterBiorxiv https://doi.org/10.1101/2022.09.23.509131Google Scholar
- Taste and pheromonal inputs govern the regulation of time investment for mating by sexual experience in male Drosophila melanogasterPLOS Genet 19:e1010753https://doi.org/10.1371/journal.pgen.1010753Google Scholar
- Taste and pheromonal inputs govern the regulation of time investment for mating by sexual experience in male Drosophila melanogasterPLOS Genet 19:e1010753https://doi.org/10.1371/journal.pgen.1010753Google Scholar
- The Drosophila learning and memory gene rutabaga encodes a Ca2+calmodulin-responsive adenylyl cyclaseCell 68:479–489https://doi.org/10.1016/0092-8674(92)90185-fGoogle Scholar
- Drosophila, Methods and ProtocolsMethods Mol Biol 1478:303–320https://doi.org/10.1007/978-1-4939-6371-3_19Google Scholar
- Courtship behavior in Drosophila melanogaster: towards a ‘courtship connectome’Curr Opin Neurobiol 23:76–83https://doi.org/10.1016/j.conb.2012.09.002Google Scholar
- idTracker: tracking individuals in a group by automatic identification of unmarked animalsNat Methods 11:743–748https://doi.org/10.1038/nmeth.2994Google Scholar
- EasyFlyTracker: A Simple Video Tracking Python Package for Analyzing Adult Drosophila Locomotor and Sleep Activity to Facilitate Revealing the Effect of Psychiatric DrugsFront Behav Neurosci 15:809665https://doi.org/10.3389/fnbeh.2021.809665Google Scholar
- Automated analysis of courtship suppression learning and memory in Drosophila melanogasterFly 7:105–111https://doi.org/10.4161/fly.24110Google Scholar
- FIMTrack: An open source tracking and locomotion analysis software for small animalsPLoS Comput Biol 13:e1005530https://doi.org/10.1371/journal.pcbi.1005530Google Scholar
- FIM Imaging and FIMtrack: Two New Tools Allowing High-throughput and Cost Effective Locomotion AnalysisJ Vis Exp https://doi.org/10.3791/52207-vGoogle Scholar
- ToxTrac : A fast and robust software for tracking organismsMethods Ecol Evol 9:460–464https://doi.org/10.1111/2041-210x.12874Google Scholar
- A simple assay to study social behavior in Drosophila: measurement of social space within a groupGenes, brain, behav 11:243–52https://doi.org/10.1111/j.1601-183x.2011.00740.xGoogle Scholar
- Mating latency, duration of copulation and fertility in four species of the Drosophila bipectinata complexIndian J Exp Biol 52:175–80Google Scholar
- The genetics of sexual behavior in DrosophilaAdv Genom Genet 6:1–9https://doi.org/10.2147/agg.s58525Google Scholar
- Drosophila: Genetics meets behaviourNat Rev Genet 2:879–890https://doi.org/10.1038/35098592Google Scholar
- Long-duration animal tracking in difficult lighting conditionsSci Rep 5:10432https://doi.org/10.1038/srep10432Google Scholar
- Molecular and Neural Circuit Mechanisms Underlying Sexual Experience-dependent Long-Term Memory in DrosophilabioRxiv https://doi.org/10.1101/2024.09.28.615582Google Scholar
- Genetic screening reveals cone cell-specific factors as common genetic targets modulating rival-induced prolonged mating in male Drosophila melanogasterG3: Genes, Genomes, Genet :jkae255https://doi.org/10.1093/g3journal/jkae255Google Scholar
- Into the mind of a flyNature 450:193–197https://doi.org/10.1038/nature06335Google Scholar
- Drosophila Mushroom Bodies Are Dispensable for Visual, Tactile, and Motor LearningLearn Mem 5:166–178https://doi.org/10.1101/lm.5.1.166Google Scholar
- Neuropeptide relay between SIFa signaling controls the experience-dependent mating duration of male DrosophilaBiorxiv https://doi.org/10.1101/819045Google Scholar
- Genes and circuits of courtship behaviour in Drosophila malesNat Rev Neurosci 14:681–692https://doi.org/10.1038/nrn3567Google Scholar
- UMATracker: an intuitive image-based tracking platformJ Exp Biol 221:jeb182469https://doi.org/10.1242/jeb.182469Google Scholar
- A receptor that mediates the post-mating switch in Drosophila reproductive behaviourNature 451:33–37https://doi.org/10.1038/nature06483Google Scholar
- Long-range neuropeptide relay as a central-peripheral communication mechanism for the context-dependent modulation of interval timing behaviorsbioRxiv https://doi.org/10.1101/2024.06.03.597273Google Scholar
- Exploring the Asymmetric Body’s Influence on Interval Timing Behaviors of Drosophila melanogasterBehav Genet :1–10https://doi.org/10.1007/s10519-024-10193-yGoogle Scholar
- Male-specific sNPF peptidergic circuits control energy balance for mating duration through neuron-glia interactionsbioRxiv https://doi.org/10.1101/2024.10.17.618859Google Scholar
Article and author information
Author information
Version history
- Sent for peer review:
- Preprint posted:
- Reviewed Preprint version 1:
Cite all versions
You can cite all versions using the DOI https://doi.org/10.7554/eLife.109742. This DOI represents all versions, and will always resolve to the latest one.
Copyright
© 2026, Song et al.
This article is distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use and redistribution provided that the original author and source are credited.
Metrics
- views
- 0
- downloads
- 0
- citations
- 0
Views, downloads and citations are aggregated across all versions of this paper published by eLife.