Mecha Research · Research / Medical Imaging

We Taught a Fly to Read X-Rays

Training a connectome-constrained network to classify pleural effusion on chest X-rays using sparse retinal inputs.

Skip interactive viewer
Interactive viewer
Interactive radFly

Explore the fly workstation and connectome.

Open standalone viewer ↗
Recorded validation examples · checkpoint 225. Fly gestures are illustrative.Open full viewer

Executive summary

We trained a biological neural network built around a fruit fly’s wiring diagram to detect pleural effusion on chest X-rays, achieving 82% validation AUROC.

Introduction

In September 2026, researchers from HHMI Janelia, the University of Cambridge, the MRC Laboratory of Molecular Biology and Google Research published the MaleCNS connectome: a reconstruction of the adult male Drosophila melanogaster brain and ventral nerve cord containing more than 166,000 neurons [1, 2].

A connectome is a wiring diagram that tells us which reconstructed neurons connect to which others, how many synaptic contacts contribute to those connections, and properties such as predicted neurotransmitter identity.

We asked whether a network constrained by that wiring could learn to classify pleural effusion on chest X-rays. An image is sampled directly at R1–R6 photoreceptors, propagated through the complete MaleCNS graph, and classified from the resulting neural state. There is no learned image encoder before the connectome.

Visual input

Image preprocessing

We used frontal MIMIC-CXR radiographs [3, 4] with pleural effusion labels extracted from reports by CheXbert [5]. Each 512 × 512 image is converted to grayscale, resized without cropping, and padded to 224 × 224. For the prepared 8-bit pixel array PP, intensity II at row yy and column xx is

I[y,x]=P[y,x]255,I[0,1]224×224.I[y,x]=\frac{P[y,x]}{255},\qquad I\in[0,1]^{224\times224}.

These display intensities enter the model directly, without contrast equalization or a learned image encoder.

Retinal mapping

Of 3,377 annotated R1–R6 photoreceptors, 3,335 receive image coordinates; the other 42 remain in the graph without direct image input.

To locate receptor rr, we sum its contacts onto same-eye L1, L2 and L3 neurons by optic-lobe column cc. Let CjiC_{ji} count contacts from source neuron ii to target neuron jj. The assigned column is

cr=argmaxcj{L1,L2,L3}c,same eyeCjr.c_r=\arg\max_c\sum_{j\in\{\mathrm{L1,L2,L3}\}_{c,\,\mathrm{same\ eye}}} C_{jr}.

Ties are resolved by axial-coordinate order. The column's hexagonal coordinates (h1,h2)(h_1,h_2) become planar coordinates (x,y)(x,y):

x=h1h22,y=32h2.x=h_1-\frac{h_2}{2},\qquad y=\frac{\sqrt{3}}{2}h_2.

Using the minimum and maximum mapped coordinates within each eye, we normalize to (xn,yn)(x_n,y_n):

xn=xxminxmaxxmin,yn=yyminymaxymin.x_n=\frac{x-x_{\min}}{x_{\max}-x_{\min}},\qquad y_n=\frac{y-y_{\min}}{y_{\max}-y_{\min}}.

Values are bounded to [0,1][0,1]. The eyes occupy overlapping image viewports, with horizontal coordinate uu and vertical coordinate vv:

u={0.6xn,left eye,10.6xn,right eye,v=1yn.u=\begin{cases}0.6x_n,&\text{left eye},\\1-0.6x_n,&\text{right eye},\end{cases} \qquad v=1-y_n.

This inferred projection is not necessarily a calibrated model of fly optics. The 3,335 receptors occupy 824 distinct image positions (ur,vr)(u_r,v_r).

Photoreceptor sampling

Bilinear interpolation gives each receptor one intensity. On the 224 × 224 canvas, its pixel coordinates are

xr=223ur,yr=223vr.x_r=223u_r,\qquad y_r=223v_r.

Let x0=xrx_0=\lfloor x_r\rfloor and y0=yry_0=\lfloor y_r\rfloor be the lower integer coordinates, with fractional offsets δx=xrx0\delta_x=x_r-x_0 and δy=yry0\delta_y=y_r-y_0. The sampled value srs_r is

sr=(1δx)(1δy)I[y0,x0]+δx(1δy)I[y0,x0+1]+(1δx)δyI[y0+1,x0]+δxδyI[y0+1,x0+1].\begin{aligned} s_r={}&(1-\delta_x)(1-\delta_y)I[y_0,x_0]\\ &+\delta_x(1-\delta_y)I[y_0,x_0+1]\\ &+(1-\delta_x)\delta_y I[y_0+1,x_0]\\ &+\delta_x\delta_y I[y_0+1,x_0+1]. \end{aligned}

The weights sum to one; some vanish at integer or boundary coordinates. Equivalently, 2(ur,vr)12(u_r,v_r)-1 expresses the sampling position on a [1,1][-1,1] coordinate system. Receptors at the same position receive the same value; there is no scanning or additional pooling.

Let ρ(r)\rho(r) identify receptor rr in the graph. The input vector dd places each sample at its corresponding neuron:

dρ(r)=sr,dj=0 for every other graph entry.d_{\rho(r)}=s_r,\qquad d_j=0\ \text{for every other graph entry}.

The dimensionless drive has gain 1 and stays constant through all twenty updates for an image. Neural state resets to zero for the next image.

Prepared radiograph224 × 224 pixels
Prepared frontal chest radiograph.
Photoreceptor samples3,335 receptors · 824 positions
Sampled radiograph intensities at retinal input positions; pink marks pixels without direct receptor input.

Figure 1. Photoreceptor sampling. Prepared radiograph and sampled intensities at their image locations; pink marks pixels that do not directly affect any receptor. This depicts the input mapping, not reconstructed or subjective fly vision. The demonstration image is by Mikael Häggström, CC0. It is not a MIMIC patient image.

Connectome model

Anatomical connectivity

The network contains N=166,700N=166{,}700 neurons and 25,582,938 directed neuron-pair edges. Its fixed anatomical matrix is

Wji0=Cjiηimax(1,kCjk).W^0_{ji}=\frac{C_{ji}\,\eta_i}{\max\left(1,\sum_k C_{jk}\right)}.

Here CjiC_{ji} is the contact count and ηi\eta_i the source neuron's sign. The sum over kk counts all incoming unsigned contacts to target jj; absent connections remain zero. For predicted neurotransmitter νi\nu_i,

ηi={1,νi{gaba, glutamate, histamine},+1,otherwise.\eta_i=\begin{cases}-1,&\nu_i\in\{\text{gaba, glutamate, histamine}\},\\+1,&\text{otherwise}.\end{cases}

Unknown and other annotations take the positive branch. Each source has one sign across all outgoing connections, and W0W^0 is not learned.

Neural dynamics

Each neuron has learned latent parameters aia_i and bib_i, initially zero. They determine outgoing gain gig_i and leak i\ell_i:

gi=exp ⁣(log(4)tanh(ai)),i=0.05+0.9σ(bi).g_i=\exp\!\left(\log(4)\tanh(a_i)\right),\qquad \ell_i=0.05+0.9\,\sigma(b_i).

Here σ\sigma is the logistic sigmoid and tanh\tanh the hyperbolic tangent. Gains start at 1 and remain between 0.25 and 4; leaks start at 0.5 and remain between 0.05 and 0.95. These parameters are shared across all updates.

The effective connection is

Wjieff=Wji0gi.W^{\mathrm{eff}}_{ji}=W^0_{ji}g_i.

Positive gains preserve the assigned signs and topology. All outgoing edges from neuron ii share gig_i, rather than receiving independent learned weights.

Starting from neural state h0=0h^0=0, the model performs twenty synchronous updates:

hjt+1=(1j)hjt+jtanh ⁣(iWji0gihit+dj),t=0,,19.h_j^{t+1}=(1-\ell_j)h_j^t+ \ell_j\tanh\!\left(\sum_i W^0_{ji}g_i h_i^t+d_j\right), \qquad t=0,\ldots,19.

Here hjth_j^t is neuron jj's state at step tt, and djd_j its image drive. Every neuron uses the previous state. In vector form, with \odot denoting elementwise multiplication,

ht+1=(1)ht+tanh ⁣(W0(ght)+d),t=0,,19.h^{t+1}=(1-\ell)\odot h^t+\ell\odot\tanh\!\left(W^0(g\odot h^t)+d\right),\qquad t=0,\ldots,19.

The states are signed, continuous, rate-like activations.

Classification

The classifier reads 148,763 neurons, excluding those annotated as sensory. Missing annotations are retained. The readout includes early visual interneurons but none of the directly driven receptors.

Let R\mathcal R be this index set and M=R=148,763M=|\mathcal R|=148{,}763. For each image, the final states become normalized features qjq_j:

qj=hj20MM1kR(hk20)2+106,jR.q_j=\frac{h_j^{20}}{\sqrt{M}\sqrt{M^{-1}\sum_{k\in\mathcal R}(h_k^{20})^2+10^{-6}}}, \qquad j\in\mathcal R.

The 10610^{-6} term stabilizes the root-mean-square denominator; M\sqrt M also scales for population size. No batch or cohort statistics enter this normalization.

Learned weights wjw_j and bias cc produce logit zz and predicted pleural effusion probability pp:

z=jRwjqj+c,p=σ(z).z=\sum_{j\in\mathcal R} w_j q_j+c,\qquad p=\sigma(z).

Weights begin as independent normal draws with mean 0 and standard deviation 0.01; the bias begins at zero. Unlike anatomical gains, these artificial classifier parameters are unconstrained in sign.

The complete parameter set is

θ=(a,b,w,c),θ=2N+M+1=482,164.\theta=(a,b,w,c),\qquad |\theta|=2N+M+1=482{,}164.

This counts all allocated parameters, including those of neurons that receive no input.

Training objective

The training set contains 7,859 positive and 13,396 negative images. Their ratio sets positive-class weight α\alpha:

α=13,3967,8591.7045425626670059.\alpha=\frac{13{,}396}{7{,}859}\approx1.7045425626670059.

For a minibatch of BB images, label yn{0,1}y_n\in\{0,1\} and logit znz_n give weighted binary cross-entropy

L(θ)=1Bn=1B[αynlog(1+ezn)+(1yn)log(1+ezn)].\mathcal L(\theta)=\frac{1}{B}\sum_{n=1}^{B} \left[\alpha y_n\log(1+e^{-z_n})+(1-y_n)\log(1+e^{z_n})\right].

The loss averages over images. The same α\alpha is used for validation. Gradients pass through all twenty updates, while the anatomical matrix stays fixed.

We used AdamW [6] with learning rates 10510^{-5} for (a,b)(a,b) and 10410^{-4} for (w,c)(w,c), momentum coefficients (0.9,0.999)(0.9,0.999), numerical stabilizer 10810^{-8}, and decoupled weight decay 10410^{-4} on all trainable parameters. Gradients were clipped to global L2 norm 5 before each update. Batch size was 64, retaining the final partial batch; initialization used seed 17.

Results

The model achieved 0.8241 validation AUROC and 0.6463 weighted validation cross-entropy at epoch 195.

Validation AUROC
0.8241Epoch 195
Training images
21,255Eligible images in the prepared cohort
Recurrent updates
20Original sparse R1–R6 input

Only explicitly present or absent report labels were included; uncertain or unmentioned findings were excluded. Contradictory studies and identical images crossing partitions were removed. The partitions are patient-disjoint subsets of MIMIC-CXR:

PartitionImagesPatients
Training21,2556,729
Validation3,7741,194

We report results from the epoch with the highest validation AUC.

MetricValidation
AUROC0.8241
Average precision0.6882
Weighted binary cross-entropy0.6463
Accuracy at probability 0.50.7530
Balanced accuracy at 0.50.7554
Sensitivity at 0.50.7630
Specificity at 0.50.7478

AUROC measures ranking of positive versus negative images; average precision summarizes precision–recall ranking and depends on prevalence. Thresholded metrics use probability 0.5.

Validation AUC0.8241
Validation AUC across training40 validation measurements from epoch 0 to 195. The value changes from 0.6643 to 0.8241. The vertical scale runs from 0.6 to 0.85. Hover, tap, or use the left and right arrow keys to inspect each measurement. Home and End select the first and last measurements.0.600.650.700.750.800.85050100150195
Weighted cross-entropy0.6463
Weighted cross-entropy across training40 validation measurements from epoch 0 to 195. The value changes from 0.8617 to 0.6463. The vertical scale runs from 0.6 to 0.9. Hover, tap, or use the left and right arrow keys to inspect each measurement. Home and End select the first and last measurements.0.600.700.800.90050100150195
Epoch 195 / 195

Figure 2. Validation performance across training. AUC and weighted binary cross-entropy on all 3,774 validation images, evaluated every five epochs. Points are measurements; lines connect them without smoothing. The two panels have separate vertical scales.

Discussion

The model learned to distinguish report-labelled pleural effusion while keeping the retinal mapping, anatomical topology and assigned synaptic signs fixed. Learning adjusted per-neuron gains and leaks, plus the artificial readout.

A fruit fly’s connectome is an unusual starting point for an X-ray classifier, but it proved a workable one. It also gives us a concrete way to explore how biological wiring shapes learning on a new task. A rather unexpected day job for a fly’s neural circuitry.

References

  1. Berg, S., Beckett, I. R., Costa, M., et al. “Sexual dimorphism in the complete Drosophila male central nervous system connectome.” Cell, 189(18), 5504–5526.e15 (2026). MaleCNS dataset.
  2. Januszewski, M., & Jain, V. “A connectomics milestone: Mapping the complete male fruit fly brain.” Google Research, September 3, 2026.
  3. Johnson, A. E. W., Pollard, T. J., Berkowitz, S. J., et al. “MIMIC-CXR, a de-identified publicly available database of chest radiographs with free-text reports.” Scientific Data, 6, 317 (2019).
  4. Johnson, A., Lungren, M., Peng, Y., Lu, Z., Mark, R., Berkowitz, S., & Horng, S. “MIMIC-CXR-JPG — chest radiographs with structured labels.” PhysioNet, version 2.1.0 (2024). Credentialed access conditions apply.
  5. Smit, A., Jain, S., Rajpurkar, P., Pareek, A., Ng, A., & Lungren, M. “Combining Automatic Labelers and Expert Annotations for Accurate Radiology Report Labeling Using BERT.” Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing, 1500–1519 (2020).
  6. Loshchilov, I., & Hutter, F. “Decoupled Weight Decay Regularization.” International Conference on Learning Representations (2019).

Talk to us

Interested in next-generation AI for radiology?

Talk to a founder

From the journal

Continue reading

Research20 min read

Qualitative Case Studies for Assessing Foundation Models

Most metrics used to evaluate machine learning models are quantitative, but qualitative assessment is crucial.

Read article
Research20 min read

Maps, Misconceptions, and the Making of Modern Foundation Models

A deep dive into foundation models, their training, and blindsides.

Read article