Imaging the evolution of visual specializations in fungus gnats

Many insects use vision to inform their behavior, but visual information differs between habitats and the sensory demands vary with each species’ ecology. The small size of insects’ eyes constrains their optical performance, and so it is unsurprising that they have evolved specializations for optimizing the information they obtain from their habitat. Unraveling how behavioral, environmental, and phylogenetic factors influence the evolution of such specializations is difficult, however, because existing techniques to analyze insect eyes require specimens to be preserved beforehand. To facilitate broad comparative studies on insect eyes and the evolution of complex visual behavior, we developed a novel analysis technique that uses x-ray micro-computed tomography to quantify and recreate the visual world of insects. We use our methodology to investigate the eyes of fungus gnats (Orfeliini), a tribe of diminutive Dipterans, to identify the visual specializations they evolved for surviving in different forest habitats and to explore how this changed over 30 million years of evolutionary history. The specimens we studied were preserved in different ways (in ethanol, air dried, and as an endocast in amber), demonstrating that our method provides a new opportunity to quantitatively study and compare the vision of a wide range insects held in museum collections. Our analysis indicates that different visual specializations have evolved between fungus gnat species living in different forest types and that the eyes of gnats from a similar geographic location have evolved to match the changing environmental conditions. Despite the small size of fungus gnats, evolution has evidentially been able to exploit sensory specializations to meet the differing sensory demands of species from a variety of forest habitats. Significance statement Do insects have visual specializations that evolve with changes in their environment? To answer this question, a novel analysis technique is described that uses 3D imaging and simulations to compare the vision of ancient amber-embedded insects to those of their extant relatives. This study investigated the vision of fungus gnats to understand how tiny insects use vision to negotiate forests, some of the world’s most visually complex environments. Despite being amongst the smallest of any flying insect, the gnats’ miniature eyes have evolved visual specializations specifically adapted for different forest types, allowing different species to meet their visual demands of their specific habitats.

