Introduction

The visual systems of many animals consist of photoreceptors with distinct spectral sensitivities1. A particular photoreceptor or photoreceptors is primarily used for detecting achromatic information related to spatial and temporal changes in luminance, such as form and motion perception, while another (or partly overlapping) set of photoreceptors contributes to processing chromatic information, enabling color perception2. Narrow band sensitivity is advantageous for wavelength discrimination but causes a low signal-to-noise ratio, leading to the convergence of a small set of photoreceptors with sensitivities of approximately 100 nm half-bandwidth3,4. Although molecular identities and spectral sensitivities of photoreceptors have been extensively characterized, how these spectrally distinct photoreceptors combine to function is not fully understood1,5.

Animal color vision behavior is divided into innate and learned behaviors. The former includes ‘wavelength-specific behaviors’, primitive forms of which are phototaxis and spectral preference, usually intensity-dependent, whereas the latter includes ‘true color vision,’ in which discrimination of wavelengths is independent of intensity and often requires spatial vision and an internal representation of color6,7. The intensity of input from a specific photoreceptor, or the summation of inputs from a small subset of photoreceptors, could be important for wavelength-specific behaviors, whereas the comparisons between differently tuned photoreceptors by color-opponent neurons could be crucial for true color vision. Although the basic circuitry of the visual system has been elucidated in many animals, the possibility that different sets of photoreceptors are responsible for different behavioral tasks makes the pursuit of the underlying brain circuits very complicated.

The fruit fly Drosophila melanogaster is an excellent model for circuit-level analysis of visual behaviors7,8,9,10. The visual system of D. melanogaster comprises a pair of compound eyes, each containing approximately 750 ommatidia, and three small ocelli. In higher flies (Diptera), the compound eyes exhibit a unique organization known as neural superposition11,12. Five classes of photoreceptors have been identified: two ultraviolet (UV)-sensitive, blue-sensitive, green-sensitive, and broadband-sensitive photoreceptors (color terms are used according to the human perception throughout the manuscript). In D. melanogaster, ommatidia are typically classified into three subtypes: pale and yellow types, which are stochastically distributed in a 35:65 (p: y) ratio, and dorsal rim area (DRA) ommatidia, which are localized in the dorsal-most region of the compound eye and are specialized for detecting polarized light from the sky13 (Fig. 1a). The spectral sensitivities of the photoreceptors have been well characterized (Fig. 1b)14,15. The outer R1–R6 photoreceptor cells express the broadband-sensitive Rh1 photoreceptor and project short visual fibers to the lamina. R7 photoreceptor cells express short UV-sensitive Rh3 in R7p and long UV-sensitive Rh4 in R7y, while R8 photoreceptor cells express blue-sensitive Rh5 in R8p and green-sensitive Rh6 in R8y. Both inner R7 and R8 photoreceptor cells form long visual fibers that project to the medulla. Notably, DRA ommatidia express Rh3 in R816, while yellow-type ommatidia in the dorsal third of the compound eye co-express Rh3 and Rh4 in R7y17. In flies, as in birds, achromatic and chromatic vision have long been considered distinctly separated, with broadband Rh1 expressed in R1–6 and narrow-band Rh3–6 expressed in R7 and 82. Due to the advantage of narrow spectral tuning for color discrimination, R7 and R8 photoreceptors play key roles in chromatic information processing, as proposed by Troje18. However, subsequent studies have suggested interactions between the inner and outer photoreceptors19,20. In addition to the conventional photoreceptors found in the compound eyes, several extra-retinal photoreceptors or photosensitive molecules have been identified21. Rh7, which is sensitive to blue and violet light, is expressed in R8 photoreceptors of the compound eyes, in certain circadian clock neurons in the brain, and in the Hofbauer-Buchner (HB) eyelet—an additional light-sensing organ located between the lamina and medulla—where it is co-expressed with Rh622,23,24. Cryptochrome, a blue- and UV-light-sensitive photopigment, is expressed in circadian clock neurons and the compound eyes25,26,27,28. Furthermore, a recent study reported transient receptor potential (TRP) channels, including Painless, TrpA1, and Pyrexia may be involved in spectral preference behaviors29. Many of these molecules are known to play important roles in light entrainment of circadian rhythms and may also influence both innate and learned chromatic behaviors.

Fig. 1
figure 1

Photoreceptors in D. melanogaster and experimental setups. a. Schematic diagram of the organization of the photoreceptors in the compound eyes of the fly. b. Spectral sensitivity of the photoreceptors adapted from15. c. Experimental setup for conditioning. The fly chamber placed on the cool plate is illuminated by LEDs on the bread board from above. Schematic diagram of the setup is shown on the right. d. Experimental setup for testing. The fly chamber is illuminated by LEDs on the bread board from below. Schematic diagram of the setup is shown on the right. During the tests, the flies moved freely within the chamber, which was illuminated by two light stimuli projected diagonally opposite each other (or in parallel during pilot experiments). e. Photon counts of each LED stimulus at bright intensity (~ 100%). Inset shows integrals of the photon counts for each stimulus. f. Photon counts of each LED stimulus at dim intensity (~ 10%). Inset shows integrals of the photon counts for each stimulus.

