## Introduction

The fruit fly, Drosophila melanogaster, is a key model for invertebrate vision research1. The small diameters of cells in the early visual neuropil have long limited electrophysiological approaches to recording neural activity in the optic lobes, a problem recently overcome with advances in technology and genetic tools that make functional imaging methods possible2,3,4. Though these imaging methods have facilitated extensive characterisation of motion vision in flies5, how flies process colour information, or how the spectral content of light affects other visual modalities, remains largely unknown.

Photoreceptors in the Drosophila eye express different classes of photoreceptive cells, referred to as R1-R8. Within an ommatidium, the six outer photoreceptors (R1-R6) express the broadband rhodopsin (Rh) 1. The more centrally located cells (inner photoreceptors), R7 and R8, express Rh3-6 photopigments, which are narrowly tuned to UV, blue and green bands of the spectrum6,7,8. R7-R8 cell pairs co-ordinately express a particular Rh to construct one of two types of ommatidial partnerships: ‘pale’ (Rh3 and Rh5) and ‘yellow’ (Rh4 and Rh6)6,9. These are stochastically distributed following a 30:70 ratio10. Spectral sensitivity is also shaped by additional pigments which exert influence on the response properties of the photoreceptor cells11. These have recently been shown, for example, to dramatically shift Rh6 expressing photoreceptors to peak at 600 nm, rather than the native 508 nm peak12. Light-absorbing screening pigment encircling each ommatidium restricts off-axis light from reaching the photoreceptors11,13,14 and yellow-coloured pigment granules in R1-R6 cells contribute to spectral tuning via a dynamic and light-dependent migratory pattern15,16,17. In addition to screening pigments, a blue-absorbing yellow filter is found in ‘yellow’ R7 cells18, and a carotenoid-based sensitising pigment contributes additional sensitivity in the ultraviolet through energy transfer to the visual pigment19. Visual information, modified by pigments before detection by receptors, is then processed in downstream neuropil innervated by photoreceptors: R1-R6 project to the lamina, the first visual neuropil, whereas R7 and R8 terminate in the second neuropil, the medulla20,21.

The overall picture of colour vison in Drosophila is being pieced together with improved knowledge of photoreceptors, candidate cells involved in circuitry, and colour-guided behaviour22,23,24,25,26,27,28, but much still remains to be characterised. The long-standing dogma advocates that the motion and colour vision processing streams are neatly separated, with R1-R6 providing input to the motion detection pathway and R7-R8 providing input to the colour vision pathway22,29,30,31. More recent evidence, however, demonstrates that signals arising from R7 and R8 improve motion processing in Drosophila32. This paradigm of combining modalities at an early stage of visual processing has previously been demonstrated as a strategic mechanism for improved perceptual discrimination and retention of salient visual features33,34,35.

Commercially available visual displays are tailored to the primate retina. Their three-colour channel configuration provides an excellent experience to the trichromatic user but fall short for visual systems with different photoreceptor sensitivities. Furthermore, the high flicker-fusion frequencies in invertebrates, beyond 120 Hz in Drosophila melanogaster36, outpace the refresh rates of commercial displays. An array of experimental systems for visual stimulation have been developed, but many constraints still limit the investigation of combined colour and motion processing. The production of bands of monochromatic light is commonly achieved via a broadband light source coupled either to a monochromator8, individual colour filters37,38, LEDs39, or more recently LED-based monochromator systems40. Such monochromatic light provides full-field stimulation but lacks any spatial structure. Paradigms for spatially patterned stimuli include LCD displays, LED panels or projectors, none of which offer the option of many colours26,41,42,43. In order to probe visual response properties to combined modalities, the integration of spectral and spatial resolution within a stimulation paradigm is essential. In addition, the spectrally broad and high detection sensitivity of two-photon imaging systems restricts the visual stimuli’s spectral range and intensity: light applied within the detection range of the microscope will result in an artefact on the acquired image consequently restricting the range of wavelengths available for visual stimulation.