Many insects use vision to inform their behavior, but visual information differs between habitats and the sensory demands vary with each species' ecology. The small size of insects' eyes constrains their optical performance, and so it is unsurprising that they have evolved specializations for optimizing the information they obtain from their habitat. Unraveling how behavioral, environmental, and phylogenetic factors influence the evolution of such specializations is difficult, however, because existing techniques to analyze insect eyes require specimens to be preserved beforehand. To facilitate broad comparative studies on insect eyes and the evolution of complex visual behavior, we developed a novel analysis technique that uses x-ray micro-computed tomography to quantify and recreate the visual world of insects. We use our methodology to investigate the eyes of fungus gnats (Orfeliini), a tribe of diminutive Dipterans, to identify the visual specializations they evolved for surviving in different forest habitats and to explore how this changed over 30 million years of evolutionary history. The specimens we studied were preserved in different ways (in ethanol, air dried, and as an endocast in amber), demonstrating that our method provides a new opportunity to quantitatively study and compare the vision of a wide range insects held in museum collections. Our analysis indicates that different visual specializations have evolved between fungus gnat species living in different forest types and that the eyes of gnats from a similar geographic location have evolved to match the changing environmental conditions. Despite the small size of fungus gnats, evolution has evidentially been able to exploit sensory specializations to meet the differing sensory demands of species from a variety of forest habitats.
Significance statement: Do insects have visual specializations that evolve with changes in their environment? To answer this question, a novel analysis technique is described that uses 3D imaging and simulations to compare the vision of ancient amber-embedded insects to those of their extant relatives. This study investigated the vision of fungus gnats to understand how tiny insects use vision to negotiate forests, some of the world's most visually complex environments. Despite being amongst the smallest of any flying insect, the gnats' miniature eyes have evolved visual specializations specifically adapted for different forest types, allowing different species to meet their visual demands of their specific habitats.
Introduction: Vision provides essential information to meet the sensory demands of flying insects and is utilized to orchestrate both movement through, and interactions with, their environment (1). To fly safely and efficiently and to avoid collisions with obstacles, an insect must control its speed and orientation. To forage successfully, it must locate and recognize food objects from the wing, before safely approaching and landing upon them. The visual requirements of both sets of tasks depend upon the complexity and illumination of the environment -flying through a dim, cluttered forest would pose radically different challenges than flying over a bright, open meadow, for example (2). To meet the sensory demands of flight, insect eyes have evolved morphological specializations that fine-tune resolution and sensitivity across their visual field (3). As the range and type of information available varies between different visual habitats, it is likely that these specializations are also adapted to the specific niche of each insect.
Astonishingly, even some of the tiniest insects are capable of inhabiting some of the most visually complex habitats. One of the most fascinating examples are the fungus gnats, who are amongst the smallest Dipterans, with eyes that comprise just a few hundred lenses and brains the size of a grain of salt. These marvels of nature inhabit a broad range of forest types, from the arctic to the tropics (4), the latter being one of the most visually challenging environments on earth. The frequent occurrence of fungus gnats in amber shows they have thrived for at least 50 million years (5) and for the continued evolutionary success of these creatures, each species must have remained capable of acquiring the visual information necessary to control flight through its particular habitat. Yet, the fungus gnat's miniature eyes would likely constrain them to evolving only the most fundamental visual specializations and due to the differences between the forests that gnats are capable of inhabiting, one set of specializations is unlikely to be optimal for all visual environments. Hence, we speculated whether gnats evolve different visual specializations depending on their specific visual habitat and if so, what were they? The aim of this study is to answer this question, not only to understand how the visual systems of flying insects are adapted to their environments, but also to gain key insights into the fundamental sensory requirements for guiding flight in complex environments.
To identify whether fungus gnats have visual specializations that are linked to specific habitats, it is important to make comparisons between related species, as this minimizes variations that might be caused by other factors such as differences in phylogenetic history and behavioral ecology. To understand how these adaptations evolved over time, it is also important to examine visual specializations in related species from a similar geographical location at different points in time. We focus our study on three species from the Orfeliini tribe, an extant fungus gnat that inhabits the tropical forests of Africa (Rutylapa sp.), and both an ancient (Orfeliini sp.; ~30 million years old, Fig. S1) and extant species from Scandinavia (Neoplatyura modesta). While both Scandinavian gnats are from a similar geographic location, they represent species from different habitat types, as the Baltic region has cooled substantially in the last 30 million years, with dense tropical forests having been replaced by sparser, temperate woodland (6). If gnat eyes do indeed evolve habitat-specific specializations, then we hypothesize that the visual properties of the two tropical gnat species will be similar, despite the geographic distance between their distributions. Specifically, given that tropical forests are relatively dark due to their dense canopies, we expect that tropical gnats could have specializations that improve their sensitivity and that these may not be possessed by gnats that inhabit brighter temperate forests.
Current methods for describing the visual specializations of compound eyes are not suitable for our study for two main reasons. Firstly, they can only be performed on readily-available, extant insects because they rely on preserving fresh tissue (7) and, secondly, because they provide only a 2D representation of the eye and thus limit our ability to understand how it viewed its 3D environment (8). To perform our investigation, it was therefore necessary to develop a method that would enable us to quantify and recreate the visual world of naturally preserved insects. Our method uses x-ray microtomography to create 3D models of insect eyes (9). The compound eyes of fungus gnats, like those of other invertebrates, are composed of many facets, also known as ommatidial units, that comprise a corneal lens, a crystalline cone and an underlying group of photoreceptors (10). Using the shape of the cornea in our 3D models, we extract information about the local resolution and sensitivity across the eye, as well as the full extent of its visual field. The measured data can be displayed in world-based coordinates, which is crucial to facilitate direct comparisons between the vision of eyes that have different morphologies or sizes. Because our method is non-destructive and is based only on the corneal structure, we could perform it on insects that were preserved in entomological collections or fossilized as amber inclusions. Thus, it facilitated our investigation into the factors that drive and shape the visual evolution of fungus gnats.