The spectral preferences of D. melanogaster have been extensively studied in combination with photoreceptor mutants and genetic manipulations, revealing the roles of specific photoreceptors in mediating phototactic behaviors30,31,32,33,34,35,36. Conventionally, fly phototactic behavior has been classified into two types: fast phototaxis and slow phototaxis. Fast phototaxis is an immediate response to light, typically observed when flies are alert and disturbed30,32,35,36,37,38. This behavior reflects an escape reaction, with flies showing a preference for shorter wavelengths as an indicator of open sky. Conversely, slow phototaxis is a delayed response occurring over longer period, observed when flies are free to move and choose between two differently illuminated areas29,33,34. Spectral preference in slow phototactic behavior has not been consistently determined and varies depending on the assay.

In contrast, true color vision in D. melanogaster has been demonstrated through learned discrimination behaviors. Associative visual learning assays are essential for evaluating the ability of flies to distinguish between different wavelengths of light, independent of intensity. These assays typically involve conditioning with aversive stimuli, such as electric shocks39,40 shaking41,42 or heat43,44 or with appetitive stimuli, such as sucrose19to assess color discrimination. Previous studies have shown that flies can learn to discriminate between different color combinations, such as blue vs. yellow40,41 or blue vs. green19,43,44. Notably, only one study has tested a relatively wide range of color combinations (406–606 nm, 8 different wavelengths) and reported a spectral discrimination function42. Additionally, several studies have shown that flies are capable of learning intensity differences19,45,46. A recent study demonstrated that not only the combination of Rh3–6, but also the parings such as Rh1 and Rh4, or Rh4 and Rh6 alone, can support discrimination between blue and green19. These findings suggest that multiple photoreceptor types contribute to color discrimination in D. melanogaster. However, the underlying mechanisms remain poorly understood.

In this study, we developed a two-choice behavioral assay to examine both innate preferences and learned discrimination in flies using various combinations of light wavelengths. The slow phototactic responses and visual learning performances were found to be dependent on the spectral properties of the stimuli. We then compared the learned discrimination behaviors with photoreceptor space representations to assess how different photoreceptor types might be functionally combined. Our findings provide valuable foundational data for further investigating the neural computations underlying spectral processing in this important model animal.

Results

In this study, we evaluated the ability of wild-type Canton-S flies to discriminate six different monochromatic lights. We developed an associative learning paradigm comprising a conditioning apparatus (Fig. 1c), in which light stimulus was paired with aversive heat, and a test apparatus (Fig. 1d), in which flies chose between two distinct areas illuminated by different light stimuli. The six monochromatic lights were generated using LEDs of six different colors at two intensity levels, and their spectral properties are shown in Fig. 1e and f (detailed LED properties are provided in Supplementary Table S1).

Before conducting learning-based discrimination tests for all pairwise combinations of the six LED colors, we first assessed innate spectral preferences using the test apparatus alone, without conditioning. We then carried out a series of pilot experiments to establish and validate the learning paradigm. Finally, we performed behavioral tests to assess learned color discrimination and evaluated the results in terms of photoreceptor contributions.

Spectral preference through slow phototactic behavior

First, we examined innate spectral preferences using combinations of six monochromatic lights (λmax = 402 nm (violet), 470 nm (blue), 526 nm (green), 596 nm (yellow), 613 nm (orange), 630 nm (red)) (Fig. 1e). The distribution of flies after two minutes of free walking was quantified as a preference index. We therefore classified these behaviors as slow phototactic responses. Flies exhibited a positive preference for green, yellow, and orange when presented alongside blue or violet, with the exception of violet vs. green (blue vs. green, PI = -0.274 ± 0.043 (mean ± SEM), p = 2.19.E-04; blue vs. yellow PI = -0.307 ± 0.038, p = 1.78.E-07; blue vs. orange, PI = -0.306 ± 0.034, p = 3.15.E-08; violet vs. green, PI = -9.71.E-05 ± 0.037, p = 6.87.E-01; violet vs. yellow, PI = -0.512 ± 0.041, p = 1.59.E-10; violet vs. orange, PI = -0.343 ± 0.048, p = 9.82.E-07; all comparisons were conducted with n = 20 flies; Fig. 2a, statistical details are provided in Table 1). This indicates that flies prefer moderately longer wavelengths (green to orange) and avoid shorter wavelengths (violet to blue).

Fig. 2
figure 2

Innate preference for combinations of six monochromatic lights through slow phototactic behaviors. a. Spectral preference for each combination of six monochromatic LEDs (violet, blue, green, yellow, orange, and red) (n = 20). b. Preference for intensity differences in six monochromatic wavelengths (n = 20). The intensity difference is approximately 1:10 (see Figs. 1E, F). Statistically significant differences from zero were assessed with a one sample t-test or a Wilcoxon signed-rank test. *p < 0.05, after p-values were Bonferroni corrected. Mean values and other statistical information are summarized in Tables 1 and 2.

Table 1 Preference index (PI) for spectral preference between pair of six LED colors.
Table 2 Preference index (PI) for spectral preference between different intensities of each LED color.

Next, to evaluate the effects of light intensity, we tested a 1:10 intensity ratio difference across all six wavelengths (Figs. 1e, f). Flies did not show a significant preference for either brighter or darker intensities in any wavelength combination (violet 100% vs. 10%, PI = -0.0392 ± 0.040, p = 3.35.E-01; blue 100% vs. 10%, PI = -0.0873 ± 0.040, p = 5.93.E-02; green 100% vs. 10%, PI = -0.0498 ± 0.050, p = 3.31.E-01; yellow 100% vs. 10%, PI = 0.0918 ± 0.038, p = 2.74.E-02; orange 100% vs. 10%, PI = 0.0749 ± 0.026, p = 1.03.E-02; red 100% vs. 10%, PI = 0.0406 ± 0.040, p = 3.27.E-01; all comparisons were conducted with n = 20 flies; Fig. 2b, statistical details are provided in Table 2). These results indicate that spectral preference in this slow phototactic assay is largely independent of light intensity.

