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:

  1. 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).

  2. 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).

  3. 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

  1. 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).

  2. 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.

  3. Uniform illumination system: Programmable LED panel array (full-spectrum, 6500K color temperature) positioned to optimize contrast for automated tracking software.

  4. 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

  1. 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.

  2. Transfer video files into the computer to be analyzed. Launch DrosoMating and open the video file.

  3. Enter the number of boards and velocity parameter. After entering the information, click “Enter” to proceed to the next step. (Fig. 1A)

  4. . 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).

  5. 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).

  6. Run the analysis (Save the processed video but not recommended for routine use).

  7. 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