Results
Our novel analysis technique uses x-ray microtomography to image the 3D structure of the head and eyes (Fig. 1Ai, ii). We then calculate the visual properties of the eyes from the structure, shape and size of the individual corneal lenses (Fig. 1Aiii-v). The corneal lenses provide details about the limits of sensitivity and resolution in a particular region of the eye, as well as enabling us to determine the full extent of the visual field. The diameter (D) of the lenses indicates the amount of light that is focused onto the underlying photoreceptors. Larger lens diameters capture greater amounts of light and therefore increase ommatidial sensitivity (3). Each lens also focuses light from a specific region of space, or viewing direction, that is centered about its optical axis. The smaller the angle between the optical axes of adjacent lenses (the inter-ommatidial angle, ΔΦ), the greater the visual resolution in that part of the visual field (3). By analyzing the distribution of lenses across the compound eye in 3D, we can determine the optical axis each corneal lens and the entire eye's field of view (Fig. 1Avi, vii), as well as the associated lens diameter and inter-ommatidial angle (Fig. 1Aviii). Our analysis procedure is described in detail in the 'Methods' and 'Supplemental methods' sections. To investigate whether and how the visual systems of fungus gnats have changed both across habitat type and across time, we applied our technique to three species (Orfeliini sp. -ancient, tropical, Fig. 1Bi; Rutylapa sp. -extant, tropical, Fig. 1Bii; N. modesta -extant, temperate, Fig. 1Biii). The exterior corneal surfaces reconstructed from microtomography showed that, superficially, the ancient gnat appears most similar to the extant temperate species (Fig. 1B). While the head and eye size of the ancient gnat was between those of the two extant gnats (Table 1), the ancient gnat had both larger lens diameters (Fig. 2D) and inter-ommatidial angles (Fig. 2E), and also a larger field of view than either extant species (Table 1). Interestingly, all species have a part of the visual field viewed by both eyes -a binocular overlap -and this is directed ventrally and frontally ( Fig. 2A-C). The extant temperate gnat has the largest binocular overlap despite having the smallest total visual field. The temperate gnat's entire visual field was also directed more ventrally than either of the tropical specimens (Fig. 2C, Table S1), while its lens diameters were generally smaller than those of either tropical species (Fig. 2D, Table 1). However, the relative distributions of inter-ommatidial angles were more similar between the extant gnats, while we calculated that the ancient gnat generally had slightly larger inter-ommatidial angles (Fig. 2E).
Despite the gnats' small eyes, it is evident that they also possess regional visual specializations. For example, the inter-ommatidial angles vary across the visual field of all gnats. The lowest inter-ommatidial angles (indicating higher resolution) are directed laterally and view their monocular visual field (Fig 2A-C:ii). Furthermore, a ventral to dorsal reduction in lens diameter is visible across the visual fields of both tropical specimens ( Fig. 2A,B:i), but this is not apparent on the temperate gnat's eye ( Fig. 2C:i). A simulation taking into account the spatial sampling of both eyes on each gnat indicates that all three should obtain coarse, but distinct, spatial information from the features in a forest scene (Fig. 3). Table 1: Summary of parameters related to each fungus gnat specimen. Field of view (FOV) is indicated as a percentage of the visual sphere viewed. The mean ± one standard deviation is provided for the lens diameter and inter-ommatidial angle, followed by the measured minima and maxima values in parenthesis.