Visual learning assay using heat as an aversive stimulus

To evaluate the discrimination between two different monochromatic light stimuli, we employed a classical conditioning assay. Monochromatic LED light served as the conditioned stimulus (CS), and aversive temperature was used as the unconditioned stimulus (US). Differential conditioning was applied to test the discrimination between the two different light stimuli: one was paired with aversive temperature, and the other with normal temperature.

To determine optimal conditions for the discrimination assay, several variations in the US temperature (34,36, or 39˚C), the duration and repetition of the training (120 s × 4, 60 s × 6, or 30 s × 6), and the spatial arrangement of the two test lights (parallel or diagonal) were compared (Supplementary Figs. S1a–d). In these pilot experiments, blue (λmax = 470 nm) and green (λmax = 526 nm) lights were used for evaluation (Supplementary Fig. S1f). Among the tested conditions, the protocol employing 36˚C as the aversive temperature, one-minute training repeated six times, and diagonally arranged test lights produced robust discrimination (LI = 0.132 ± 0.040 (mean ± SEM), n = 14, p = 2.32.E-03; Supplementary Figs. S1c, d, statistical details are provided in Supplementary Tables S2,S3), and was thus selected as the standard procedure. Under these conditions, a control experiment in which the aversive stimulus was replaced with 22˚C yielded an LI value of 0.0056 ± 0.023 (n = 14, p = 0.815; Supplementary Figs. S1c, d, statistical details are provided in Supplementary Table S3), indicating that aversive temperature and/or relief from aversive temperature induce learning.

Since color vision is defined as the ability to discriminate between two different wavelengths independent of their intensity, we tested whether our experimental conditions satisfy this criterion. We employed conversion experiments19,41 in which the intensities of the lights are inverted between conditioning and testing phases; flies were conditioned with 100% bright blue vs. 10% dark green and tested with 100% bright green vs. 10% dark blue, or vice versa. Flies did not show significant discrimination (when trained with 100% blue vs. 10% green, LI = 0.0501 ± 0.059, n = 14, p = 4.11.E-01; when trained with 10% blue vs. 100% green, LI = -0.0490 ± 0.042, n = 14, p = 2.61.E-01; Supplementary Fig. S1e, statistical details are provided in Supplementary Table S4). Next, we tested 1:2 intensity ratio intensity difference (100% vs. 50%) between the conditioning and testing, and flies successfully discriminated in this case (when trained with 100% blue vs. 50% green, LI = 0.1245 ± 0.040; n = 14, p = 8.10.E-03; when trained with 50% blue vs. 100% green, LI = 0.1165 ± 0.031, n = 14, p = 2.42.E-03; Supplementary Fig. S1e, statistical details are provided in Supplementary Table S4). These results suggest that flies can learn to discriminate blue vs. green based on wavelength to some extent, although contributions from intensity differences cannot be entirely excluded in this assay.

Discrimination between different wavelength and intensity combinations

Next, we examined the flies’ ability to discriminate between different wavelength combinations across a wide spectral range using our behavioral system (Fig. 1e). Significant discrimination was observed for combinations of violet vs. blue (LI = 0.116 ± 0.019 (mean ± SEM), n = 30, p = 9.54.E-07, statistical details are provided in Table 3), violet vs. green (LI = 0.102 ± 0.026, n = 30, p = 4.53.E-04), and blue vs. green (LI = 0.093 ± 0.020, n = 30, p = 5.24.E-05), whereas green, yellow, orange, and red were not discriminated from one another (green vs. yellow, LI = -0.010 ± 0.042, n = 26, p = 8.16.E-01; green vs. orange, LI = 0.024 ± 0.032, n = 26, p = 4.55.E-01; green vs. red, LI = 0.011 ± 0.029, n = 26, p = 7.20.E-01; yellow vs. orange, LI = 0.029 ± 0.026, n = 26, p = 2.83.E-01; yellow vs. red, LI = -0.003 ± 0.024, n = 26, p = 8.91.E-01; orange vs. red, LI = 0.019 ± 0.030, n = 26, p = 5.42.E-01; Fig. 3a, statistical details are provided in Table 3). Combinations of shorter wavelengths (violet and blue) with longer wavelengths (yellow, orange, and red) showed moderate LIs, although these were not statistically significant (violet vs. yellow, LI = 0.049 ± 0.028, n = 26, p = 9.07.E-02; violet vs. orange, LI = 0.053 ± 0.036, n = 26, p = 1.49.E-01; violet vs. red, LI = 0.041 ± 0.035, n = 26, p = 7.34.E-02; blue vs. yellow, LI = 0.049 ± 0.033, n = 30, p = 1.51.E-01; blue vs. orange, LI = 0.092 ± 0.036, n = 30, p = 1.62.E-02; blue vs. red, LI = 0.051 ± 0.035, n = 30, p = 1.52.E-01; Fig. 3a, statistical details are provided in Table 3). These results suggest that flies can discriminate between short to middle wavelengths (violet to green), but not between middle to long wavelengths (green to red). Since we could not rule out the possibility that discrimination was based on differences in light intensity, we next tested discrimination of intensity differences at each individual wavelength.

