跳到主内容
@wquguru
精选85Hacker News Best(web_list)产品发布/更新

macOS桌面3D果蝇:由真实FlyWire连接组驱动

原文
发到 X
推荐理由

做神经形态计算或具身智能的同学必看,这是把真实连接组跑成可交互桌宠的硬核实践,代码开源可直接克隆复现,赶紧在你的 Mac 上跑起来试试逃逸延迟。

DesktopFly 🪰

DesktopFly 🪰

A 3D fruit fly that lives on your macOS desktop — driven by a live spiking simulation of the real FlyWire connectome. It walks across your windows, grooms, sleeps, and decides to flee your cursor with the same neurons a real fly uses.

一只生活在你的 macOS 桌面上的 3D 果蝇——由真实的 FlyWire 连接组的实时尖峰模拟驱动。它会在你的窗口上行走、梳理毛发、睡觉,并用与真实果蝇相同的神经元决定逃离你的光标。

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.

果蝇的大脑窗口:来自 FlyWire v783 的 23,210 个真实神经元胞体位置,实时尖峰在真实神经元位置闪烁。两个发光的黄色标记是巨纤维——逃逸命令神经元。点击任何区域以刺激它。

What's real

什么是真实的

  • 23,210 neuron soma positions (of 139,255 in FlyWire v783) render the rotating brain window, colored by super-class (FlyWire's coarse cell-type grouping).
  • A 668-neuron circuit with ~19,000 real synaptic connections (synapse counts, signed by neurotransmitter prediction) runs as a 1 kHz leaky-integrate-and-fire (LIF) simulation:
  • LC4 (104) + LPLC2 (210) looming-detector visual neurons
  • DNp01 / Giant Fiber (GF) (2) — the escape command neuron
  • DNa01 + DNa02 (4) steering neurons · DNp09 (2) forward walking
  • DNg11 (6) grooming · MDN (4) backward walking ("moonwalker")
  • DNp02/DNp04/DNp11 (6) escape-maneuver (wing) neurons
  • their 330 strongest partners, including ascending (proprioceptive) and sensory (wind) neurons
  • Escape is not scripted. Your cursor's approach becomes looming input to the real LC4/LPLC2 cells; the fly takes off only when the Giant Fiber actually spikes through its real synapses — ~1,200 synapses of feedforward inhibition push back, which is why slow approaches are tolerated and fast lunges trigger escape in ~4 ms, just like the real animal.
  • 23,210 个神经元胞体位置(FlyWire v783 中的 139,255 个)渲染旋转的大脑窗口,按超类(FlyWire 的粗粒度细胞类型分组)着色。
  • 一个包含 668 个神经元、约 19,000 个真实突触连接(突触计数,按神经递质预测标记)的电路以 1 kHz 的泄漏积分-发放(LIF)模拟运行:
  • LC4(104)+ LPLC2(210)逼近检测视觉神经元
  • DNp01 / 巨纤维(GF)(2)——逃逸命令神经元
  • DNa01 + DNa02(4)转向神经元 · DNp09(2)向前行走
  • DNg11(6)梳理 · MDN(4)向后行走("月球漫步者")
  • DNp02/DNp04/DNp11(6)逃逸机动(翅膀)神经元
  • 它们的 330 个最强伙伴,包括上行(本体感觉)和感觉(风)神经元
  • 逃逸不是脚本化的。你的光标接近成为对真实 LC4/LPLC2 细胞的逼近输入;只有当巨纤维通过其真实突触实际发放时,果蝇才会起飞——约 1,200 个前馈抑制突触会推回,这就是为什么缓慢接近被容忍,而快速猛扑会在约 4 毫秒内触发逃逸,就像真实动物一样。

The body itself is procedural (FlyWire is a brain connectome — no body geometry exists), with a tripod gait, visible wing-beat, altitude-scaled flight, grooming, and sleep postures.

身体本身是程序生成的(FlyWire 是一个大脑连接组——没有身体几何结构),具有三脚架步态、可见的翅膀拍动、按高度缩放的飞行、梳理和睡眠姿势。

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.

要求:macOS 13+,Xcode 命令行工具(Swift 5.9+)。无需权限或授权——它感知的一切(光标、窗口框架、点击作为轻拍、热状态)都是无需权限的。

代码 · 4
git clone https://github.com/DenisSergeevitch/desktop-fly.git
cd desktop-fly
./build.sh
./DesktopFly
代码 · 4
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.

菜单栏中出现一个 🪰 项目;从那里退出。果蝇在透明的、可点击穿透的覆盖层上漫游你的桌面——它永远不会拦截你的鼠标或键盘。

Controls (menu bar 🪰)

控制(菜单栏 🪰)

itemeffect
Pause / Resumefreeze the world
Show/Hide Braintoggle the live brain window
Escape Test (loom)inject a looming stimulus, watch the GF fire
Move to Next Displayhop the fly across monitors (shown when >1 display)
Add / Remove Flyextra flies (only fly #1 carries the brain)
Scare Fliesstartle everyone
项目效果
暂停 / 恢复冻结世界
显示 / 隐藏大脑切换实时大脑窗口
逃逸测试(逼近)注入逼近刺激,观察 GF 发放
移动到下一个显示器让果蝇跳到其他显示器(当显示器 >1 时显示)
添加 / 移除果蝇额外的果蝇(只有 #1 号果蝇携带大脑)
吓唬果蝇惊吓所有果蝇

The brain window is interactive: hovering pauses the rotation; clicking a region "optogenetically" stimulates the ~60 nearest circuit neurons for 400 ms. The fly's reaction is whatever the real network does downstream — click the Giant Fiber and it escapes; click DNg11 and it grooms; click one side's DNa01/02 and it turns.

大脑窗口是交互式的:悬停会暂停旋转;点击某个区域会“光遗传学”刺激附近约60个回路神经元,持续400毫秒。苍蝇的反应就是真实网络下游所做的任何事——点击巨纤维神经元,它会逃跑;点击DNg11,它会梳理;点击一侧的DNa01/02,它会转向。

How real neurons drive the body

真实神经元如何驱动身体

body behaviordriven by
escape takeoffDNp01 giant fiber spike
walk vs. rest, walking speedDNp09 rate
steeringDNa01+DNa02 left−right rate difference
groomingDNg11 rate
backward scootMDN burst
nervous dartingLC4/LPLC2 population rate
wing-beat effort, threat wing-raiseDNp02/04/11 rate
spontaneous takeoffwhole-population arousal
身体行为由...驱动
逃跑起飞DNp01巨纤维神经元尖峰
行走与休息,行走速度DNp09速率
转向DNa01+DNa02左右速率差
梳理DNg11速率
后退滑行MDN爆发
紧张性闪避LC4/LPLC2群体速率
翅膀拍打力度,威胁性抬翅DNp02/04/11速率
自发起飞全群体唤醒水平

The loop also closes body→brain: the gait rhythm feeds the circuit's real ascending (proprioceptive) neurons in phase with the legs, and fast cursor motion stimulates its sensory (wind) partners.

回路也闭合了身体→大脑的循环:步态节律以与腿部同步的相位,将信号馈入回路中真实的上行(本体感觉)神经元,而快速光标移动则刺激其感觉(风)伙伴。

Desktop ecology (all permission-free macOS senses)

桌面生态(所有无需权限的macOS感知)

  • Window terrain: window top edges are ledges — the fly lands on them, walks along them, rides a window you drag, and startles when one closes under its feet.
  • Window looms: a window appearing near the fly feeds the looming pathway; the circuit decides whether to flee your dialogs.
  • Clicks are substrate taps; clicking next to the fly startles it through the wind→GF pathway. Typing is vibration (idle-time API — knows when keys were pressed, never which).
  • Circadian rhythm: dawn/dusk activity peaks, midday siesta, night quiescence. Sleep: idle at night → it sleeps, breathing slowly, with raised arousal threshold; it grooms after waking.
  • Temperature: flies are ectotherms — a hot Mac is a faster fly.
  • 窗口地形:窗口顶部边缘是壁架——苍蝇落在上面,沿着它们行走,骑在你拖动的窗口上,当窗口在它脚下关闭时会受惊。
  • 窗口逼近:靠近苍蝇出现的窗口会激活逼近通路;回路决定是否逃离你的对话框。
  • 点击是基底敲击;点击苍蝇旁边会通过风→巨纤维通路惊吓它。打字是振动(空闲时间API——知道按键何时被按下,但从不涉及具体按键)。
  • 昼夜节律:黎明/黄昏活动高峰,中午午睡,夜间静止。睡眠:夜间不活动→它睡觉,呼吸缓慢,唤醒阈值提高;醒来后它会梳理。
  • 温度:苍蝇是变温动物——热的Mac意味着更快的苍蝇。

Regenerating the data

重新生成数据

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

data/ 附带紧凑的派生文件。要从原始FlyWire Codex转储(约60 MB下载)重建它们:

代码 · 5
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
代码 · 5
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

Diagnostics

诊断

代码 · 4
./DesktopFly --simtest        # circuit invariants: GF silent at rest, 4 ms loom latency, ...
./DesktopFly --behaviortest   # 17 end-to-end checks: stimulate neurons -> body reacts
./DesktopFly --snapshot f.png  # offscreen fly render
./DesktopFly --brainshot b.png # offscreen brain render
代码 · 4
./DesktopFly --simtest        # circuit invariants: GF silent at rest, 4 ms loom latency, ...
./DesktopFly --behaviortest   # 17 end-to-end checks: stimulate neurons -> body reacts
./DesktopFly --snapshot f.png  # offscreen fly render
./DesktopFly --brainshot b.png # offscreen brain render

What's modeled vs. measured

建模与测量的对比

Honesty section: the connectome gives wiring, not physiology. The LIF dynamics, neurotransmitter signs (ACh+, GABA−, Glu−), the gap-junction boost on LC→GF and wind→GF (documented electrical coupling), synaptic delays, and the sensory transduction (cursor → looming value) are standard modeling choices layered on the real graph. Everything downstream of the sensory neurons — who connects to whom, and how strongly — is FlyWire data.

诚实说明:连接组提供布线,而非生理学。LIF动力学、神经递质符号(ACh+, GABA−, Glu−)、LC→GF和风→GF上的间隙连接增强(有记录的电气耦合)、突触延迟以及感觉转导(光标→逼近值)都是叠加在真实图上的标准建模选择。感觉神经元下游的一切——谁连接到谁,以及连接强度——都是FlyWire数据。

License & citation

许可证与引用

Code is MIT. The files in data/ are derived from FlyWire (FAFB v783) and are CC BY-NC 4.0 — see data/DATA_LICENSE.md. If you use this, cite:

代码采用MIT许可证。data/中的文件源自FlyWire(FAFB v783),采用CC BY-NC 4.0许可——参见data/DATA_LICENSE.md。如果你使用此内容,请引用:

  • Dorkenwald, S. et al. Neuronal wiring diagram of an adult brain. Nature 634, 124–138 (2024). https://doi.org/10.1038/s41586-024-07558-y
  • Schlegel, P. et al. Whole-brain annotation and multi-connectome cell typing of Drosophila. Nature 634, 139–152 (2024). https://doi.org/10.1038/s41586-024-07686-5
  • Dorkenwald, S. 等人. 成年大脑的神经元接线图. Nature 634, 124–138 (2024). https://doi.org/10.1038/s41586-024-07558-y
  • Schlegel, P. 等人. 果蝇全脑注释与多连接组细胞分型. Nature 634, 139–152 (2024). https://doi.org/10.1038/s41586-024-07686-5

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

另一事件,读法相近