首页Home / 数据格式 V3.0Data Format V3.0
统一数据格式 V3.0 Unified Data Format V3.0

蓝牙与 U 盘双通道
同一套解析接口
Dual channel: BLE and USB drive
behind one parsing interface

科研数据最耗时的环节从来不是采集,而是清洗、对齐与标注。V3.0 的目标很直接:让三个硬件形态、两条传输通道产出的数据,在 PC 端呈现完全一致的解析结果——算法代码一行都不用改。 The most time-consuming part of research data is never acquisition — it is cleaning, alignment and labelling. V3.0 has a single objective: make data from three hardware forms and two transport channels parse identically on the PC side — without changing a single line of your algorithm code.

2传输通道Transport channels
4帧型Frame types
CRC16逐帧校验Per-frame check
1解析接口Parsing API

设计目标Design goals

  • 设备端只写二进制,文本格式交 PC 端生成 Device writes binary only; text formats are generated on the PC side
  • 原生采样率,不做重采样、不做填充 Native sampling rates, no resampling and no padding
  • 毫秒级统一时间戳,可离线重建绝对时间 Millisecond-unified timestamps, absolute time reconstructible offline
  • 逐帧 CRC,坏帧可定位、可丢弃、不影响后续 Per-frame CRC so corrupt frames are locatable, droppable and non-propagating
  • 元数据完整快照,含寄存器配置,保证科研可复现 Complete metadata snapshot including register configuration for reproducibility
  • 蓝牙与 U 盘两条通道输出同一个对象 Both BLE and USB channels emit the same object

01 三层架构Three-Layer Architecture

L1 采集内核 → L2 传输与落盘 → L3 PC 端统一解析 L1 acquisition core → L2 transport and logging → L3 unified PC parsing
L1 · 采集内核Acquisition core SampleFrame 唯一真相源。各通道按各自原生采样率产生样本,未经任何插值或填充。这是整个格式体系的锚点。 The SampleFrame is the single source of truth. Each channel emits samples at its own native rate with no interpolation or padding. This anchors the entire format.
→
L2a · 蓝牙通道BLE channel 实时流式传输。分包、序号、逐包校验、确认重传机制;波形延迟控制在 100 ms 量级。 Real-time streaming with fragmentation, sequence numbering, per-packet checksums and acknowledgement/retransmission; waveform latency kept in the ~100 ms range.
L2b · U 盘通道USB-drive channel 定长二进制帧落盘。按通道拆分成独立文件,帧长互不整除以保证无歧义重同步。 Fixed-length binary frames logged to disk, split into per-channel files with mutually non-dividing frame lengths for unambiguous resynchronisation.
→
L3 · PC 端解析parsing BluetoothSource 与 UDiskSource 输出同一种 SampleFrame。 BluetoothSource and UDiskSource emit the same SampleFrame type.
为什么这条设计值钱:Why this design matters: 你的分析代码只针对一种输入对象编写。今天用蓝牙做预实验、明天用 U 盘做长时程记录,或者同一批数据一半来自指套一半来自胸贴——下游管线完全不需要分支。 Your analysis code targets exactly one input type. Run a pilot over BLE today and a multi-day recording from a USB drive tomorrow, or mix sleeve and patch data in one cohort — the downstream pipeline needs no branching at all.
层级Layer 产物Artifact 典型用途Typical use 关键属性Key properties
L1 SampleFrame 固件内部唯一数据模型Single in-firmware data model 通道字典 + 统一时间戳 + 质量位 + 事件标记;各通道原生速率Channel dictionary + unified timestamp + quality bits + event markers; per-channel native rates
L2a BLE 实时流 / .ftrawlive stream / .ftraw 实时监视、预实验、交互式采集Live monitoring, pilot work, interactive acquisition 低延迟;边收边存;断点可续Low latency; write-while-receiving; resumable
L2b U 盘二进制文件USB-drive binary files 长时程归档、临床佩戴、离线研究Long-duration archiving, clinical wear, offline studies 定长帧;逐帧校验;断电最多丢 1 秒Fixed-length frames; per-frame checksums; at most 1 s lost on power loss
L3 PC 端数据对象PC-side data object 算法开发、统计分析、格式转换Algorithm development, statistics, format conversion 统一输入;可导出为科研数据标准格式Unified input; exportable to research data standards