Table 3 Learning index (LI) for discrimination between pairs of six LED colors.
Fig. 3
figure 3

Learning discrimination for combinations of six monochromatic lights. a. Learning discrimination for each combination of six monochromatic LEDs (violet, blue, green, yellow, orange, and red) (n = 26–30). b. Learning discrimination for intensity differences in six monochromatic wavelengths (n = 30). The intensity difference is approximately 1:10 (see Figs. 1e, f). Statistically significant differences from zero were assessed with a one sample t-test or a Wilcoxon signed-rank test. *p < 0.05, after p-values were Bonferroni corrected. Mean values and other statistical information are summarized in Tables 3 and 4.

Table 4 Learning index (LI) of discrimination between different intensities of each LED color.

We tested the ability to discriminate luminance differences (100% vs. 10%; light intensities shown in Figs. 1e, f) for all six monochromatic light wavelengths. Flies showed no significant discrimination at any wavelength (violet 100% vs. 10%, LI = -0.0169 ± 0.030, n = 30, p = 5.84.E-01; blue 100% vs. 10%, LI = 0.0399 ± 0.024, n = 30, p = 1.78.E-01; green 100% vs. 10%, LI = 0.0187 ± 0.025, n = 30, p = 4.61.E-01; yellow 100% vs. 10%, LI = 0.0196 ± 0.024, n = 30, p = 4.27.E-01; orange 100% vs. 10%, LI = 0.0330 ± 0.020, n = 30, p = 1.12.E-01; red 100% vs. 10%, LI = -0.0049 ± 0.027, n = 30, p = 8.58.E-01; Fig. 3b, statistical details are provided in Table 4), indicating that the observed discrimination behavior was based primarily, if not entirely, on spectral information.

Comparison of behavioral results with photoreceptor space representation

Once the spectral sensitivities of a species are known, the quantum catch of each photoreceptor in response to a given light stimulus can be calculated (Figs. 4a, b). Here, we compared our behavioral results with the categorical model proposed by Troje18. According to the model, stimuli plotted in different categories (quadrants) of this photoreceptor space can be discriminated, whereas those within the same category cannot. In our case, all six light stimuli except violet were plotted in the bottom-left quadrant, while violet appeared in the upper-left quadrant, suggesting that this model does not account for our behavioral results (Fig. 4c, see also Discussion).

Fig. 4
figure 4

Comparison of the color representation in the photoreceptor space and the behavioral results. a. Spectral sensitivity of the photoreceptors reported in Sharkey et al. 202015 (upper) and spectra of the LED lights used in the learning experiments (bottom). The quantum catch for each photoreceptor was calculated by multiplying its spectral sensitivity by the LED light spectrum and integrating the product over the range of 315 to 700 nm (see Methods). b. Calculated quantum catch for each LED light. c. Light stimuli are represented on the map of Troje’s categorical model18. d. Principal component analyses for the six LED colors based on the calculated quantum catches of the four photoreceptors: Rh3, Rh4, Rh5, and Rh6. The percentages of variance accounted by the PC1 and PC2 are shown on each axis. e. Correlations between the pairwise distances between each color represented in the PC1 and PC2 space and the mean learning indices in the aversive visual learning. f. Loadings of the PC1 (upper left) and PC2 (bottom left). Reconstructed sensitivities of the PC1 (upper right) and PC2 (bottom right).

Due to difficulties in applying conventional models to explain the discrimination observed in our data, we adopted a more straightforward representation of each color stimulus in photoreceptor space, where each axis corresponds to the quantum catch of a specific photoreceptor. The distance between points in this space serves as an estimate of the discriminability between two stimuli. Because the sensitivities of the photoreceptors are highly correlated, we applied principal component analysis (PCA) using four photoreceptors (Rh3, Rh4, Rh5, and Rh6) to efficiently represent the photoreceptor space. Each color stimulus was then mapped onto a two-dimensional space defined by the first two principal components, PC1 and PC2, which together explain over 95% of the total variance (78.4% for PC1 and 16.7% for PC2; Fig. 4d). We further compared the distances between these color loci with the mean learning indices (LIs) obtained from learning discrimination experiments (Fig. 4e). This representation predicted behavioral discrimination reasonably well (r2 = 0.49), capturing the discriminability among violet, blue and green, as well as the lack of discrimination among green, yellow, orange, and red. Moreover, this correlation was stronger than that obtained using the photoreceptor space defined by all photoreceptors, including Rh1 (r2 = 0.30; Supplementary Fig. S3). Finally, by multiplying the PCA loadings by the spectral sensitivities of each photoreceptor, we reconstructed the sensitivities of the two axes, revealing two opponent channels: short (Rh3 and Rh4) vs. long (Rh6) for PC1, and middle (Rh5) vs. short (Rh3 and Rh4) plus long (Rh6) for PC2 (Fig. 4f).

Discussion

We conducted a spectral preference assay and a visual learning assay using heat as an aversive stimulus to evaluate the flies’ ability to discriminate between various combinations of wavelengths and light intensities. We then compared our behavioral results with existing coding models by incorporating the spectral sensitivities of individual photoreceptors and estimated each photoreceptor’s contribution to color discrimination.

