desktop-fly README

The project's README from github.com/DenisSergeevitch/desktop-fly. As one markdown file: README.md.

DesktopFly — a 3D fruit fly

DesktopFly 🪰

A 3D fruit fly that lives on your macOS desktop, with spiking simulations built from FlyWire brain wiring and the MaleCNS brain-to-leg network. It combines identified neural circuits with modeled senses, joints and behavior.

Live brain window: 23,210 real neuron positions, spikes flashing

The fly's brain window: 23,210 real neuron soma positions from FlyWire v783, with live spikes flashing at real neuron locations. The two glowing yellow markers are the Giant Fibers — the escape command neurons. Click any region to stimulate it.

Changelog

1.1.0 — 2026-09-05

The new circuit adds measured anatomy; neural physiology, sensory tuning and muscle mechanics remain modeled. See evaluation and limitations and data provenance.

What's real

The body is procedural. The experimental MaleCNS path drives articulated leg joints and receives joint/contact feedback. Flight, wing-beat, grooming and sleep retain modeled animation and state rules. This is not a full CNS or a biologically calibrated walking simulation.

Installation

Requirements: macOS 13+, Xcode Command Line Tools (Swift 5.9+). No permissions or entitlements needed — everything it senses (cursor, window frames, clicks-as-taps, thermal state) is permission-free.

git clone https://github.com/DenisSergeevitch/desktop-fly.git
cd desktop-fly
./build.sh
./DesktopFly

A 🪰 item appears in the menu bar; quit from there. The fly wanders your desktop on a transparent, click-through overlay — it never intercepts your mouse or keyboard.

Windows

An Electron + three.js port with the same connectome extracts, neural models, and the same test suites lives in windows/ (contributed by @MikeMike88). Requires Windows 10/11 and Node.js 18+:

cd desktop-fly/windows
npm install
npm start          # tray icon 🪰; quit from there
npm test           # all three suites, headless

See windows/README.md for the macOS→Windows mapping table and platform notes (the fly there roams all monitors on its own). The optional stag-beetle body is macOS-only for now.

Controls (menu bar 🪰)