02 四种帧型(U 盘通道) Four Frame Types (USB-drive channel)

按通道原生速率拆分独立文件,彻底消除填充 Split into per-channel files at native rates, eliminating padding entirely
帧型Frame 内容布局Payload layout 帧长Length 采样率Rate 用途Purpose
F1 时间戳timestamp (4) + ECG (4) + status (2) + CRC16 (2) + 保留reserved (4) 16 B 512 / 1024 Hz 心电主通道(双档采样率可选)Primary ECG channel (two selectable rates)
F2a 时间戳timestamp (4) + BIOZ (4) + BIOZ_AUX (4) + CRC16 (2) + 保留reserved (2) 16 B 16 Hz BioZ 标量通道(EDA / 呼吸等低频模式)BioZ scalar channel (EDA, respiration and other low-rate modes)
F2b 时间戳timestamp (4) + PPG ×8 (32) + IMU ×6 (12) + flags (4) + LED 电流current (4) + 保留reserved (4) + CRC16 (2) + 保留reserved (2) 64 B 128 Hz 8 波长 PPG 与六轴 IMU 同帧同步8-wavelength PPG and 6-axis IMU synchronised in one frame
F3 时间戳timestamp (4) + TEMP ×4 (8) + ILLUM (2) + MARKER (1) + QUALITY (1) + CRC16 (2) 16 B 1 Hz / 事件event 慢变通道、光照、事件标记与质量位Slow channels, illumination, event markers and quality bits

为什么 512 / 64 字节刚好Why 512 and 64 bytes work

存储设备以扇区为单位写入。16 字节帧每扇区正好装 32 帧,64 字节帧正好装 8 帧——没有半个帧跨扇区的问题,写入逻辑可以做得非常简单可靠。 Storage writes happen in sectors. A 16-byte frame fits exactly 32 times per sector and a 64-byte frame exactly 8 times — no frame straddles a sector boundary, keeping write logic simple and reliable.

帧长互不整除Mutually non-dividing lengths

16 与 64 字节的帧长组合,使得在任意字节偏移处重新同步时几乎不会出现歧义匹配。这是长时程文件损坏后仍能恢复数据的关键设计。 The 16/64-byte combination means resynchronisation at any byte offset is almost never ambiguous. This is what allows data recovery from long recordings after corruption.

逐帧 CRC16Per-frame CRC16

每一帧独立校验。坏帧可被单独定位与剔除,不会污染相邻数据——对临床长时程记录尤为重要。 Each frame carries its own checksum. A corrupt frame can be located and dropped in isolation without contaminating neighbours — critical for long clinical recordings.

速率与余量:Throughput and headroom: 按上述帧型与采样率核算,全通道连续落盘的数据速率远低于存储子系统的写入上限,留有充足余量应对突发写入与闪存擦除延迟。这意味着即使在最高采样档位下,长时间连续记录也不会因为写入瓶颈而丢帧。 At the frame types and rates above, the full-channel continuous logging throughput sits well below the storage subsystem's write ceiling, leaving ample headroom for burst writes and flash-erase latency. Even at the highest sampling tier, long continuous recordings will not drop frames due to write bottlenecks.

03 通道注册表Channel Registry