A caveat of this study concerns the choice of Drosophila strain. We used the wild-type Canton-S line as a representative of D. melanogaster. However, previous reports have shown that phototactic behavior can vary depending on the strain47,48. In fact, one of the original study on phototaxis deliberately selected the Canton-S line because of its strong light response47. Thus, our findings may not be fully generalizable to other D. melanogaster strains. Although several studies have reported that Canton-S and other wild-type strains exhibit comparable phototactic and spectral preference behaviors34,36 it remains possible that spectral preference is influenced by genetic background. Moreover, previous research has shown that phototactic behavior can also be affected by individual variation48. Therefore, both genetic and environmental factors may influence innate spectral preference, and similar considerations should be applied when interpreting learned chromatic behaviors.

In our slow phototactic assay, flies exhibited an innate preference for moderately longer wavelengths (green to orange) and avoidance of shorter wavelengths (violet to blue), contrasting with the short-wavelength preference seen in fast phototaxis. Similar findings include a green preference over blue in D. melanogaster49 and an innate preference for yellow wavelengths in some dipteran species, such as the blow fly50 and the hover fly Eristalis tenax51. These results suggest that yellow to orange wavelengths may have an innate attractive effect in some dipteran species, although the underlying neural mechanisms and ecological significance remain unclear11. Conversely, shorter wavelengths can be harmful to flies52,53. A recent study demonstrated consistent blue avoidance mediated by Rh7 and the TRP channel Painless in neurons located on the body surface at high light intensities29. This study also shows that the green preference at dawn and dusk is mediated by Rh1 receptors and dynamically modulated by the circadian rhythm through the action of the TRP channels, TrpA1 and Pyrexia. Although the behavioral contexts differ and thus direct comparison to our study is limited, the blue avoidance observed here may also be mediated by a non-visual component, while the green preference may be mediated by Rh1 receptors. Additionally, extraretinal photosensitive molecules such as cryptochrome and Rh7 have been shown to influence the activity levels of flies21,24,54,55. Further research is needed to identify the photoreceptor inputs and other extraretinal photosensitive components involved in slow phototactic behaviors, using genetic manipulations of candidate photoreceptors and extraretinal photosensitive molecules, as well as analyses of downstream circuit elements.

In this study, we introduced a newly developed visual learning assay. Various types of associative visual learning assays have been established for flies18,19,41,43,44,45,50,56 differing in factors such as the number of flies tested (individuals or groups), the type of unconditioned stimulus used (appetitive stimuli like sucrose as a reward or aversive stimuli such as electric shock, shaking, or heat as punishment), and the conditioning method applied (differential or absolute). Our assay was designed based on the behavioral paradigm developed by Schnaitmann et al., who demonstrated blue vs. green color discrimination using appetitive learning with sucrose reward19,49. We also referred to Spatz et al.’s work, which evaluated color discrimination starting with blue vs. yellow, followed by various other color combinations, using aversive learning with shaking punishment41,42.

Like these assays, our method uses a population of flies freely walking in an illuminated arena during both conditioning and testing. Population-based assays offer a practical approach and can reduce variability between individuals, though group effects may still influence results57. We employed aversive heat as the unconditioned stimulus, a stimulus well-established in conventional single-fly assays using infrared beams43,44. Finally, differential conditioning was applied in our assay; this method has been shown to enhance color discrimination in honeybees58. While we assume the heat stimulus induces aversion, relief from the aversive temperature may also act as positive reinforcement.

There are several potential limitations in our study that should be acknowledged. First, our visual learning assay did not conclusively demonstrate that flies discriminated between two visual cues based solely on wavelength differences, independent of light intensity. Rather, we showed that flies were unable to discriminate intensity differences at each wavelength but could distinguish between several wavelength combinations with relatively small intensity differences. To accurately separate the contributions of wavelength and intensity, it is essential to assess the animal’s perception of subjective brightness. However, currently, no established behavioral paradigm exists to fully disentangle these two factors in insects9. An alternative approach is the conversion experiment, which in our study showed moderate discriminability based on wavelength over intensity (Supplementary Fig. S1e). Second, our assay evaluated flies’ preference for direct light emitted from the light source, rather than for object colors reflected under illumination. Although this method allows greater control over wavelength and intensity of the stimuli and is commonly used with the assumption that the perceived sensation corresponds to object color detection (e.g. 18,19,42,59), there remains a caveat regarding potential photoreceptor adaptation11. Third, as described above, some TRP channels may be sensitive to both light and temperature and could play a role in spectral preference behavior29. These TRP channels may be influenced by both the light stimuli and the aversive heat stimuli used in our learning paradigm; however, their actual contribution was not examined in this study. Finally, the learning scores in our assay were relatively low even when flies significantly discriminated between two colors. In general, visual learning in D. melanogaster tends to show lower performance compared to olfactory learning, regardless of the type of unconditioned stimulus employed39. This likely reflects an inherent bias in D. melanogaster’s learning abilities toward olfactory cues, possibly related to the relative amount of neural input to the mushroom body60,61.