In order to determine the precise contribution of spectral information to visual computations, whether general or colour-specific, we designed a system that offers fine-wavelength resolution across a large portion of the spectrum, that can be calibrated to produce isoluminant stimuli over a biologically-relevant range of intensities and that allows the presentation of spatially- and temporally-structured stimuli. This system presents several advantages not offered in any previous imaging-based setups for characterising physiological responses to colour. These include (1) the delivery of coloured stimuli simultaneous to the acquisition of two-photon images (previous methods rely on the scanner fly-back periods for stimulation26,43), (2) the ability to arbitrarily chose the centre wavelength and bandwidth, and (3) a rear projection screen which maintains isoluminant hues across the visible spectrum. Using this setup, we characterised intensity-response relationships and spectral response profiles of the pan-neuronally labelled medulla (the second visual neuropil) in several genetically modified strains of Drosophila, varying in opsin functionality and screening pigment density.

## Results

### A modified monochromator-projector-microscope system

A visual stimulus was presented to a fly while imaging its neural responses via a two-photon microscope. To produce a range of colours (selectable narrow bands of the spectrum), we modified a projector to use a monochromator as its light source (Fig. 1A). We introduced custom Semrock bandpass optical filters to the imaging and visual stimulation pathways (Fig. 1B). These filters allowed for the presentation of a visual stimulus with minimal contamination to the calcium signal read. One filter set, added to the monochromator, blocks the wavelengths of light within the microscope’s detection range. The other set of optical filter combination is integrated into the microscope to limit the wavelengths of light entering the detectors and works to reject bleed-through of detectable light wavelengths from the visual stimulus by means of an arrangement of high optical density bandpass filters (further details of the filters in Supplementary Fig. S1).

### Combined spectral and spatial precision

The light produced by the monochromator can be modified for two parameters, wavelength and intensity, providing ample versatility to produce stimuli across the visible spectrum and across several log units of intensity. To test for spectral response independent of brightness, all monochromatic bands of light were calibrated to produce the same radiance with minimal variation over time (Supplementary Fig. S2). Bands spanned from 385 to 725 nm at approximately 5 nm centre wavelength intervals. Gaps in the transmitted light between 500–540 nm and 610–650 nm (Supplementary Fig. S2) exist because of the dichroic filters integrated to the monochromator. Furthermore, we sought to ensure minimal variation of projected light across the two-dimensional plane. As the distance between the fly’s eye and the screen increases towards the outer edges of the screen, the brightness diminishes accordingly (Fig. 2A). A more problematic source of variation, however, stems from light scattering. Scattering is an inherent and necessary property of the screen to ensure light diffuses over the array of angles required to reach the fly’s eye (Fig. 2A). Scattering properties of a material, however, are coupled to the wavelength of the light. This creates the challenge of identifying a screen material that scatters light in an equivalent manner across the UV and visible spectrum. We identified a screen fitting these requirements (Da-Lite, Polacoat Flex Plex Video Vision), ensuring that calibrated isoluminant bands of light at the screen centre retain their flat isoluminant calibration across the screen from 385 to 720 nm (Fig. 2B,C). A small variation between the UV and red light occurs at the outer edges of the screen. However, by delimiting a circular ellipse (diameter: 400 pixels/38.8 degrees of visual field), with its centre realigned to correspond to maximal brightness (blue dot, Fig. 2B), the projected stimulus retains spectral constancy (Fig. 2D).

### Proof of concept: spectral response properties in the Drosophila medulla

#### General medulla responses

To probe spectral response properties in the medulla of Drosophila, we established intensity-response relationships and spectral response profiles by means of calcium activity indicator imaging in pan-neuronally labelled flies. Transgenic fly strains differed from each other for one or more of the following parameters: screening pigment density (red: high, orange: low), photoreceptor function (intact or Rh1-only) and calcium activity indicator (GCaMP6f: green, RGECO: red, Fig. 3A).