每个通道一个稳定 ID,跨设备形态通用 A stable ID per channel, shared across all hardware forms
ID 区段ID range 通道组Channel group 包含通道Members 原生速率Native rate
0x01–0x02ECG 心电主通道、辅助/参考通道Primary ECG, auxiliary/reference 512 / 1024 Hz
0x10–0x12BIOZ BIOZ, BIOZ_AUX, BIOZ_PHASE 16 Hz
0x20–0x27PPG 8 个波长:525 / 660 / 850 / 940 / 1050 / 1300 / 1550 / 1650 nmEight wavelengths: 525 / 660 / 850 / 940 / 1050 / 1300 / 1550 / 1650 nm 128 Hz
0x30–0x35IMU 三轴加速度 + 三轴陀螺仪3-axis accelerometer + 3-axis gyroscope 128 Hz
0x40–0x43TEMP 四路温度——每个电极附近各 1 路(组织温度梯度同步可见)Four temperature channels, one adjacent to each electrode (tissue temperature gradient visible in sync) 1 Hz
0x50ILLUM 环境光Ambient illumination 1 Hz
0x60MARKER 事件标记(按键短按 / 远程触发 / 刺激事件)Event markers (key press / remote trigger / stimulus events) 事件驱动Event-driven
0x70QUALITY 数据质量位图:导联脱落 / 佩戴状态 / 接触质量等Data-quality bitmap: lead-off, wear state, contact quality etc. 1 Hz
注册表的设计意义:Why a registry: ID 区段固定、含义稳定,不随硬件形态改变。同一段分析代码可以同时处理指套、胸贴与戒指的数据——某个通道在特定形态上不存在时只是"缺席",而不是"换了个 ID"。这对多设备队列研究是决定性的便利。 ID ranges are fixed and meanings stable regardless of hardware form. The same analysis code processes sleeve, patch and ring data alike — when a channel does not exist on a particular form it is simply absent, never reassigned to a different ID. For multi-device cohort studies this is a decisive convenience.

04 时间戳体系Timestamp System

毫秒级统一基准,可离线重建绝对时间 Millisecond unified baseline, absolute time reconstructible offline

两级时间:会话起点 + 相对偏移 Two-level time: session origin plus relative offset

每个采集会话在元数据中记录一个绝对起始时间(UTC,毫秒精度),每帧只携带相对该起点的毫秒偏移。这样做的原因有两个: Each acquisition session records one absolute start time (UTC, millisecond precision) in its metadata, and every frame carries only a millisecond offset relative to that origin. There are two reasons:

  • 省空间:帧内只放 4 字节偏移,而不是 8 字节绝对时间——对上百万帧的会话是显著节省。 Space: a 4-byte offset per frame rather than an 8-byte absolute timestamp — a substantial saving across sessions of millions of frames.
  • 抗漂移:设备 RTC 的绝对精度有限(技术要求允许 24 h 内误差 ≤5 min),但相对偏移由高稳定时钟源产生,精度远高于绝对时间。数据内部的时间关系因此始终可靠。 Drift immunity: the device RTC has limited absolute accuracy (the technical requirement permits ≤5 min drift per 24 h), but relative offsets come from a high-stability clock and are far more precise. Internal timing relationships therefore remain reliable throughout.

采样间隔的表达方式 How the sampling interval is expressed

元数据中同时给出浮点间隔与精确分数形式(分子 / 分母)。分数形式的分母取 2 的整数次幂,便于用移位与整数运算精确重建每一帧的时间,完全避免浮点累积误差。 Metadata provides both a floating-point interval and an exact fractional form (numerator / denominator). The denominator is a power of two so frame times can be reconstructed exactly with shifts and integer arithmetic, eliminating floating-point accumulation error.

给算法开发者的建议:Advice for algorithm developers: 重建时间轴时请使用分数形式做整数运算,不要直接用浮点间隔做累加。这样即使分析数小时的记录,也不会出现末尾时间轴漂移。 Reconstruct the time axis with integer arithmetic on the fractional form rather than accumulating the floating-point interval; this prevents end-of-record time-axis drift even over hours of analysis.

05 文件与目录布局File & Directory Layout

U 盘目录结构USB-drive directory structure

/
├── sub-S005/                  # subject ID (subject-level)
│   ├── ses-20260927/          # session (session-level)
│   │   ├── META.BIN           # metadata snapshot
│   │   ├── F1_ecg.bin         # 16 B frames @512/1024 Hz
│   │   ├── F2a_bioz.bin       # 16 B frames @16 Hz
│   │   ├── F2b_ppg_imu.bin    # 64 B frames @128 Hz
│   │   ├── F3_slow.bin        # 16 B frames @1 Hz / events
│   │   └── session.log         # human-readable event log
│   └── ses-20260928/
│       └── …
└── sub-UNKNOWN/               # when no subject ID was set