Our results showed that flies could discriminate combinations of violet, blue, and green wavelengths, but could not discriminate combinations involving green, yellow, orange, and red. This suggests that discriminability is enhanced in the wavelength range where the spectral sensitivities of multiple photoreceptors overlap, rather than in regions where their sensitivities do not overlap. Most previous studies on color vision in D. melanogaster have focused on blue vs. yellow40,41 or blue vs. green19,43,44 with only one study examining a relatively wide spectral range42. Therefore, our study provides a second piece of evidence regarding spectral discrimination properties in D. melanogaster, under different behavioral conditions, offering valuable insights into the spectral discrimination abilities of this important model organism. Our findings contrast with those of Salomon et al. (1983)42as flies in our study showed weak discriminability between middle (green) to longer (red) wavelengths, indicating that wavelength dependency in learning may vary across the entire visible spectrum. Similar results have been reported in other fly species, where discrimination at green and red wavelengths is less robust compared to blue and yellow50. This reduced wavelength contrast may be due to a lack of variation in long-wavelength photoreceptors in flies. A similar trait is observed in bees, which possess three classes of spectrally sensitive photoreceptors, with peak sensitivities in the ultraviolet, blue, and green ranges62 and exhibit poor red discrimination63. In contrast, butterflies have greater photoreceptor variation from duplications and screening pigments, including red receptors sensitive to longer wavelengths64,65 enabling them to achieve fine discrimination in this range66,67. Whether the use of photoreceptors is conserved across insect species or is species-specific remains a matter of debate13,68,69,70.

Although our results showed that flies were unable to learn to discriminate based on intensity differences, the potential influence of intensity differences cannot be entirely ruled out. Previous studies have demonstrated that flies are capable of learning to distinguish differences in light intensity under certain conditions19,45,46. However, it has also been shown that chromatic information tends to be prioritized over intensity cues, as well as over other achromatic cues such as form19,41,44 suggesting that chromatic cues may be a more salient visual feature for flies in these behavioral contexts. Similarly, in our experiments, wavelength differences may have been perceived as more salient than intensity differences. In contrast, honeybees have been shown to use chromatic and achromatic information differently depending on visual angle: achromatic contrast is used for objects subtending 5–15˚ of visual angle, while chromatic contrast is used for objects larger than 15˚ 71,72. The neural mechanisms underlying such context-dependent visual processing in honeybees—and whether similar strategies are employed by Drosophila—remain unclear.

Modeling approaches that incorporate photoreceptor spectral sensitivities and behavioral data are commonly used to predict which photoreceptors contribute to color discrimination1. Regarding color discrimination in Diptera, an influential model proposed categorical discrimination in the blow fly18. This model has been supported by studies in other fly species73 and widely used to represent dipteran color space (e.g. 74,75,76). However, our results do not align with this model, as blue, green, yellow, orange, and red stimuli all fall within the same category (Fig. 4c). This discrepancy may be partly due to experimental conditions. Our assays were conducted in darkness, without accounting for photoreceptor adaptation to background light. Troje’s original model, by contrast, included gain adjustments based on light adaptation and defined four categories: UV, blue, green, and purple (UV–green). Applying similar gain adjustments to our data, the resulting map aligned more closely with our behavioral data, though only marginally (Supplementary Fig. S2). Additional experiments using a broader set of wavelength combinations—both within and across the proposed categories—are necessary to further evaluate the validity of this model.

We also considered applying the receptor noise-limited (RNL) color-opponent model, another widely used framework for insect color vision77. This model allows for the calculation of a spectral discrimination function (∆λ), which can be compared with behavioral data59. However, the limited number of wavelengths tested in our behavioral experiments prevented an accurate reconstruction of the spectral discrimination function. Therefore, we conclude that our dataset is not suitable for applying the RNL model.

We evaluated the distances between monochromatic light stimuli in photoreceptor space, defined by the quantum catches of each photoreceptor, and compared models with and without the broadband Rh1 photoreceptor. To reduce redundancy among photoreceptor spectral sensitivities, we applied PCA, representing color loci in a two-dimensional space defined by PC1 and PC2. The model excluding Rh1 provided a better fit to our behavioral data, consistent with previous proposals that Rh1 does not substantially contribute to chromatic processing in flies18,78. This finding contrasts with prior models suggesting that inclusion of Rh1 improves alignment with behavioral outcomes19,79. Notably, inclusion of Rh1 in our model resulted in a clear separation of green from longer wavelengths (yellow, orange, and red), which was not supported by our behavioral observations (Supplementary Fig. S3a). To further examine the nature of photoreceptor interactions underlying color discrimination, we reconstructed the PC1 and PC2 axes (Fig. 4f). The resulting opponent axes closely resembled those described by Heath et al.78, indicating that similar chromatic processing mechanisms may be conserved. Nonetheless, discrepancies between the model and empirical data persist. In particular, while the model predicted large perceptual distances between violet and longer wavelengths, behavioral discrimination in this range was limited. This suggests that additional factors—such as perceptual brightness or context-dependent sensitivity—may influence color discrimination and should be considered in future models. In addition, our study did not include light stimuli in the UV range, which may have reduced the contribution of photoreceptors sensitive to these wavelengths.

Here, we characterized both innate spectral preferences and learned chromatic discrimination in D. melanogaster using a defined behavioral paradigm. While the neural circuits linking photoreceptor input to chromatic behavior remain largely unresolved across insect taxa, recent studies in D. melanogaster have elucidated mechanisms of color opponency mediated by inhibitory interactions among photoreceptor axons78,80. Although color-opponent neurons in higher brain centers remain elusive60,81 recent studies have identified circuits within the optic lobe that involve interactions between chromatic and achromatic pathways, as well as color-opponent neurons exhibiting spatially and spectrally double-opponent properties82,83,84. These findings, together with the uniquely detailed connectomic datasets now available for D. melanogaster85 set the stage for comprehensive circuit-level analysis of spectral coding. Our behavioral results provide foundational data to support such efforts. By refining the current paradigm and combining the powerful genetic tools, future studies are well positioned to resolve the neural computations underlying spectral processing at single-cell resolution—an objective that remains difficult to achieve in other systems.