Discussion
Vision is essential for guiding many insect behaviors, but we know little about the intrinsic and extrinsic factors driving the evolution of visual systems and their adaptation to specific visual environments. This knowledge gap is partly due to the limitations of current methodologies for quantifying eye specializations, which can only be applied to freshly preserved tissue, thereby excluding investigations of rare, naturally preserved or ancient specimens (7). To overcome this, we have developed a new method for exploring the visual world of invertebrates using non-destructive microtomographic methods ( Fig.  1Ai) that can be applied equally well to fresh, dried, or even fossilized specimens. We used this method to quantify the vision of fungus gnats' tiny eyes, and we will now explore how these relate to the adaptations they have evolved in a broad range of visual environments. While not readily apparent from their external morphology, our analysis of their vision reveals that different gnat species do indeed appear to have evolved visual specializations that would optimize their eyes for vision in their specific habitats.
The fungus gnats we investigated belong to the tribe Orfeliini, a cosmopolitan group of Dipterans with species that inhabit forest environments from the arctic to the tropics. Despite their differences in age and habitat, we identified two visual specializations common to all three of the Orfeliini species investigated. The first is that their highest resolution vision is directed laterally ( Fig. 2A-C:i). This is in contrast to larger Dipterans (including Drosophila), whose highest resolution is directed frontally (11)(12)(13). Further comparative anatomical and behavioral investigations would be necessary to understand why fungus gnats require this lateral region of high resolution vision. The second specialization common to the species investigated here is that they have a large binocular visual field that is directed ventrally and somewhat frontally (Fig. 3). Interestingly, when the extent of binocular visual field has previously been measured in larger female flying insects (14)(15)(16), it has been found to span a substantially smaller angular area (<10% of the visual world), while we find that the gnats' binocular visual fields covers from 15 to 27% (Table 1). Additionally, the binocular region of these larger species is approximately ventrally-todorsally symmetric, unlike the primarily ventral binocularity of fungus gnats. We propose that ventral binocularity is a previously unconsidered adaption for small, forest-dwelling insects to improve their optical sensitivity to the visual features beneath them. A large ventral binocular overlap could be used to improve sensitivity by averaging the noisy signal in this part of the visual field between both eyes. This adaptation that would be beneficial in a forest environment because objects on the ground are likely to be shadowed and difficult for small eyes to detect.
In addition to revealing commonalities in the visual systems of the different fungus gnats, our method also revealed that they have distinct differences, which appear to be habitat-specific specializations. We find that both the extant and ancient tropical gnat species have a larger, more dorsally-directed total visual field than the temperate gnat ( Fig. 3B,C). The visual systems of other tropical insects also have prominent dorsal visual fields (17), suggesting that extending the dorsal visual field is a common visual specialization for the densest forests where the sky can be completely occluded by the thick canopy (18). Another difference between the tropical and temperate species is that the lens diameters of the tropical species are larger (Fig. 2D), indicating increased sensitivity. However, while the lens diameters remain relatively constant across the temperate gnat's eyes, the lens diameters in the tropical gnats have a clear negative relationship to elevation, as their ventral lenses are larger than those facing dorsally ( Fig. 2A,B:i). These larger ventral lenses are a regional visual specialization that would improve optical sensitivity of the ommatidia viewing the forest floor. An analogous increase in eye 'regionalization' is also found among extant damselfly species that live in dark or visually complex habitats (19). In combination with the ventral binocular overlap, this ventral region of high sensitivity in the tropical gnats suggests that the ground is an important, but dimly illuminated, source of visual information for these insects. Taken together, our findings support our initial prediction that the tropical gnat species do indeed have additional specializations that increase sensitivity and that would facilitate visually-guided behaviors in denser forests compared to their temperate relatives.
The results of this study provide important insights into the visual specializations of insects from different times and environments and demonstrates that our method is particularly valuable for investigations into the visual systems of rare or extinct species in various states of preservation. While we do find evidence to support our hypothesis that fungus gnats have developed habitat-specific visual specializations, we acknowledge that our small sample size limits the strength of our conclusions. Larger sample sizes, from a broader range of species, would be required for more in-depth analyses of the factors that influence the evolution of visual systems and how they become specialized for different habitats. A distinct advantage of our method is that it facilitates direct comparisons between species. This is because, unlike existing approaches, it enables the visual properties of each insect to be presented in a common, world-based coordinate frame, even if there are substantial differences between the visual morphology or the size of the eyes. Additionally, the ability of this technique to simulate vision through an insect's eyes provides insights into how it views a particular scene (Fig. 3), which is a valuable tool for developing hypotheses about visual adaptations that can then be directly tested with behavioral experiments. For instance, despite being weak fliers, fungus gnats are effective pollinators (20). Is it possible that the eyes of tropical species allow them to find flowers more easily in a rainforest than the eyes of temperate species would? Additionally, the larvae of many fungus gnat species are greenhouse pests (21), and the sensitive phototaxis of adult gnats has led to the suggestion that light trapping could be used as an effective management strategy (22). In this context, a key question could be if the gnat's optical sensitivity varies across the visual field, does the effectiveness of such traps depend on the elevation they are placed at? Knowledge of a gnat's visual capabilities and simulating its vision undoubtedly provide a crucial starting point for designing behavioral assays to conclusively answer such questions, which are of both ecological and economic importance.
Unlike the soft-tissue of vertebrate eyes, the cuticular corneas of insect eyes can remain exceptionally preserved in amber dating back to the Early Cretaceous (23) and we expect that there are many further opportunities to use our methodology to study the circumstances through which specific visual traits evolved in other taxa. For example, nocturnal bees have developed enlarged frontal lenses that would assist them in locating food and nest sites in dim light, enabling them to compensate for the limitations imposed by their apposition compound eyes that are otherwise poorly suited to dim-light vision (24). The evolutionary origin of these specializations that have enabled nocturnality in an otherwise diurnal insect taxon are speculative, but investigations from the fossil record may help to clarify when and where these enlarged frontal lenses evolved. Likewise, prominent acute zones with regions of flattened and enlarged lenses have evolved to accompany pursuit behavior in many insect species. Identification of such regional specializations in the fossil record could be used to investigate the evolutionary origins of pursuit mating strategies in male bees (25) or of the predatory behavior of miniature female flies (26). Exceptionally preserved amber inclusions are occasionally discovered with their fine retinal structure is intact (27). As similar structures can be identified in our alcohol-preserved sample (Fig. S2), they are also likely to be visible in microtomographic volumes of such well-preserved specimens and could provide more detailed insights into the visual systems of ancient insects. Furthermore, microtomographic images are already used to describe the morphology of insect inclusions in amber for taxonomic purposes (28,29), and systematics could proceed in tandem with analysis of a specimen's visual system.
Applying our methodology to the substantial range of dried specimens collected over the last two centuries (30) would also facilitate investigations into the influence of recent anthropogenic disruptions on the evolution of invertebrate visual systems. For instance, replacing forested areas with agricultural landscapes results in sparser visual habitats that would likely favor certain visual specializations. Species that do not adapt to such disruptions in their visual habitat may be more vulnerable to these changes (31, 32). Our methodology makes it possible to examine whether the increase in light pollution over the last century has placed selective pressure on the eyes of nocturnal urban insects (33,34). Testing these, and many other, hypotheses related to the factors driving sensory evolution will be possible by applying this technique to analyze the well-preserved compound eyes of the specimens already available in museum collections.