目录层级采用"受试者 → 会话"两段式,命名规则与主流科研数据组织的习惯一致,便于批量导入与脚本遍历。未设置受试者编号时落入 sub-UNKNOWN,事后可重命名而无需改动文件内容。 The two-level subject → session hierarchy follows common research data organisation conventions, easing bulk import and scripted traversal. When no subject ID is set, data lands in sub-UNKNOWN and can be renamed later without touching file contents.

META.BIN 元数据快照META.BIN metadata snapshot

科研可复现的关键:把"当时设备处于什么状态"完整记录下来。 Reproducibility hinges on recording exactly what state the device was in.

字段组Field group内容Content
会话时间Session time 绝对起始时间(UTC 毫秒)+ 采样间隔浮点值与精确分数形式 Absolute start time (UTC ms) + sampling interval as both float and exact fraction
通道配置Channel config 各通道启用状态、采样率档位、增益设置 Per-channel enable state, sampling-rate tier, gain settings
BioZ 工作参数BioZ operating parameters 工作模式(EDA / ICG / 呼吸 / 阻抗谱)、激励幅度与频段 Operating mode (EDA / ICG / respiration / spectroscopy), drive amplitude and frequency band
寄存器快照Register snapshot 采集开始时刻前端全部寄存器的完整快照 Complete snapshot of all front-end registers at acquisition start
文件清单File manifest 四个数据文件的帧计数、字节长度、校验摘要 Frame count, byte length and checksum digest for each of the four data files
界面设置UI settings 界面语言、受试者编号、固件版本 Interface language, subject ID, firmware version
为什么寄存器快照重要:Why the register snapshot matters: 两年后审稿人问"这批 EDA 数据当时的激励参数是多少",答案就在文件里,不需要翻实验记录本。 When a reviewer asks two years later what excitation parameters were used for a batch of EDA data, the answer is in the file rather than in a lab notebook.

06 PC 端解析接口PC-Side Parsing Interface

Python · 零依赖核心 · 两条通道同一输出 Python · dependency-free core · identical output from both channels

核心抽象Core abstractions

# SampleFrame — the single truth source on the PC side
class SampleFrame:
    t_utc_ms:  int          # absolute UTC time (ms)
    t_ms:      int          # offset from session origin
    channels:  dict[int, float]   # ChID -> value
    quality:   int          # quality bitmap (0x70)
    marker:    int          # event marker (0x60)

# FrameSource — abstract, two concrete implementations
class FrameSource:            # iterable of SampleFrame
    ...

class BluetoothSource(FrameSource):   # live / .ftraw
    ...

class UDiskSource(FrameSource):       # .bin files
    ...

用法:换数据源,不改算法 Usage: swap the source, keep the algorithm

from ft_core import UDiskSource, BluetoothSource

# Option A — read from a USB drive dump
src = UDiskSource("E:/sub-S005/ses-20260927")

# Option B — read from a BLE session capture
# src = BluetoothSource("capture.ftraw")

# Downstream is identical for both
for frame in src:
    ecg   = frame.channels[0x01]
    eda   = frame.channels[0x10]
    ppg   = frame.channels[0x20]
    # ... your algorithm here, unchanged

格式转换工具Format conversion tool

除原始二进制归档外,PC 端工具可把会话导出为科研数据标准格式(按通道分组的表格文件 + 结构化元数据),直接兼容常见分析生态与数据校验工具。转换在 PC 端完成,设备端固件完全不参与——固件只负责产出可靠的二进制原始数据。 Beyond the raw binary archive, the PC-side tool exports sessions into a research data standard format (per-channel tabular files plus structured metadata) compatible with common analysis ecosystems and validation tools. Conversion happens entirely on the PC; firmware only produces reliable binary raw data.

设备端Device 写二进制定长帧,严格 CRC,断电最多丢 1 秒 Fixed-length binary frames with strict CRC; at most 1 s loss on power failure
→
PC 端解析PC parsing 统一 SampleFrame 对象,逐帧校验与时间轴重建 Unified SampleFrame objects with per-frame validation and time-axis reconstruction
→
导出Export 科研数据标准格式,供分析、共享与归档 Research data standard format for analysis, sharing and archiving