Materials and methods

Fly stocks

All flies were maintained on conventional cornmeal agar medium under a 12-hour light: 12-hour dark cycle at 24 ˚C. Flies 3 − 10 days after eclosion were used in all experiments. The fly line used in this study was the wild-type strain Canton-S, which was provided by Dr. A. Nose.

Fly chamber

Flies were placed in a custom-made acrylic chamber produced using a 3D printer (DMM.make, https://make.dmm.com/). The chamber size was 55 × 75 × 20 mm, with a sliding slit through which two thin plastic plates were inserted. An acrylic plate (55 × 75 × 1 mm) was attached to the bottom of the chamber using adhesive. Approximately 50 flies were transferred into the chamber using an aspirator through a small hole in the plastic plate. Afterward, the hole was covered with another plastic plate. The space available for the flies to move freely was 55 × 75 × 3 mm. Males and females were not distinguished. The chamber was cleaned with wet paper soaked in distilled water after each experiment and thoroughly washed at the end of each experimental day.

Experimental apparatus

Two sets of conditioning apparatus (Fig. 1c) and two sets of testing apparatus (Fig. 1d) were placed side by side in a darkroom. A conditioning apparatus consisted of electric circuits built on a breadboard that controlled illumination from light-emitting diodes (LEDs) and a cooling plate that regulated temperature (Fig. 1c). Six wavelengths of LEDs (all sourced from AKIZUKI DENSHI TSUSHO CO., LTD) were used: violet (OSV5YL3131A, λmax = 402 nm), blue (OSB56A3131A, λmax = 470 nm), green (OSPG3131P, λmax = 526 nm), yellow (OS5YKA3131A, λmax = 596 nm), orange (OS5OAA3131A, λmax = 613 nm), and red (OS5RKA3131P, λmax = 630 nm). The wavelengths and intensities of the light were measured using a spectrometer (HSU-100S, Asahi Spectra) (Figs. 1e, f). The LED circuits consisted of four units, with each unit containing five 3-mm LEDs connected in series. Each LED was covered with a diffusion cap. The four sections of the chamber were illuminated by each LED unit through the separator. The black nylon separator, produced using a 3D printer (DMM.make), measured 55 × 75 × 50 mm with the four sections separated by thin walls. The top of the separator was covered with a sheet of paper. The light intensity was adjusted using carbon resistors, and electric power was supplied to each unit by a 24 V AC adapter. For conditioning, LEDs of the same wavelengths were mounted in each of the four units, and the chamber was illuminated from above. A testing apparatus consisted of the same electrical circuits that controlled illumination as the conditioning chamber (Fig. 1D). For testing, LEDs of two different wavelengths were mounted diagonally (or parallel in the pilot experiments), and the chamber was placed on the separator and illuminated from below.

Preference experiments

Preferences for the two light stimuli were evaluated using the test apparatus without conditioning. Flies were housed in the chamber, and after a two-minute dark-adaptation period, five-minute tests were conducted and recorded using a CMOS camera (DCC1545M, Thorlabs) positioned above. During the tests, the flies moved freely within the chamber, which was illuminated by two light stimuli projected diagonally opposite each other. The number of flies distributed after two minutes was counted, and preference indices were calculated.

Discrimination experiments

We employed classical associative learning with differential conditioning using aversive temperature as the unconditioned stimulus (US) and light from LEDs as the conditioned stimulus (CS). During the training phase, the chamber was placed in the conditioning apparatus and positioned on the cooling plate, where the temperature inside the chamber was set to either an aversive level (34,36, or 39˚C) or a normal level (22˚C). Light from LEDs was projected onto the chamber from above through the separator. Two sets of conditioning apparatus were placed symmetrically, with one set configured to an aversive temperature associated with one light stimulus and the other set configured to normal temperature associated with the other stimulus. After the fixed training period (the standard protocol was one minute), the two chambers were swapped, and the flies were trained under the other condition for an additional period (Supplementary Figs. S1a, c). This procedure was repeated several times (the standard protocol was six times). After approximately 30 s in a dark place at room temperature, the chamber was moved to the test apparatus. During the tests, the flies moved freely within the chamber, which was illuminated by two light stimuli projected diagonally opposite each other (or in parallel during pilot experiments). Then, five-minute tests were conducted and recorded using a CMOS camera positioned above. The number of flies distributed after two minutes was counted, and learning indices were calculated. The tests were performed at room temperature.

Preference and learning indices

The number of flies after two minutes was counted. A preference index (PI) for wavelength λA vs. wavelength λB was calculated as the difference between the number of flies in area A, illuminated by wavelength λA, minus the number of flies in area B, illuminated by wavelength λB, divided by the total number of flies:

$$\:\text{P}\text{I}\:=\:(\#\text{f}\text{l}\text{i}\text{e}\text{s}\:\text{i}\text{n}\:\text{A}\:-\:\#\text{f}\text{l}\text{i}\text{e}\text{s}\:\text{i}\text{n}\:\text{B})/(\:\#\text{f}\text{l}\text{i}\text{e}\text{s}\:\text{i}\text{n}\:\text{A}\:+\:\#\text{f}\text{l}\text{i}\text{e}\text{s}\:\text{i}\text{n}\:\text{B})$$

For the discrimination experiments, preference indices for pattern I (PI1), where wavelength λA was associated with the aversive temperature and wavelength λB was associated with the normal temperature, and for pattern II (PI2), where wavelength λB was associated with the aversive temperature and wavelength λA was associated with the normal temperature, were calculated first for each experiment as above:

$$\:{\text{P}\text{I}}_{1}\:=\:(\#\text{f}\text{l}\text{i}\text{e}\text{s}\:\text{i}\text{n}\:\text{B}\:-\:\#\text{f}\text{l}\text{i}\text{e}\text{s}\:\text{i}\text{n}\:\text{A})/(\:\#\text{f}\text{l}\text{i}\text{e}\text{s}\:\text{i}\text{n}\:\text{B}\:+\:\#\text{f}\text{l}\text{i}\text{e}\text{s}\:\text{i}\text{n}\:\text{A})$$
$$\:{\text{P}\text{I}}_{2}\:=\:(\#\text{f}\text{l}\text{i}\text{e}\text{s}\:\text{i}\text{n}\:\text{A}\:-\:\#\text{f}\text{l}\text{i}\text{e}\text{s}\:\text{i}\text{n}\:\text{B})/(\:\#\text{f}\text{l}\text{i}\text{e}\text{s}\:\text{i}\text{n}\:\text{A}\:+\:\#\text{f}\text{l}\text{i}\text{e}\text{s}\:\text{i}\text{n}\:\text{B})$$

Then, a learning index (LI) was calculated for the two consecutive experiments as follows:

$$\:\text{L}\text{I}\:=\:({\text{P}\text{I}}_{1}\:+\:{\text{P}\text{I}}_{2})/2$$

The preference indices (PIs) from the two patterns of differential experiments were averaged. The LI indicated how well the flies learn to discriminate between two visual stimuli, with values ranging from 1 to − 1. A value of 1 indicates that all flies chose the light associated with the normal temperature, 0 indicates a neutral response, and − 1 indicates all flies chose the light stimulus associated with the aversive temperature. The LI canceled out the innate preference for one of the stimuli, which was assumed to be symmetrically overlaid in both patterns of preference indices.

Visual models

Relative spectral sensitivity of each photoreceptor (Rh1, Rh3, Rh4, Rh5, and Rh6) was obtained from a recent study, where photoreceptor sensitivities were measured in vivo15.

The quantum catch for photoreceptor i was calculated as follows:

$$\:{Q}_{i}=\underset{315}{\overset{700}{\int\:}}I\left(\lambda\:\right)*{S}_{i}\left(\lambda\:\right)\:d\lambda\:$$

Where I(λ) was the normalized light intensity of a light stimulus and Si(λ) is the spectral sensitivity of the i-th receptor. Based on the quantum catch of each photoreceptor, the visual stimulus was plotted in photoreceptor space.

Troje’s categorical models

The categorical color vision model was proposed by Troje18. Based on the quantum catch values Qi calculated above, photoreceptor excitations were computed as follows:

$$\:{E}_{i}\:=\:{Q}_{i}\:/\:({Q}_{i}\:+\:1)\:$$

Where Ei can take any value between 0 and 1. The categorical model consists of two axes of inner photoreceptor subtractions in either pale-type or yellow-type ommatidia; p = (E3 E5) / (E3 + E5), y = (E4 E6) / (E4 + E6). If the stimulus spectrum did not overlap with the spectral sensitivity of the photoreceptors defined for each axis,  1 or 1 was assigned, depending on whether the stimulus wavelength was shifted to longer or shorter wavelength, respectively. Achromatic information was excluded. There are four categories depending on the polarity of the subtractions of these inner photoreceptors: p  y, p  y+, p + y+, and p + y.

Representation in photoreceptor space via dimensionality reduction

Quantum catches of each photoreceptor for each LED stimulus were calculated, and the LED stimuli were represented as four-dimensional or five-dimensional vectors. Principal component analysis (PCA) was applied to the quantum catches of the six LED stimuli (violet, blue, green, yellow, orange, and red) across the four photoreceptors (Rh3–Rh6) or the five photoreceptors (Rh3–Rh6 and Rh1). The quantum catch values were transformed to z-score before PCA to normalize the weights of each photoreceptor. Each LED stimulus was then plotted in a two-dimensional space, with PC1 and PC2 as the axes. The distances between the six LED stimuli were calculated using the Euclidean distance metric. Linear regression analyses were performed between the distances in photoreceptor space and the mean values of LI.

Statistics

Statistical analyses were performed using MATLAB software with the Statistics and Machine Learning Toolbox (MathWorks). For the spectral preference and learning discrimination experiments, if the data did not violate the assumption of normality (Shapiro-Wilk test), statistically significant differences from zero were assessed using a one-sample t-test with a Bonferroni correction. If the data significantly deviated from the assumption of normality, Wilcoxon signed-rank tests with a Bonferroni correction were applied. Statistical details are presented in Tables 1, 2 and 3 and Tables S2–S4, including the specific statistical tests applied to each dataset. All the graphs are presented as boxplots, which display the median (central line) and quartiles (boxes), with the whiskers extending to the minimum and maximum points within 1.5 times the interquartile range. Individual value plots are overlaid onto the boxplots.