A set of full-field light pulses of increasing intensity were applied to the fly’s eye (Supplementary Fig. S3) and sigmoid curves fitted to establish intensity-response relationships for UV, blue and green light (390, 460 and 565 nm centre wavelength respectively, Fig. 3B). We observed a left shift of the green intensity-response curve and half-maximum values in orange-eye flies by comparison with their red counterparts (Fig. 3B,C), indicative of increased sensitivity to longer wavelengths of light. Next, we applied a series of light pulses ranging from UV light through to red light set at approximately 5 nm centre wavelength intervals (Supplementary Fig. S3) and plotted normalised spectral response curves (Fig. 3D). Our results revealed strain-specific sensitivity to colours: orange-eye flies exhibited a decreased sensitivity in the blue range and an increased sensitivity in the green range by comparison with their red eye counterparts (Figs. 3D and Supplementary Fig. S5). Coefficient values extracted from fitted intensity response curves (slope and half maximum, Supplementary Fig. S4) suggest minor response property discrepancies between flies expressing GCaMP6f and RGECO (Supplementary Fig. S4), attributable to differences in amplitude and decay times44. Consequently, we did not pool data from RGECO-expressing flies with GCaMP6f data for statistical analyses. Nonetheless, this red-emitting indicator serves the valuable purpose of completing the spectral profile as the red GaAsP is used to record RGECO signals, thus allowing the GCaMP-restricted green wavelengths of the spectral sweep to be filled in (Fig. 3E).

#### Layer-specific responses

Pan neuronal labelling of the medulla reveals clearly discernible and identifiable layer structures (Fig. 4A) allowing us to delve into layer-specific responses for the intensity-response relationships and spectral response curves as above (Fig. 4B,C and Supplementary Fig. S6). Our results demonstrate that half maximum values for UV, blue and green light exhibit layer-specific variability between fly strains (Fig. 4C). Although most layer groupings retain the higher sensitivity of orange-eye flies to green light, this difference disappears in layers M2 and layers M6-M7. The decreased sensitivity of orange-eye/Rh1-rescue flies relative to the red eye/wildtype photoreceptor flies in the UV-blue range of the spectral response curve (Fig. 3D) is only apparent in layers M6-M7 and M9-M10. Strikingly, the red eye/Rh1-rescue flies exhibit increased sensitivity to UV, blue and green light in M2, but this increased sensitivity does not occur in the orange eye/Rh1 rescue flies. We also see this trend in layer M3, and we attribute the absence of statistical significance to the lower number of ROIs with successfully fitted intensity-response curves as response size is smaller than other layers.

## Discussion

We developed a novel experimental setup that enables simultaneous two-photon functional brain imaging and visual stimulation across the spectrum in Drosophila. With this system, a fly can be presented with over 50 different wavelength bands of the visual spectrum, causing minimal disruption to the image quality produced by the microscope. Furthermore, our visual stimulation paradigm provides combined high spatial resolution and high spectral resolution, overcoming the customary trade-off between the two parameters.

The modifications to the optical pathway in both the monochromator and the microscope overcome the major limitation for spectrally-varied stimuli with two-photon imaging. The study of motion vision in Drosophila is usually carried out using blue light for visual stimulation, which offers an adequate wavelength range for Rh1-derived visual responses that sits outside of the PMT’s detection range. For the use of spectrally diverse stimuli, a workaround method was developed whereby the visual stimulus delivery occurs during the two-photon scanner fly-back period26,27. This approach, however, is limited by the discontinuous nature of the visual stimulus, which could introduce aliasing problems with moving patterns, but also reduces the microscope photon collection time thereby reducing the imaging sensitivity (this particularly affects calcium indicators with slow temporal responses). The introduction of custom Semrock bandpass filters in our system results in an extensive range of possible wavelengths for visual stimulation simultaneous to the acquisition of imaging data by the microscope. A gap in the spectrum corresponding to each PMT’s detection range still exists, but is considerably narrowed, and can be overcome by switching between neural activity indicators with different emission spectra detected by alternate PMT detectors.