07 数据可靠性与质量保障 Data Reliability & Quality Assurance

断点可续Resumable

蓝牙通道传序号与确认机制,会话中断后可继续,不重不漏。 The BLE channel uses sequence numbers and acknowledgements so interrupted sessions resume without duplication or loss.

断电保护Power-loss protection

周期性刷盘策略把断电数据损失控制在 1 秒以内;断电后文件系统结构保持可解析。 Periodic flush strategies bound power-loss exposure to under a second, and filesystem structures remain parseable after an unexpected outage.

坏帧可定位Locatable bad frames

帧内校验失败时能精确定位到具体帧序号,便于事后报告数据完整性。 Checksum failures resolve to a specific frame index, allowing data completeness to be reported after the fact.

完整性可报告Reportable integrity

元数据记录每个文件的帧计数;PC 端解析时逐一比对,直接产出"丢帧率"指标供论文方法学引用。 Metadata records a frame count per file; the PC parser cross-checks each one and emits a frame-loss metric ready for citation in a Methods section.

四条质量门控(硬件级):Four hardware-level quality gates: 除传输层的可靠性机制外,前端芯片本身提供四道数据质量门控——直流偏置诊断、内部标准电阻自检、导联脱落检测、佩戴唤醒检测。它们的输出写入 QUALITY 通道(0x70),成为数据集纳入/排除标准的客观依据。详见科研平台页。 Beyond transport-layer reliability, the front-end chip itself provides four data-quality gates — DC-offset diagnostics, internal reference self-test, lead-off detection and wear-on detection. Their outputs are written to the QUALITY channel (0x70) and serve as objective inclusion/exclusion criteria. See the Research Platform page.

08 实测数据与波形(可下载) Measured Data & Waveforms (Downloadable)

MAX86178 台架实录 · 原始 CSV 未做任何滤波 Recorded on a MAX86178 bench setup · raw CSV, no filtering applied

BioZ · 直流 0.5 V 恒压模式(实测 16.13 Hz) BioZ · DC 0.5 V constant-voltage mode (16.13 Hz measured)

Measured BioZ waveform in DC 0.5V constant-voltage mode, baseline-referenced, 50 s window

50 s 窗口 · 激励 1.41 µA(寄存器 0xA4=0xC5)· 显示为基线参考化 ΔZ。可见缓慢的电极稳定与低频漂移——0.5 V 直流体系的典型特征,科研团队可据此设计漂移补偿。 50 s window · excitation 1.41 µA (register 0xA4=0xC5) · shown baseline-referenced as ΔZ. The slow electrode settling and low-frequency drift are typical of the 0.5 V DC system — a useful basis for designing drift compensation.

文件File 内容Contents 时长Duration 实测采样率Measured Fs 大小Size
ecg-500hz-sample.csv ECG 单通道 + 14 行寄存器快照头 + UTC 毫秒时间戳single-channel ECG + 14-line register snapshot header + UTC ms timestamps 55.8 s516.21 Hz1.4 MB
ecg-1000hz-sample.csv 同上,高倍采样档same layout, high-rate tier 63.8 s1032.36 Hz3.2 MB
bioz-dc-16hz-sample.csv BioZ DC 0.5 V 单标量 + 寄存器快照(含 0xA2/0xA4 配置)BioZ DC 0.5 V scalar + register snapshot (incl. 0xA2/0xA4 config) 61.0 s16.13 Hz53 KB
ecg-500hz-rawframe.bin
bioz-dc-16hz-rawframe.bin
设备端原始帧存档(.bin),与 V3.0 帧型对应,供解析器开发比对device-side raw frame archives (.bin) matching the V3.0 frame types, for parser development ——97 / 4.6 KB
这批文件由评估样机实录,包含完整寄存器快照头与秒级 UTC 起始时间戳,可直接用本页 §06 的解析接口读取——下载后你的第一行解析代码应当能立即跑通。 These files were recorded on an evaluation unit and carry the full register-snapshot header and second-level UTC start timestamp. They load directly through the parsing API in §06 — your first lines of parsing code should run immediately after download.