Materials and methods Animals
In this study, we obtained samples of female fungus gnats from three species. Each specimen was preserved in a different way -dried, in alcohol or as an amber endocast (Table S1). The Entomology Collection at the Department of Biology, Lund University provided dried and pinned samples of Neoplatyura modesta, the Natural History Museum at the University of Oslo provided samples of Rutylapa sp. preserved in ethanol, while the Department of Geology at Lund University provided a piece of amber containing inclusions of Orfeliini sp. (Fig. S1). The smallest individuals with intact eyes (as observed with a light microscope) were chosen from the museum collections for microtomographic analysis.

Microtomography
Microtomography was performed on the head of each sample using a Zeiss XRM520 at the 4D Imaging Lab at Lund University. For each data set, x-ray projections were obtained over 360 o (the specific scanning parameters for each sample are listed in Table S2) and reconstructed into 3D volumes with 1μm isotropic resolution. A different method was used to mount each sample in the tomograph, as outlined below.
• The pin of the dried sample was clamped in a pin-vice and mounted directly in the tomograph and was oriented such the pin did not occlude the projection of the gnat head on the detector. • The alcohol-preserved sample was placed at the bottom of a 0.5 mL microcentrifuge tube (Eppendorf) and partially covered with a small amount of 70% ethanol (the surface tension of the liquid held the gnat in place). A ball of Parafilm was then used to fill the remaining volume of the tube and prevent evaporation of the ethanol. The original microcentrifuge tube was placed partially within a larger 2 mL tube and secured with Parafilm, and the later was clamped in a pinvice and mounted in the tomograph. • The amber block was hot-glued to a 'drawing pin' that was clamped in a pin-vice and mounted in the tomograph. A lower resolution scan was initially conducted on the block to identify the location of several inclusions, with the head of one selected for the 1μm resolution scans.

Analysis procedure
After performing microtomography to identify the lenses of the compound eye (Fig. 1Ai), a digital representation of the entire head surface was computed (Fig. 1Aii) in Amira (FEI). The border of the left eye (Fig. 1Aiii) and each of its lenses (Fig. 1Aiv) was then manually labeled by selecting paths across the surface. This isolated the surface of every individual lens in the left eye. The right eye was represented by mirroring the lens surfaces of the left eye (Fig. 1Av, for additional information see 'Detailed surface analysis procedure' in the Supplemental methods). The optical axis of each lens (Fig.1Avi) and its viewing direction relative to the head (Fig.1Avii) were calculated from the surfaces after importing them into Matlab (Mathworks). The limits of the visual field of each eye were calculated from the optical axes of their outermost lenses. The complete visual field and binocular overlap was determined by combining the limits of both eyes (Fig. 1Avii). Lens diameters were calculated by finding the average distances between the center of each facet and its neighbors (Fig. 1Aviii) and inter-ommatidial angles were calculated by finding the average angle between the optical axis of a facet and its neighbors (Fig. 1Aviii) (3). Diagrams of how lens diameter and inter-ommatidial angle vary over the visual field were generated from the visual axes and properties calculated for each gnat. A voronoi diagram was drawn around the visual axes of each eye, and the cells were colored according to the local lens diameter ( Fig. 2A-C:i) or inter-ommatidial angle ( Fig. 2A-C:ii), which could also be depicted by coloring the individual lenses of the compound eye ( Fig.  2A-C insets). A simulation of how each gnat may have viewed a forest scene was generated from an arbitrarily chosen panoramic forest image. We assumed that each lens accepted light over an angle equal to its inter-ommatidial angle, and then colored the voronoi cells based on the weighted average of the intensity value of the pixels that lay within this angular range (Fig. 3, see the 'Detailed computational analysis procedure' in the Supplemental methods for additional information). Note that this simulation does not take into account the variation in optical sensitivity that would be caused by differences in lens diameter and acceptance angles (35).