In addition to the combination of simultaneous spectral visual stimulation and two-photon imaging, we also present a screen material that maintains near-constancy of the brightness of a wavelength band at all points of the screen from UV through to red light. To our knowledge, this surpasses all currently published screen materials in this regard, and offers a host of possibilities for characterisation of combined visual modalities such as motion and colour. The inevitable drop in radiance and spectral constancy towards the outer edges of the screen can be eliminated by restricting the stimulus to the central portion of the screen. Alternatively, if some variation of the brightness and spectral properties of the stimulus is not deemed to impact response properties, use of the extended screen area provides a greater coverage of the visual field.

Our understanding of the spectral quality of visual information transmitted by the different photoreceptive cells to downstream visual neurons is primarily based on the generation of spectral sensitivity curves for opsins or electroretinogram measurements of the surface of the eye8,45. A recent study, however, demonstrated that R7 and R8 terminals interact to transform the inner photoreceptor output to a biphasic sensitivity curve26, exemplifying the modification of spectral tuning at the early stages of visual processing. Very little is known about how outputs of different photoreceptors might be combined by colour-encoding circuits, highlighting the need for high resolution spectral stimulus capabilities. Our system uses narrow bands of monochromatic light well suited to our investigation into spectral response properties, but it is entirely possible to modify the light source to produce multispectral light using a system such as the LED-based monochromator40. Methods commonly employed in mammalian vision research, such as the sophisticated combination of multispectral light to effectively target only one class of photoreceptors46, are limited in invertebrates. Further characterisation of the effect of pre-receptoral filtering, such as eye pigment screening, as well as instability and adaptation properties of visual pigments, is required. With this information, a smaller, but carefully selected, array of colour channels can be coupled to a display technology (screen or panel) such as the modified projector system with a five-primary light engine used in mouse vision research42 or the arbitrary-spectrum spatial visual stimulator presenting up to six chromatic channels43.

An ideal spectral stimulation range would extend further into the UV portion of the spectrum to match the known spectral sensitivities of Rh1, Rh3 and Rh4. Monochromators providing this range of UV light exist. However, the high-energy photons of the shorter wavelengths are lost by transmission throughout the optical pathway, with the DLP chip in the projector, in particular, drastically reducing the UV content of light. The ongoing progress in the development of UV transmitting projectors (e.g. Texas Instruments) and optics might soon provide an adequate and affordable solution and extend the capabilities of our system to include UV visual stimulation.

The experimental setup we describe here enabled us to record the responses to a range of narrow bands of light across the spectrum, over a range of intensities spanning several log units of light in the medulla. We find several modifications of spectral response properties in the summed activity of the pan-neuronally labelled neuropil between transgenic fly strains, demonstrating the precision, reliability and sensitivity of our setup. A reduction of screening pigment density results in increased sensitivity of medulla neurons to longer wavelength of light, consistent with prior electroretinogram recordings in flies and Goldsmith’s recruitment hypothesis47,48,49. Goldsmith stipulates that absorption of light by screening pigments decrease any light contribution from neighbouring photoreceptors to the visual response of a given ommatidium. The degree of shielding from off-axis light is directly related to the density of the screening pigment. Thus, we understand the increased sensitivity of orange-eye flies to longer wavelengths of light to derive from the decrease in screening pigment density coupled to the intrinsic properties of the pigment favouring the reflectance of wavelengths in the red portion of the spectrum.