item effect
Pause / Resume freeze the world
Show/Hide Brain toggle the live brain window
Escape Test (loom) inject a looming stimulus, watch the GF fire
Move to Next Display hop the fly across monitors (shown when >1 display)
Add / Remove Fly extra flies (only fly #1 carries the brain)
Scare Flies startle everyone
Body: Fruit Fly / Stag Beetle swap the body geometry — behavior is unchanged

The optional stag-beetle body

The same connectome, the same state machine, a different shell. The behavior layer only ever touches the body through one struct, so a second geometry drops in without a line of behavior code: the elytra open when it flies or when the escape descending neurons fire a grounded threat posture, and the membranous hindwings underneath are the surfaces that actually beat.

The brain window is interactive: hovering pauses the rotation; clicking a region "optogenetically" stimulates the ~60 nearest circuit neurons for 400 ms. Spikes propagate through the extracted FlyWire graph and the configured body interface: the Giant Fiber requests escape, DNg11 requests grooming, and an asymmetric DNa01/02 stimulus changes the steering drive.

How real neurons drive the body

body behavior driven by
escape takeoff DNp01 giant fiber spike
walk vs. rest DNp09 rate through a modeled state threshold
leg activation and grounded movement MaleCNS motor rates → modeled joints and foot contacts
steering drive DNa01+DNa02 activity passed to the male descending populations
grooming DNg11 rate
backward scoot MDN burst
nervous darting LC4/LPLC2 population rate
wing-beat effort, threat wing-raise DNp02/04/11 rate
spontaneous takeoff whole-population arousal

FlyWire population rates drive corresponding male descending cell types through an explicit modeled interface between two specimens. Within MaleCNS, published connections link descending neurons, VNC interneurons, motor neurons, leg sensory neurons and ascending feedback. There are no invented cross-specimen synapses in the data.

Motor channels use named tibial and trochanteral flexors/extensors, sternal anterior/posterior coxal rotators, and named promotor/remotor groups. Body joint angles, velocities and contact/load estimates feed leg-local sensory inputs. Peripheral nerve and receptor-class identities are measured annotations; joint tuning, muscle forces and the conversion of those measurements into current are modeling choices. Fast cursor motion continues to stimulate the original FlyWire sensory pathway.

Desktop ecology (all permission-free macOS senses)

Regenerating the data

data/ ships with compact derived files. To rebuild them from the raw FlyWire Codex dumps (~60 MB download):

mkdir -p /tmp/flywire && cd /tmp/flywire
B=https://storage.googleapis.com/flywire-data/codex/data/fafb/783
curl -O "$B/classification.csv.gz" -O "$B/coordinates.csv.gz" \
     -O "$B/connections.csv.gz" -O "$B/consolidated_cell_types.csv.gz"
cd - && python3 etl.py /tmp/flywire

The separate MaleCNS extractor downloads three public Feather tables (~1.11 GB) into a temporary directory and regenerates the compact locomotor graph:

python3 -m pip install numpy pandas pyarrow
python3 etl_malecns.py /tmp/fly-male-cns --download

It writes data/locomotor_circuit.json and data/locomotor_report.json. The circuit records exact source URLs, SHA-256 hashes, native body IDs and annotations. The report records real descending-to-motor paths and omitted input coverage. See data/LOCOMOTOR_PROVENANCE.md for the extraction rules and data/model boundary. Keep raw downloads outside the repository; the original FlyWire files are not changed by this extractor.

Diagnostics

./DesktopFly --simtest        # circuit invariants and stimulus responses
./DesktopFly --behaviortest   # end-to-end neural/body checks
./DesktopFly --locomotortest  # actual MaleCNS closed loop, direction, lesions, frame-rate checks
./DesktopFly --snapshot f.png  # offscreen body render (3/4 perspective)
./DesktopFly --snapshot f.png --top [--flying] [--beetle]   # the overlay's own
                               # top-down orthographic view, the one users see
./DesktopFly --brainshot b.png # offscreen brain render
./DesktopFly --snapshot walk.png --top --walking # pose from the live motor circuit

What's modeled vs. measured

The connectomes supply anatomy and contact counts, not a working physiological simulation. LIF dynamics, excitability, synaptic signs/delays, electrical-coupling boosts, rate normalization, the interface between specimens, sensory tuning, muscle mechanics and behavioral thresholds are configured models.

MaleCNS retains original neurotransmitter predictions and raw counts. The current sign convention is ACh+, GABA− and Glu−; unresolved/modulatory edges have zero direct current while retaining their source contacts. Motor channels retain only part of their full incoming contacts; the report provides exact coverage by leg and channel. Other inputs and much of the complete nervous system are omitted.

Connectivity alone does not establish alternating gait, stable balance or realistic muscle recruitment: a network may co-contract or settle under tonic drive. The motor evaluation requires sustained stepping after startup, physical backward motion, causal steering and loss of propulsion after motor silencing. The complete sensor/neuron/body feedback loop runs at 120 Hz independently of render refresh, with 1 kHz neurons and 600 Hz mechanical substeps. Muscle force and relaxation parameters are calibrated model choices; see evaluation. Anatomical path checks and software behavior tests do not demonstrate agreement with measured fly locomotion. The brain window continues to show the FlyWire visualization rather than all 1,713 simulated cells together.

License & citation

Code is MIT. The original FlyWire-derived brain_points.json and circuit.json are CC BY-NC 4.0. The MaleCNS-derived locomotor_circuit.json and locomotor_report.json are CC BY 4.0 — see data/DATA_LICENSE.md. If you use this, cite:

desktop-fly (DenisSergeevitch/desktop-fly)

Searching Database…

这是什么?DesktopFly 是一只生活在 macOS 桌面上的 3D 果蝇,由基于真实 FlyWire 果蝇大脑连接组(外加 MaleCNS 数据集的一个运动回路)构建的实时脉冲发放仿真驱动。
这是真实的大脑仿真,还是只是一个动画吉祥物?两者兼具:一个 668 神经元的 FlyWire 回路基于实测连接以真实的 1 kHz 泄漏积分发放仿真运行,而身体运动、肌肉力学和感觉调节则是在这些真实数据之上叠加的建模近似。
我怎么让它跑起来?在 macOS 13+ 上用 Xcode Command Line Tools(Swift 5.9+)构建,之后菜单栏会出现一个果蝇图标。windows/ 文件夹里还有一个独立的 Electron + three.js 移植版,在 Windows 10/11 上配合 Node.js 18+ 运行。
试用之前需要 Xcode 或 Node.js 吗?原生 macOS 应用需要带 Swift 5.9+ 的 Xcode Command Line Tools;Windows 移植版需要 Node.js 18+。不需要任何 API 密钥或特殊权限。
腿部行走和大脑行为在生物学上准确吗?不准确——连接数据是真实的,但 LIF 动力学、突触符号/延迟、肌肉力学和行为阈值都是人为配置的模型选择,项目也明确说明这不是完整的中枢神经系统,也不是经过生物学校准的行走仿真。
它在 Windows 上也能用,还是只有 Mac?原生应用仅限 macOS,但社区贡献的 Electron + three.js 移植版使用相同的连接组数据和神经模型,可在 Windows 10/11 上运行;可选的锹形虫身体切换目前仍仅限 macOS。
跟踪我的光标和窗口需要特殊权限吗?不需要——果蝇感知的一切(光标位置、窗口边框、点击、热状态)都无需请求任何 macOS 权限或授权即可读取。
巨纤维(Giant Fiber)是什么?它对这只果蝇为什么重要?DNp01 即巨纤维,是果蝇真实的逃生指令神经元;当它的模拟脉冲发放时(由逼近的光标或点击触发),桌面果蝇就会起飞。
这只果蝇真能用真实的腿部解剖结构行走吗?可以,部分可以——一个 1,045 神经元的 MaleCNS 提取部分(含实测的下行神经元、VNC 和腿部运动/感觉神经元)驱动带关节的腿部,但把这些信号转化为运动的肌肉力学是建模的,并非实测。
我能更换桌面宠物的外观吗?可以。菜单栏让你在果蝇和锹形虫之间切换身体;底层神经行为保持不变,因为身体只通过一个共享的接口结构体连接。
果蝇会对室温或一天中的时间之类的东西做出反应吗?会——它模拟昼夜节律(黎明/黄昏活动、正午午休、夜间睡眠),并且像变温动物一样,Mac 运行得越热它移动越快。
Size
0.8 MB
Stars
1.1K
Updated
CommitSep 05
Age
1mo
Commits · 90 Days