Supplemental information Supplemental methods
Detailed surface analysis procedure Each 3D microtomography image was imported into Amira (v6.2, FEI). This software was used to develop an interactive workflow that allowed us to create a surface defining the head of the scanned insect, and then to delineate the border of the left eye and each corneal lens on it. After labeling the lenses, these data were mirrored to the right eye, and the surface data and mirror transform were then exported to Matlab for further computational analysis (see the following section). In the following descriptions, windows within the Amira console are indicated in italics, Editor windows (accessible from the Properties View of a given module) are indicated by underlining, and further modules, tools, and options are indicated in 'parenthesis'.
The head surface was created by firstly labelling the voxels within the head volume, and then fitting a surface around their border, as described in the following. The 'Threshold' tool in the Segmentation View was used to select and label the voxels that were part of the gnat (which were lower intensity than the surrounding material for the amber-embedded specimen, but higher in the other two cases). The '3D Lasso' tool was then used to select and remove excess labeled material, such that only the fungus gnat's head capsule remained labeled. Following this, a surface was created around the labels using the 'Generate Surface' (a 'smoothing extent' of 2 was used when generating the surface) and 'View Surface' modules in the Project View. Sometimes the surface created for the eyes appeared to be poorly formed, particularly for the amber-embedded and alcohol-preserved samples. In the former case, this was because decayed material from the gnat coated the inside of the endocast, and often had higher absorption than the amber. In the alcohol-preserved case, it was because of relatively low absorption contrast between the cuticle and the alcohol. In both cases, the 'Brush' tool was used to manually correct the label field of 2D slices in the Segmentation Editor, to ensure that individual lens surfaces of the left eye appeared smooth in the generated surface and, additionally, that the surface of the eye was closed, with no gaps present between lenses. The scan of the dried gnat had high contrast between the cuticle and air, and the initial surface that was generated did not require such corrections.
After completing any required corrections, a final surface was created and a 'Create Surface Geodesic Path' module was attached to it (all remaining steps are performed in the Project View). In the Surface Path Editor, the connector was set to 'dijkstra', and the control points to 'vertex'. The Surface Path Editor allows points to be selected around the border of the left compound eye, which were linked by paths taking the shortest route across the surface between sequential points. To isolate this area from the remainder of the surface, after closing the path around the eye, the 'Patchify Surface' was selected. The Surface Editor was then used to selectively display only the compound eye patch, after which the 'Extract Surface' module was used to create a new surface only including the compound eye. A second 'Create Surface Geodesic Path' module was then attached to the isolated corneal surface and paths were traced in a circle around the base of every lens on the compound eye. Approximately 60 control points were placed per lens and closing a path upon completion allowed a new path to be started for the next lens. Note that each fungus gnat lens has a dome shaped cornea; many other insects have flatter, hexagonal lenses and placing a control point at each of the six corner points of a lens would probably be sufficient in such cases. The right eyes of gnats were not individually segmented, but we counted the number of lenses by using another geodesic path to place control points at the center of each facet. This indicated that the gnat eyes were approximately symmetrical, with at most a 2.4% difference in facet number between the eyes (Table S1).
Each head surface was then aligned using the Transform Editor, by positioning and aligning it such that it faced forwards in the default XY image in the Project view. The head was aligned in its frontal (yaw) and axial (roll) planes based on its symmetry. The pitch (sagittal plane) of the head could not be aligned by symmetry but was positioned such that each head appeared to have a similar orientation (inset heads in Fig. 2A-C). After aligning the head, the resulting rigid transformation matrix was copied to both the isolated eye surface and the paths around each facet. While the right eye was not separately labeled, we determined the transformation required to mirror the labelled left eye such that it was aligned with the position of the right eye. To mirror the left eye, we used the 'Scan surface to volume' module on the left eye surface to create a volume in which the voxels corresponding to the surface were labeled. The 'Resample transformed image' module was then applied to this volume, which created a second volume, the axes of which were orthogonal to the world coordinate frame. This volume could then be mirrored around the sagittal plane of the head by using the 'Flip X' button in the Crop Editor, and a 'Volume rendering' module was used to visualize the position of the mirrored eye. Finally, the Transform Editor was used to adjust the alignment of the mirrored right eye such that it matched the actual right eye on the surface of the head as closely as possible.
After completing the above-described processing workflow in Amira, it was necessary to export data for use in Matlab. Both the head surface and eye surface were exported as 'stl' files in little endian format.
The paths surrounding each facet were exported as 'Amira lineset' files in asci format. To facilitate importing paths into Matlab, it was necessary to split the lineset file into two parts using a text editing program. Each file contains data under two headings; @1 is a list of indices indicating the vertices to use for each control point in an individual path (-1 indicates that start of a new path), @2 is a list of 3D vertices coordinates referenced by the indices. It is necessary to copy the indices and vertices into individual text files. Finally, the 4x4 transform matrices for the head and the right eye were recorded by using the 'GetTransform' command in the TCL Console, and the 'Max index' and the 'Min coord' values of the right eye volume were recorded from Crop Editor.
Upon acceptance of this manuscript: We will submit the original volumes and head surfaces from each sample to the MorphoSource depository and include their DOIs in the manuscript. We will also submit an example Amira project showing the result of the complete workflow described above as Supplementary Material.