Assessment of inter-layer variability revealed a diversity of responses. Most intriguing is the increased sensitivity of layers M2 and M3 in red eye flies that have lost R7 and R8 function, suggestive of inhibitory control of postsynaptic neurons in wild type flies by the R8 cells that terminate in M350. Several reasons may explain why orange eye flies lacking functional photoreceptors do not also exhibit increased sensitivity in M2 and M3. Flies homozygous for the white null allele 1118 are known to have retinal degeneration51 and this may not be rescued with the mini-white vector expression. This effect could also be attributed to prolonged depolarisation afterpotential (PDA)52, more common in white-eye flies53, where the temporary light insensitivity of the photoreceptor requires red to shift metarhodopsin back to rhodopsin. This could also explain the decreased responsiveness to short wavelengths observed in the spectral response profile of this strain. The decreased sensitivity in the orange-eye flies to UV light in layers M6-M7 could be attributable to the lack of input from UV-sensitive R7 photoreceptors that project to this layer50,54. It is less clear, however, why these flies lose their increased sensitivity to green light uniquely in this layer structure. If the shift in response properties is caused by the photoreceptor terminals, green light should inhibit R7 activity26,27, resulting in decreased sensitivity in the red-eye flies expressing all functional opsins while maintaining unaffected high sensitivity in the orange-eye strain. Our data appears to suggest layer-specific shifts in spectral response properties in the medulla corresponding to projection regions of photoreceptor terminals. We did not detect summation of R7-R8 with R1-R6 signals proposed to drive lobular plate responses reported previously32 as we found no difference between wild type and Rh1-only red-eye flies in most layers, however further investigation is required to establish this with certainty.

Our setup overcomes many limitations that have hindered the study of colour vision and the integration of visual modalities in Drosophila. Going forward, it will serve as a highly versatile tool to further recent breakthroughs in the field26,27 and unravel the neural circuitry underlying spectral processing.

## Materials and methods

### Fly stocks

Expression of the fluorescent calcium indicators GCaMP6f3 and RGECO44 was achieved using the GAL4/UAS expression systems55. We used the pan-neuronal promoter nSyb (Bloomington Stock Center, 39171) and the following stocks for the red-eye norpA36 X chromosome mutant32, white-eye norpA36 mutant (Bloomington Stock Center, 52276) and rhodopsin 1 rescue construct for norpA (Bloomington Stock Center, 9048). Four different fly stocks were used in this study:

1. 1.

