File size: 7,302 Bytes
180c67c
 
7684a18
 
 
180c67c
 
 
 
 
7684a18
53f3821
53f7fe6
7684a18
180c67c
 
 
aa62c5f
180c67c
7684a18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180c67c
7684a18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180c67c
 
 
7684a18
180c67c
 
 
7684a18
180c67c
7684a18
180c67c
7684a18
180c67c
 
 
 
 
 
 
 
 
7684a18
 
 
180c67c
 
53f3821
7684a18
 
 
 
180c67c
 
 
 
7684a18
180c67c
 
 
7684a18
 
180c67c
 
 
 
 
 
 
 
 
aa62c5f
180c67c
aa62c5f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Data quality

A small fraction of frames contain known sensor artifacts. The repo ships [`../bad_frames.json`](../bad_frames.json) as a skip-list so downstream code can avoid sampling on top of these intervals — important since this dataset is intended for **short-window dynamics / world-model learning**, where a glitch landing inside a training window can dominate the loss for that step.

> **All frame indices in `bad_frames.json` are in TRIMMED `.pt` coordinates.** The original H5 recordings have not been edited; only the published `.pt` files have had their OT-uninitialized prefixes cut (see [`caveats.md`](caveats.md) §OT track loss). The per-file trim offset is stored in `_contact_meta.trim_offset` inside each `.pt`.

## Headline numbers

| | |
|---|---:|
| Total synchronized frames (post-trim) | 190,231 (105.7 min @ 30 Hz) |
| Recording files | 27 |
| Frames flagged in `bad_frames.json` | **1,768 (0.929 %)** |
| Recording files with ≥ 1 flagged frame | 11 |

## Failure modes — quantitative breakdown

| # | Mode | Frames | % of dataset | Files | Symptom | Example |
|---|---|---:|---:|---:|---|---|
| 1 | **GelSight LED flicker** | 56 | **0.029 %** | 5 / 27 | 1–2 frames of uniform pink/magenta wash across the gel surface; adjacent frames normal. | [`intensity_spike_overview.png`](../figures/dataset_figures/intensity_spike_samples/intensity_spike_overview.png) |
| 2 | **OptiTrack pose teleport** | 56 | **0.029 %** | 3 / 27 | Translation velocity > 5 m/s **or** angular velocity > 15 rad/s in a single OT sample (solver flip — physically impossible for human-hand motion). | [`pose_teleport_samples/`](../figures/dataset_figures/pose_teleport_samples/) |
| 3 | **OptiTrack track loss** | 1,680 | **0.883 %** | 6 / 27 | Sensor pose held at a stale value for ≥ 0.25 s; cross-modal motion check confirms hand was actually moving. Cause: marker briefly left the mocap volume / camera FOV. | [`freeze_diagnose/`](../figures/dataset_figures/freeze_diagnose/) |

**Union of modes 1+2+3: 1,768 / 190,231 = 0.929 % of post-trim frames flagged.** Mode 3 is by far the largest — but it's already orders of magnitude smaller than what the *raw* recordings looked like (15 % of frames before the OT-uninitialized prefixes were trimmed). The remaining 0.88 % is genuine mid-episode mocap dropout that no amount of post-processing can recover.

## How to use the data — three recipes

### A. Easiest: the shipped example dataloader

`ReactWindowDataset` does the right thing out of the box. Just turn `skip_bad_frames=True`:

```python
from examples.react_window_dataset import ReactWindowDataset
from torch.utils.data import DataLoader

ds = ReactWindowDataset(
    data_root       = "processed/mode1_v1/motherboard",
    bad_frames_path = "bad_frames.json",
    tasks_json_path = "tasks.json",
    window_length   = 16,
    skip_bad_frames = True,    # ← drops windows touching ANY of modes 1/2/3
    respect_active_sensors = True,
)
```

Any window whose [t_start, t_end] range overlaps an `intensity_spikes` /
`pose_teleports_{L,R}` / `ot_loss_{L,R}` interval is silently dropped at
window-enumeration time, so your DataLoader never sees them.

### B. Loading a single `.pt` directly — DIY skip-list

If you're rolling your own sampler or scanning a single file:

```python
import json, torch

ep_key = "2026-05-11/episode_017"
ep = torch.load(f"processed/mode1_v1/motherboard/{ep_key}.pt", weights_only=False)
T = ep["view"].shape[0]
trim_offset = ep["_contact_meta"].get("trim_offset", 0)   # already applied to ep
bad = json.load(open("bad_frames.json"))["episodes"][ep_key]

# Build a per-frame boolean mask (True = drop)
import numpy as np
mask = np.zeros(T, dtype=bool)
for s_, e_ in (bad["intensity_spikes"]
               + bad["pose_teleports_L"] + bad["pose_teleports_R"]
               + bad["ot_loss_L"] + bad["ot_loss_R"]):
    mask[s_:e_ + 1] = True
print(f"{mask.sum()}/{T} flagged ({100 * mask.mean():.2f} %)")

# Then sample only clean windows:
def clean_window_start(t_start, win_len):
    return not mask[t_start:t_start + win_len].any()
```

### C. Only care about action labels (pose)? Skip just ot_loss

If your model treats vision + tactile as observations and sensor pose as the *action* label (UMI-style imitation learning), the LED flicker and translation teleports are observation-side noise that you can usually tolerate (single frames or short < 0.3 s spikes). The OT track losses are the one mode you *must* exclude, because the recorded "action" is stale:

```python
# Just the action-label cuts
def clean_pose_window(t_start, win_len, bad_ep):
    for s_, e_ in (bad_ep["ot_loss_L"] + bad_ep["ot_loss_R"]
                   + bad_ep["pose_teleports_L"] + bad_ep["pose_teleports_R"]):
        if s_ <= t_start + win_len - 1 and e_ >= t_start:
            return False
    return True
```

### What NOT to do

- Don't ignore `bad_frames.json` — for `ot_loss` intervals the *recorded pose looks plausible* (it's just a stale held value), but the actual sensor was moving. A model trained on those will learn that contact-rich tactile signals are uncorrelated with motion.
- Don't try to skip individual *frames* and stitch the rest — windows must be contiguous over time. Drop the **whole window**, not just the bad frames in it.

## Inspection figures

**Mode 1 — GelSight LED flicker** (overview across all affected files):

![Intensity spike overview](../figures/dataset_figures/intensity_spike_samples/intensity_spike_overview.png)

Per-file close-ups: [`figures/dataset_figures/intensity_spike_samples/`](../figures/dataset_figures/intensity_spike_samples/).

**Mode 2 — OptiTrack pose teleport.** GIFs (10 s playback at 2× speed) for all affected files: [`pose_teleport_samples/`](../figures/dataset_figures/pose_teleport_samples/).

**Mode 3 — OptiTrack track loss.** 15 sample clips (recording-viewer layout, 30 fps real time, red ring on the frozen-sensor projected dot): [`freeze_diagnose/ot_loss/`](../figures/dataset_figures/freeze_diagnose/ot_loss/).

## `bad_frames.json` schema

Frame indices are inclusive on both ends and pre-padded by `buffer_frames` (3) on each side so context windows don't bleed into the glitch:

```json
{
  "tau_intensity": 30.0,
  "tau_velocity_mps": 5.0,
  "tau_angular_rad_per_s": 15.0,
  "tau_opt_gap_s": 0.10,
  "freeze_threshold_s": 0.25,
  "buffer_frames": 3,
  "summary": {
    "n_episodes": 27,
    "total_frames": 190231,
    "total_bad_frames": 1768,
    "bad_fraction_overall": 0.009294,
    "n_episodes_with_bad_frames": 11
  },
  "episodes": {
    "2026-05-11/episode_003": {
      "n_frames": 10032,
      "duration_s": 334.4,
      "intensity_spikes": [[260, 268], "..."],
      "pose_teleports_L": [],
      "pose_teleports_R": [],
      "ot_loss_L": [],
      "ot_loss_R": [],
      "total_bad_frames": 19,
      "bad_fraction": 0.0019
    }
  }
}
```

A per-mode aggregate is also available: [`figures/dataset_figures/data_quality_breakdown.json`](../figures/dataset_figures/data_quality_breakdown.json).

## Full report (per-file CSV)

Every file's individual stats (frames, duration, contact %, max intensity left/right, drift, max pose velocity, etc.) are in [`figures/dataset_figures/data_quality_report.csv`](../figures/dataset_figures/data_quality_report.csv).