# Brain anatomy assets / 大脑解剖资源

## Source and license / 来源与许可

The model is derived from **FreeSurfer fsaverage**, an MRI-based group reference template. Both pial surfaces, their cortical masks and `aseg.mgz` come from the same FreeSurfer 6 template distributed in **MNE-Python fsaverage-1.1**. This is not a scan of one identifiable person, and it is not a map of memory activity. The full cortical meshes are retained without decimation.

模型来自 **FreeSurfer fsaverage**，一种由 MRI 建立的群体参考模板。左右软脑膜表面、对应的皮层掩膜与 `aseg.mgz`，全部取自 **MNE-Python fsaverage-1.1** 分发的同一个 FreeSurfer 6 模板。它不是某位可识别个人的扫描，也不是记忆活动地图；皮层保留原始网格，不再减面。

- [Official fsaverage description / 官方模板说明](https://surfer.nmr.mgh.harvard.edu/fswiki/FsAverage)
- [Source archive / 固定版本源数据](https://github.com/mne-tools/mne-data/releases/download/fsaverage-1.1/fsaverage-root.zip)
- [MNE's template loader and provenance / MNE 模板来源说明](https://github.com/mne-tools/mne-python/blob/main/mne/datasets/_fsaverage/base.py)
- [FreeSurfer Software License v1.0, February 2011 / 官方许可](https://www.freesurfer.net/fswiki/FreeSurferSoftwareLicense)
- [Bundled complete license and modification notice / 随附完整许可与修改说明](BRAIN-LICENSE.txt)

The official agreement expressly covers downloaded **software and data**. Its Part B permits reproduction, derivatives, display and redistribution subject to its conditions; it also permits incorporation in proprietary programs. This is the FreeSurfer license, **not CC BY-SA or the MNE software license**. Preserve the full bundled notice and license with the mesh, anatomical manifest, rendered poster and derived ambient-visibility data. Modified data must not be described as unmodified FreeSurfer output.

官方协议明确覆盖下载的**软件与数据**。Part B 在其条件下允许复制、派生、展示与再分发，也允许纳入专有程序。这里适用的是 FreeSurfer 许可，**不是 CC BY-SA，也不是 MNE 的软件许可**。网格、解剖清单、渲染截图和衍生的环境可见度数据均须保留随附完整声明与许可；不能把修改后的数据说成未经修改的 FreeSurfer 原始输出。

Required notice / 必须保留的声明：

> All or portions of this licensed product (such portions are the "Software") have been obtained under license from The General Hospital Corporation and are subject to the following terms and conditions:

The terms follow in [BRAIN-LICENSE.txt](BRAIN-LICENSE.txt). The site's viewer JavaScript and original prose are separate from these anatomical derivatives.

后续条款见 [BRAIN-LICENSE.txt](BRAIN-LICENSE.txt)。网站查看器 JavaScript 与原创正文同这些解剖数据衍生资源分别适用各自许可。

The archive SHA-256 is `17b579e5102c75ce1b8b6a1194abdee9ee75aea5bcac33ad77acf3d77b232c16`. The preparation script verifies this archive and all five extracted inputs against recorded SHA-256 values, including when a local source directory is supplied. The manifest records source hashes, transformations, counts and smoothing measurements. Unrelated atlases in the archive are not redistributed.

源压缩包 SHA-256 为上述值。准备脚本校验压缩包及五个输入文件的固定 SHA-256，使用本地源目录时同样逐文件校验。清单记录源文件哈希、变换、面数与平滑测量结果；压缩包中的其他图谱不进入本站分发。

## Geometry and coordinates / 几何与坐标

The left and right cortical surfaces use `surf/lh.pial` and `surf/rh.pial`. A triangle is retained only when all three of its vertices occur in the corresponding `label/lh.cortex.label` or `label/rh.cortex.label`. This removes the synthetic medial closure of the pial mesh. Four zero-area source faces are also removed. No replacement caps, procedural folds or independently scaled components are added.

左右皮层分别使用 `surf/lh.pial` 与 `surf/rh.pial`。只有三个顶点均出现在对应 `cortex.label` 中的三角形才保留，以排除软脑膜表面网格中的中线合成封口；同时剔除源模型中四个零面积面。不添加替代封口、程序生成的褶皱，也不对某一组件单独缩放。

Hippocampal surfaces are extracted from `mri/aseg.mgz`, labels **17 (left)** and **53 (right)**, by marching cubes at 0.5. The segmentation has **1 mm isotropic voxels**. Its header's `vox2ras_tkr` places these vertices in the same **surface RAS** coordinates as the pial surfaces. Using the image's scanner-RAS affine here would mix coordinate systems. Every structure then receives one shared centering, rotation and uniform scale: surface RAS `(right, anterior, superior)` becomes viewer `(right, superior, posterior)`, with a maximum cortical extent of 2.

海马由 `mri/aseg.mgz` 的 **17（左）**、**53（右）** 标签提取，在 0.5 等值面运行 marching cubes。分割体素为 **1 mm 各向同性**。使用文件头的 `vox2ras_tkr`，把顶点放入与软脑膜表面相同的 **surface RAS** 坐标；此处若使用图像的 scanner-RAS affine，就会混用坐标系。之后全部结构共用一次居中、旋转和均匀缩放：由 surface RAS 的“右、前、上”变为查看器的“右、上、后”，皮层最大跨度归一化为 2。

Ten Taubin pairs (`λ=0.5`, `μ=-0.53`) reduce hippocampal voxel staircasing. They **do not raise the segmentation's spatial resolution or reveal additional anatomical detail**. Against the unsmoothed isosurface, left/right volume changes are approximately +0.260%/+0.207%; maximum corresponding-vertex displacement is 0.604/0.562 mm. The script rejects smoothing that changes volume by 2% or moves a vertex by 1 mm. Neither hippocampus is relocated, enlarged or independently normalized.

海马采用十对 Taubin 平滑（`λ=0.5`、`μ=-0.53`），减轻体素阶梯。平滑**不会提高分割的空间分辨率，也不会产生新的解剖细节**。相对未平滑等值面，左右体积变化约 +0.260%/+0.207%，对应顶点最大位移为 0.604/0.562 mm。脚本拒绝体积变化达到 2% 或顶点位移达到 1 mm 的结果；没有单独移动、放大或归一化海马。

The final geometry contains **613,630 triangles**: 299,357 left cortex, 299,301 right cortex, 7,458 left hippocampus and 7,514 right hippocampus. The raw buffer is 11,051,844 bytes; its gzip copy is about 6.16 MB. The template and 1 mm segmentation limit anatomical precision, especially in the hippocampal close-up; this asset is not for clinical measurement.

最终网格包含 **613,630 个三角形**：左皮层 299,357，右皮层 299,301，左海马 7,458，右海马 7,514。原始缓冲区为 11,051,844 字节，gzip 约 6.16 MB。模板与 1 mm 分割限制了可表达的解剖精度，尤其是海马近景；这些资源不用于临床测量。

## Shading and transport / 着色与传输

`brain-occlusion.bin` is deterministic ambient-visibility shading computed from the real mesh, not an anatomical texture. The cortex sees both cortical hemispheres; the hippocampi see only their pair, so hidden cortex does not darken the isolated view. The file begins with the mesh's 32-byte SHA-256 followed by one visibility byte per vertex. The viewer applies it only if its hash and vertex count match. Missing or stale shading data falls back to ordinary lighting; it never changes geometry.

`brain-occlusion.bin` 是从真实网格计算的确定性环境可见度着色数据，不是解剖纹理。皮层计算两半球之间的遮挡，海马仅计算两侧海马之间的遮挡，避免在独立近景中被已隐藏的皮层压暗。文件以网格的 32 字节 SHA-256 开头，之后每个顶点一个可见度字节；查看器只应用哈希与顶点数量匹配的数据。着色数据缺失或过期时使用普通灯光，不改变几何。

The mesh buffer contains little-endian `float32` positions and `uint32` triangle indices; offsets and counts live in `brain-mesh.json`. The gzip copy decompresses to identical bytes and has `mtime=0` for reproducibility. Readers with `DecompressionStream` load that copy; other readers use the raw buffer. Data and code remain self-hosted. The static poster is rendered from the same geometry.

网格缓冲区包含小端 `float32` 顶点与 `uint32` 三角形索引；偏移与数量存于 `brain-mesh.json`。gzip 解压后与原数据逐字节一致，并以 `mtime=0` 保持可复现。支持 `DecompressionStream` 的浏览器读取压缩副本，否则使用原始缓冲区；数据与代码均由本站提供。静态回退图由同一几何模型渲染。

## Rebuild / 重建

These assets are checked in. A normal site build neither downloads MRI data nor installs Python packages. Maintenance was run with Python 3.12, NumPy 2.2.6, SciPy 1.15.3, NiBabel 5.3.2, scikit-image 0.25.2 and lazy-loader 0.4. Install them in a temporary environment. The optional occlusion bake also uses trimesh 4.6.10 and embreex 2.17.7.post6.

资源已经入库；普通网站构建不下载 MRI 数据，也不安装 Python 包。维护时使用 Python 3.12、NumPy 2.2.6、SciPy 1.15.3、NiBabel 5.3.2、scikit-image 0.25.2 与 lazy-loader 0.4，请安装到临时环境。可选的遮蔽预计算另使用 trimesh 4.6.10 与 embreex 2.17.7.post6。

```bash
# Fetch and verify the recorded release / 下载并校验固定版本
python scripts/prepare-brain-mesh.py

# Or read the same verified files locally / 或读取同版本的已校验本地文件
python scripts/prepare-brain-mesh.py --source-dir /path/to/fsaverage

# Recompute shading whenever the mesh changes / 网格变化后重新计算着色
python scripts/bake-brain-occlusion.py

# Render the fallback from the built viewer / 从构建后的查看器生成回退图
npm run build
node scripts/render-brain-poster.mjs
npm run build
```