w[ +]; P{yw [20XUAS-IVS-GCaMP6f}attP40/ + ; P{yw [GMR57C10-GAL4}attP2/ + (n = 5)

2. 2.

w[ +]; + ; P{yw [GMR57C10-GAL4}attP2, PBac{w, 20xUAS-jRGECO1a-p10}VK5 (n = 5)

3. 3.

w[ +] norpA [36]; UAS-GCaMP6f / P{w[+ mC] = ninaE-norpA.W}2; 39,171-Gal4/ + (n = 4)

4. 4.

w[-] norpA [36]; UAS-GCaMP6f / P{w[+ mC] = ninaE-norpA.W}2; 39,171-Gal4/ + (n = 5)

Fly stocks were made using standard fly crossing techniques using balancer chromosomes and in the case of stock 2, recombination was used to bring two insertions onto the same chromosome. Note that P{yw [20XUAS-IVS-GCaMP6f}attP40 is abbreviated as UAS-GCaMP6f, P{yw [GMR57C10-GAL4}attP2 is abbreviated as 39171—Gal4. Stock 1 is referred to throughout as red eye/wild type photoreceptor function/GCaMP. Stock 2 is referred to throughout as red eye/wild type photoreceptor function/RGECO. Stock 3 is referred to throughout as red eye/Rh1 photoreceptors only/GCaMP. Stock 4 is referred to throughout as orange eye/Rh1 photoreceptors only/GCaMP. Females were used for stocks 1 and 2 and males for stocks 3 and 4.

### Fly care

All flies were reared at 25–27 °C with approximately 60% humidity under a 12:12 light/dark cycle and fed a standard cornmeal and molasses diet. Flies were collected one day after eclosion using CO2 for sedation and were transferred into fresh food vials. A prior study51 cautions against using flies aged beyond 4–5 days if they carry the w1118 mutation for reasons of retinal degeneration, recordings were carried out in 4 to 7-day old flies. Slightly older flies were used due to ease of making the imaging preparation and did not show different results across this age range.

### Fly preparation

Following cold-anaesthesia (~ 15 min in a vial placed on ice), the fly was positioned on a sheet of aluminium foil such that the back of the head capsule protruded through a small cut-out and was tilted to form an approximate 10° angle with the foil sheet. This configuration allowed the back of the head to be exposed for imaging, while leaving the majority of the compound eye below the foil for visual stimulation. Using UV-curing adhesive, the fly was then secured to the sheet with special care to reduce brain movement by attaching the proboscis and legs to the upper thorax and immobilising the abdomen. The sheet of aluminium foil was attached with superglue to a plastic disk, which in turn was secured with 5-min epoxy to a custom aluminium holder (produced by turning on a lathe). The holder was made to fit the tip/tilt stage holder and was held in place by neodymium magnets, allowing easy install with manual rotation. The holder was 45 mm in diameter, 1 mm thick (top, sides and bottom), with an inner recess of 6 mm for the stage holder to form a well to accommodate a saline bath and an inner recess of 14 mm diameter and 10 mm hole to accommodate the replaceable plastic/aluminium foil section. A plastic guard was wrapped around the edge and secured with superglue creating a dam to prevent saline spilling out as we tilted the holder. A saline solution (103 mM NaCl, 3 mM KCl, 20 mM BES, 10 mM trehalose, 20 mM sodium bicarbonate, 1 mM sodium phosphate monobasic, 2 mM CaCl2 and 4 mM MgCl2, balanced to pH 7.4) was added to create a bath over the back surface of the head. The cuticle and underlying trachea were then gently removed to expose the optic neuropil. The trachea extending from the rim of the eye outward over the medulla was removed using forceps to gently pull it away. A gravity/suction pump was used to circulate saline over the course of the experiment to prevent build of up of metabolites or other resulting from the dissection. Following the removal of the cuticle, an interval of 45 min, or more, was allowed to ensure stabilisation of neural activity and dark adaptation of the fly.

### Visual stimuli

A projector (DepthQ 360 DLP, WXGA resolution) coupled to a screen was modified to use an independent light source, a monochromator (Cairn Research Optoscan Monochromator). This allowed us to project selectable narrow bands of the spectrum onto a screen material (Da-Lite, Polacoat Flex Plex Video Vision) that minimised wavelength-dependent scattering properties. The native resolution we used for the projector was 800 pixels wide by 600 pixels high. Only the central portion of the screen was used, segmented by a circular ellipse of 400 pixels in diameter corresponding to 38.8 degrees of visual field. By removing the corners and edges, spectral variation resulting from light scattering is reduced (Fig. 2D). The projector was used for patterned stimuli up to 360 Hz frame rate as some fly species, such as Coenosia attenuata can see up to 300 Hz, while Drosophila melanogaster can see just beyond 120 Hz36. The light guide, the projector, the screen and the stage/holder were adjusted to ensure an ideal alignment of the optical pathway and visual field of the fly. A first adjustment was made to the light guide and projector mirror position to place the maximal brightness at the screen projection centre with an even drop in optical power towards the edges of the screen in all directions. Next, the holder was positioned in relation to the screen such that the holder centre is perpendicular to the projection centre and equidistant to all four corners. Furthermore, the holder and screen/projector are adjusted such that when the holder is positioned to be parallel to the screen, the spectrometer samples light directly at the centre of the screen. A motorised tip/tilt system (Bruker Nema-14 and Nema-17 stepper motors with Standa rotation stages 8MR151-30-MD14-001 and bracket 2AB151-001) allowed us to precisely tilt the holder in any direction such that the central point of the holder where the spectrometer detector (or fly’s eye) is positioned remains in the same point of space but the angle of the detector varies such that it samples light from a different location of the screen. Radiance spectra were measured using a NIST calibrated Avantes AvaSpec 2048 Single Channel spectrometer coupled to an Avantes UV–VIS 600 μm fibre (numerical aperture NA = 0.22, acceptance angle = AA = 25.4° and solid angle SA = 0.1521°).

#### Intensity-Response Relationship

The first set of visual stimuli applied to the fly were used to establish intensity-response relationships of medulla neurons. The stimulation protocol consisted of three repeated 1-s light flashes intercalated with 3 s of darkness. This motif was repeated for a range of twenty incremental intensities spanning four log units of light (from 1012 to 1015 photons/s/cm2) to establish the dynamic range of the visual response. Intensity-response relationships were probed for three different bands of the spectrum defined by the following centre wavelengths: 385 nm (UV), 440 nm (blue) and 565 nm (green). These colours were chosen with the intent to match the known spectral sensitivity peaks of the fruit fly opsins within the limitations of the system, such as the lack of UV light transmission through the projector and the restriction of most green wavelengths by the filters to prevent sampling by the GaAsP detectors.

#### Spectral Response

Next, in order to probe spectral response properties, the fly was presented with a spectral sweep of randomised light flashes of varying centre wavelengths ranging from 390 to 720 nm, all calibrated to produce the same radiance of 2.63 × 1013 photons/s/cm2. This intensity was chosen as it sits in the middle of the intensity-response range across all tested wavelengths and all tested fly genotypes. A gap in the spectral sweep was introduced spanning 490 to 656 nm and 595 to 700 for the green-emitting GCaMP and the red-emitting RGECO, respectively, to accommodate the red and green GaAsP detector sensitivities. Flashes of light were applied for 1 s with a 3-s interval between each pulse, and the entire spectral sweep was repeated five times with a different colour randomisation for each repetition. Spacing between centre wavelengths was originally set to be 5 nm increments, as specified by the voltages supplied by the monochromator software. However, an assessment of the Gaussian curve describing the band of light revealed that the peak of each curve is, in fact, not aligned with the expected centre wavelength, but shifted in either direction by a negligible amount. Nonetheless, in the interest of precision, centre wavelengths have been adjusted in graphs throughout.

#### Further visual stimulus considerations

Daily calibrations were carried out for all stimuli, and a post-calibration check was conducted to ensure precision of the stimuli. Each experiment consisted of all stimuli types and these were always presented in the following order: spectral sweep, green-, UV- and blue intensity-response stimuli. A ten-minute dark adaptation period preceded the five repetitions of the spectral sweep and preceded each presentation of the intensity-response stimulus.

### Two-photon imaging

Calcium signals in neurons of the medulla were imaged using a two-photon Bruker (Prairie Technologies) In Vivo Microscope using GFP and RFP detection channels, with a 20X water immersion objective (Zeiss, W Plan-Apochromat 20x/1.0 DIC M27; Cat # 421452-9600-000), modified with the addition of specialised optical bandpass filters (Fig. 1B and Supplementary Fig. S1). An insight DS + laser (Newport Spectra-Physics), with 920 nm infrared excitation applied to the sample. For functional imaging of calcium responses, data was acquired at a 512 × 512-pixel resolution at a rate of approximately 30 frames per second. Visual stimuli were generated in StimGL (Howard Hughes Medical Institute) and controlled via Matlab (Mathworks, MA, USA) although the psychophysics toolbox or other software could be used here instead. The start of a visual stimulus sequence was indicated to the imaging software (PrairieView) by a trigger, which subsequently initiated the acquisition of images, but also controlled the monochromator and projector. Images were acquired using the green channel (GaAsP detector 1) for flies expressing GCaMP and the red channel (GaAsP detector 2) for flies expressing RGECO. A 200X zoom (20X on the objective and 10X on the software) was used to visualise the fly medulla. This allowed imaging of all layers of the neuropil from proximal to distal across a number of cartridges (ranging from a half a dozen to a dozen in different experiments, 0.104 to 0.115 μm/pixel with a field of view of 53 to 59 μm).

### Analysis

#### Fluorescent signal extraction

Analyses were conducted using custom-made scripts in Matlab (Mathworks, MA, USA). For region of interest (ROI) selection, a reference image was used corresponding to averaged frames across the response period for a blue light pulse. Circular ROIs 12 pixels in diameter were manually positioned to tile the sections of the 512 × 512-pixel image containing the medulla that are visually distinguishable from their fluorescence (both baseline and light response). The aim of this selection process was to assess responses in a given discernible layer without assuming response uniformity across the layer. Each ROI covers a sufficient number of pixels to ensure a good response could be extracted whilst limiting noise issues that may arise in larger ROIs. Each imaging sequence from a fly medulla averaged approximately 150 ROIs that were extracted for analysis. A cross-correlation analysis56 was implemented to compensate for motion in the x–y plane resulting from physiologically driven movement of the visual neuropil (e.g. muscular displacement), vibrations resulting from equipment, or other. With this method, images across the experiment were realigned to an initial template image in order to ensure continuity of all features, and consequently continuity of ROIs from one image to another throughout the stack. A voltage recording paired to the two-photon image stack was used to segment the experiment into individual stimulus presentations. For each segment, baseline fluorescence was averaged over a pre-stimulus darkness period (5 frames prior to stimulus onset). Baseline fluorescence was averaged for each ROI over the pre-stimulus darkness period. Calcium activity was assessed by changes in fluorescence. These were calculated as the difference between average fluorescence for a given frame and the baseline fluorescence and then divided by the baseline for each ROI:

$$\Delta F=\frac{F-{F}_{0}}{{F}_{0}}$$

where ∆F is the change in fluorescence, F is the fluorescent signal and F0 is the baseline fluorescence. Extracted responses were then averaged across stimulus repeats.

#### Curve fitting parameters and data selection

∆F traces extracted for individual ROIs were averaged across repetitions of identical stimuli. In the case of data resulting from the spectral sweep, only three of the five repetitions were retained via a selection method whereby the two responses furthest from the mean of all five responses for a stimulus were removed. This methodology was introduced in an effort to reduce noise in the data. Next, a stimulus response value was calculated by integrating the response over time. The time segment for response integration was matched to the excitatory phase of the response profile observed to ensure maximal signal. In practical terms, integral values of the trace were calculated either over the one-second duration of the stimulus, over the one-second duration post stimulus or over the time course of both. Sigmoid curves were fitted to the intensity-response data using the Naka-Rushton equation classically used for electroretinogram data57:

$$\frac{V}{Vmax}=\frac{{I}^{n}}{{I}^{n}+{K}^{n}}$$

V is the response and Vmax the maximum amplitude of the response, I is the stimulus intensity, K is the intensity at the half-maximum response and n is the exponential slope measured at the half-maximum response. The curves were fitted in a two-step process. First, the intensity-response data was transformed for each stimulus intensity: $$\mathrm{log}\left[\left(\frac{Vmax}{V}\right)-1\right].$$ Then a linear regression was fitted to the transformed data to determine an initial approximation of K and n58,59. Next, the estimated K and n values were used to fit the curve with the above equation. The goodness-of-fit of the curve was evaluated by means of the mean square error value (MSE) and curves presenting MSE values superior to 0.05 were discarded. Furthermore, data was retained only if a curve could be fitted to all three intensity-response stimuli colours (UV, blue and green) within the set MSE parameter threshold.

A selection process was also applied to spectral sweep data. Spectral response curves were only retained for a given ROI if the following conditions were fulfilled: (1) all three intensity-response curves were fitted as per the above criteria and (2) the light intensity used for the spectral sweep sits at least 1/5th below the maximal value of the intensity-response curve for all three colours (to ensure saturation was not reached at any point of the spectral sweep).

### Statistics

All stages of data analysis (image analysis, curve fitting, data representation and statistical analyses) were conducted using custom scripts which used statistical packages available in Matlab (Mathworks, MA, USA). Individual statistical tests are reported in figure legends and the results of post hoc tests, original data points, mean, standard deviation, and standard error of the mean are reported throughout using notBoxPlot Matlab function (version 1.31.0.0, Rob Cambell).