Detail computational analysis procedure
The data exported by Amira was imported into Matlab and analyzed using a series of custom written scripts to quantify the visual properties of gnat eyes and perform a visual simulation. The analysis procedure involves applying the rigid transformations to the imported surfaces and identifying the lens surfaces from the path points. The corneal optical axis from each lens was calculated, from which the eye's visual parameters and fields of view were quantified. Various plotting options were implemented for the data, including performing a visual simulation of the insect's perspective of a scene. This analysis was mostly automated, and here we describe the analysis steps performed by the script. Variable names that the user may wish to modify are indicated in 'parenthesis', and influence data importing and various display options as outlined in the initial 'Configuration' section of the attached 'AnalyseCorneaMain.m' file.
Data were initially imported into Matlab based on the user specified files in the initial portion of the 'Configuration' section. The appropriate transformations were applied to the surfaces such that they were represented in the same orientation as seen in Amira. The paths were initially formatted as a single list of points, but we separated this into an individual list of vertices for each lens' border. After this, the coordinates on the eye surface enclosed by each border path were selected as the corneal surface for that facet. The central point on each lens' cornea was determined, and then the normal vector of the corneal surface was calculated from this point. This calculation involved fitting a second order polynomial surface to the corneal surface vertices, and calculating the normal direction from the derivative at the central point (17). The normal vector was taken to indicate the optical axis of the lens. The same procedure was performed for the mirrored right eye.
The neighbors of each lens were determined based on the shortest distances between its center and those of each other lens (each lens was linked to six neighbors, unless it was on the border of the eye). Having established the neighbors of each lens, the inter-ommatidial angle (ΔΦ) of a given lens was calculated as the average angle between its optical axis and those of its neighbors and the lens diameter (D) was calculated as the average distance from its center point to those of its neighbors. Additionally, the eye parameter (P), was calculated by multiplying each lens' inter-ommatidial angle by its diameter (36). It was not possible for us to calculate the acceptance angle over which individual lenses absorbed light, hence we assumed that this was equal to the local inter-ommatidial angle of each lens. It is possible to perform a local smoothing operation on the data, whereby the optical axes and diameters of each lens are averaged with those of their neighbors. Smoothing may be useful if the visual parameters of an eye vary irregularly and can be adjusted using the 'smoothingFactor' variable.
To determine the fields of view (FOV) of each eye, we first calculated the intersection of each optical axis on a distant sphere. We then discretized the sphere into many equally spaced points and determined which of those points lay within a boundary enclosing the optical axis intersections. The points within the FOV were determined in this manner for each eye individually. The union of these two sets of points provided the total FOV, while the intersection indicated the portion of the FOV with binocular overlap. The borders around each region were also calculated for use in the later plotting steps; note that if multiple individual regions are present within a given field of view (such as in the binocular visual field, Fig. 2A), the border calculation may take a long time to compute. The visual sphere was also divided into individual regions for each lens. This was calculated either for the lenses of the left eye only (Fig. 2) or both eyes (Fig. 3) by calculating the borders of the voronoi cells (on the surface of the sphere) around the sphere intersection points of the lenses. Although the voronoi cells covered the entire sphere, those on the borders were limited to the extent of the previously calculated field of view.
Different methods were implemented to plot the data resulting from the previous analysis. The individual optical axes and fields of view were drawn onto a sphere surrounding a visualization of the head surface (Fig. S3A). The values of each calculated parameter (ΔΦ, D, P) were encoded using a color map, and displayed either as a world-based representation by coloring the voronoi cells of the left eye ( Fig. 2A-C), or as a head-based representation by coloring the corneal lenses on the eye surface ( Fig. 2A-C insets). While the voronoi cells were calculated on a sphere, we displayed them as 2D maps using an equirectangular projection, onto which either the binocular FOV or the right eye FOV could be displayed using the 'plotBinoLine' and the 'plotRightEyeLine' variables, respectively. It was also possible to draw contour lines of one parameter upon the map of another (for example contours of D on a map of ΔΦ using the 'dispContourOnInterOImage' variable, Fig. S3B). Lenses viewing the binocular visual field could also be indicated with markers on the head centric representation (using the 'binoMarkerSize' variable). All plots could be saved automatically by setting the 'saveImages' flag.
To display color maps, the observed range of each calculated parameter was discretized into a number of equally spaced bins (set with 'numColBins' variable). By default, this discretization is performed for each insect, and different insect eyes had different ranges and receive different color mappings. To compare between multiple insects, 'AnalyseCorneaMain.m' should first be run for each insect with the 'saveData' flag set. This will save the calculated parameters for each insect analyzed and the 'PlotGroupHistograms.m' file (which requires similar variables to be set as in the main analysis file) was used to produce overlaid histograms for the parameters, and to compute the mean, standard deviation, and range of each parameter for each insect. The latter file also determined the total ranges of each calculated parameter between all data sets and used them to compute the appropriate discretization for all insects. In the original file, the 'useGroupColBins' flag was then set, and re-running the main analysis file created plots with equivalent color mappings between each individual.
A simulation of an insect's vision of a user-supplied panoramic image (Fig. 3) or a checkered sphere (Fig.  S3D) could also be computed (choose by setting the 'simUserIm' flag). When using the checkered sphere, the number of checks was set using the 'numChequers' variable, note that a higher number of checks results in a lower wavelength and higher spatial frequency, and that checks are mapped onto equirectangular image and do not represent equal angular areas on the world sphere (Fig. S3C). The simulation was performed using a direct grey scale conversion from the image provided -no knowledge of the spectral sensitivity of the simulated insect was included. The world coordinates were determined for each pixel of the image being used, and we simulated the insect's position at the center of the world sphere. For each lens, we averaged the intensity of all points that lay less than one acceptance angle from its corneal axis and weighted this average by a Gaussian kernel with full width at half maximum (FWHM) equal to the acceptance angle of each facet. We then shaded the facet's voronoi cell with the averaged grayscale value, and the simulation could either be performed for the left eye only or for both eyes by setting the 'simBothEyes' variable. The shaded cells were plotted on an equirecetangular image in a similar manner to the color maps described above, and the border of the fields of view could also be displayed.
Supplemental Tables  Table S1: Summary of additional parameters related to each fungus gnat specimen. The mean ± one standard deviation is provided for the eye parameter, followed by the measured minima and maxima values in parenthesis. Visual field extents are also provided as the minima and maxima angular limits of the total azimuthal range (at 0° elevation) and the total elevation range (at 0° azimuth), followed by the total angular extent in parenthesis (the visual field behind the head is indicated with values from -90° to -270° in the elevation range).   Figure S1: Habitus image created from the endocast of the female Eocene gnat specimen. Unfortunately, the degradation of the wings limited a full species identification of the sample, but the general morphological features place it in the tribe Orfeliini of the family Keroplatidae in the order Diptera.