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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ๐งช Lab Physiological Signal Dataset Hub
|
| 2 |
+
|
| 3 |
+
> **Organization**: `MultiModalSensing` on HuggingFace
|
| 4 |
+
> **Maintainer**: `@bc121381`
|
| 5 |
+
> **Last Updated**: 2026-04
|
| 6 |
+
> **Contact**: m.r.cui@utwente.nl
|
| 7 |
+
|
| 8 |
+
This repository defines the **unified data standard** for all physiological signal datasets managed by our lab. Every dataset uploaded to the organization must follow the schema and conventions described here.
|
| 9 |
+
|
| 10 |
---
|
| 11 |
+
|
| 12 |
+
## ๐ Repository Index
|
| 13 |
+
|
| 14 |
+
| Dataset | Modality | Sampling Rate | Task | Owner | Access |
|
| 15 |
+
|---------|----------|---------------|------|-------|--------|
|
| 16 |
+
| e.g. [mimic-waveforms](https://huggingface.co/datasets/your-lab-org/mimic-waveforms) | ECG / ABP / SpOโ | 125 Hz | Clinical monitoring | @member-name | ๐ Gated |
|
| 17 |
+
| e.g. [pamap2-activity](https://huggingface.co/datasets/your-lab-org/pamap2-activity) | IMU / HR / Temp | 100 Hz | Activity recognition | @member-name | โ
Public |
|
| 18 |
+
| *(add your dataset here after you submit to this space)* | | | | | |
|
| 19 |
+
|
| 20 |
+
> ๐ **Gated**: Requires PhysioNet credentialing or lab approval.
|
| 21 |
+
> โ
**Public**: Freely accessible within the organization.
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
## ๐ Unified Schema
|
| 26 |
+
|
| 27 |
+
All datasets share the following field definitions. Every sample (row) represents **one time-window segment** of a recording.
|
| 28 |
+
|
| 29 |
+
### Field Specification
|
| 30 |
+
|
| 31 |
+
| Field | Type | Required | Description |
|
| 32 |
+
|-------|------|----------|-------------|
|
| 33 |
+
| `signal` | `Sequence(Sequence(float32))` | โ
| Raw signal, shape `[n_channels, n_samples]` |
|
| 34 |
+
| `sampling_rate` | `float32` | โ
| Sampling frequency in Hz |
|
| 35 |
+
| `modality` | `string` | โ
| Signal type, e.g. `"EEG"`, `"ECG+PPG"`, `"IMU"` |
|
| 36 |
+
| `channel_names` | `Sequence(string)` | โ
| List of channel names, e.g. `["ECG_II", "ABP"]` |
|
| 37 |
+
| `n_channels` | `int32` | โ
| Number of channels |
|
| 38 |
+
| `n_samples` | `int32` | โ
| Number of time points per channel |
|
| 39 |
+
| `unit` | `string` | โ
| Physical unit(s), e.g. `"uV"`, `"mV+mmHg+%"` |
|
| 40 |
+
| `subject_id` | `string` | โ
| Anonymized subject identifier |
|
| 41 |
+
| `session_id` | `string` | โ
| Recording session identifier |
|
| 42 |
+
| `trial_id` | `string` | โ
| Segment identifier within session |
|
| 43 |
+
| `start_time_sec` | `float64` | โ
| Segment start time relative to recording onset (seconds) |
|
| 44 |
+
| `label` | `string` | โ
| Task label (see per-dataset definition) |
|
| 45 |
+
| `label_scheme` | `string` | โ
| Label semantics, e.g. `"sleep_stage"`, `"physical_activity"` |
|
| 46 |
+
| `extra` | `string` (JSON) | โ
| Additional metadata as JSON string (use `{}` if none) |
|
| 47 |
+
|
| 48 |
+
### HuggingFace Feature Definition
|
| 49 |
+
|
| 50 |
+
Copy this into your `convert.py` as the canonical feature spec:
|
| 51 |
+
|
| 52 |
+
```python
|
| 53 |
+
from datasets import Features, Sequence, Value
|
| 54 |
+
|
| 55 |
+
LAB_FEATURES = Features({
|
| 56 |
+
"signal": Sequence(Sequence(Value("float32"))),
|
| 57 |
+
"sampling_rate": Value("float32"),
|
| 58 |
+
"modality": Value("string"),
|
| 59 |
+
"channel_names": Sequence(Value("string")),
|
| 60 |
+
"n_channels": Value("int32"),
|
| 61 |
+
"n_samples": Value("int32"),
|
| 62 |
+
"unit": Value("string"),
|
| 63 |
+
"subject_id": Value("string"),
|
| 64 |
+
"session_id": Value("string"),
|
| 65 |
+
"trial_id": Value("string"),
|
| 66 |
+
"start_time_sec": Value("float64"),
|
| 67 |
+
"label": Value("string"),
|
| 68 |
+
"label_scheme": Value("string"),
|
| 69 |
+
"extra": Value("string"),
|
| 70 |
+
})
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
---
|
| 74 |
|
| 75 |
+
## ๐ Key Design Principles
|
| 76 |
+
|
| 77 |
+
### 1. Original Sampling Rate is Always Preserved
|
| 78 |
+
|
| 79 |
+
Do **not** resample during dataset creation. Store signals at their native sampling rate. Resampling is done at load time, per experiment requirements.
|
| 80 |
+
|
| 81 |
+
```
|
| 82 |
+
โ
Store at native rate โ resample in DataLoader
|
| 83 |
+
โ Do not permanently downsample/upsample the stored data
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
### 2. Channel Names, Not Positions
|
| 87 |
+
|
| 88 |
+
Always use `channel_names` for indexing. Never assume a channel exists at a fixed index position across datasets.
|
| 89 |
+
|
| 90 |
+
```python
|
| 91 |
+
# โ
Correct
|
| 92 |
+
idx = sample["channel_names"].index("ECG_II")
|
| 93 |
+
ecg = np.array(sample["signal"])[idx]
|
| 94 |
+
|
| 95 |
+
# โ Wrong
|
| 96 |
+
ecg = np.array(sample["signal"])[0] # position may differ across datasets
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
### 3. Label Semantics Are Dataset-Specific
|
| 100 |
+
|
| 101 |
+
The same `label` value (e.g., `"1"`) may mean different things across datasets. Always use `label` together with `label_scheme`.
|
| 102 |
+
|
| 103 |
+
```python
|
| 104 |
+
{"label": "1", "label_scheme": "sleep_stage"} # โ N1 sleep
|
| 105 |
+
{"label": "1", "label_scheme": "physical_activity"} # โ sitting
|
| 106 |
+
{"label": "1", "label_scheme": "arrhythmia"} # โ AFib
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
### 4. Extend with `extra`, Don't Break the Schema
|
| 110 |
+
|
| 111 |
+
Dataset-specific metadata that doesn't fit the common fields goes into the `extra` JSON string field. This keeps the schema stable while allowing flexibility.
|
| 112 |
+
|
| 113 |
+
```python
|
| 114 |
+
import json
|
| 115 |
+
|
| 116 |
+
extra = json.dumps({
|
| 117 |
+
"age": 67,
|
| 118 |
+
"gender": "M",
|
| 119 |
+
"icu_type": "MICU",
|
| 120 |
+
"filter_applied": "0.5-40Hz bandpass",
|
| 121 |
+
})
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
+
---
|
| 125 |
+
|
| 126 |
+
## ๐ Directory Structure
|
| 127 |
+
|
| 128 |
+
Each dataset repository follows this structure:
|
| 129 |
+
|
| 130 |
+
```
|
| 131 |
+
MultiModalSensing/<dataset-name>/
|
| 132 |
+
โโโ train/
|
| 133 |
+
โ โโโ data-00000-of-00002.parquet
|
| 134 |
+
โ โโโ data-00001-of-00002.parquet
|
| 135 |
+
โโโ validation/
|
| 136 |
+
โ โโโ data-00000-of-00001.parquet
|
| 137 |
+
โโโ test/
|
| 138 |
+
โ โโโ data-00000-of-00001.parquet
|
| 139 |
+
โโโ README.md โ Dataset Card (required)
|
| 140 |
+
โโโ convert.py โ Conversion script (required, for reproducibility)
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
---
|
| 144 |
+
|
| 145 |
+
## ๐ How to Load Datasets
|
| 146 |
+
|
| 147 |
+
### Basic Loading
|
| 148 |
+
|
| 149 |
+
```python
|
| 150 |
+
from datasets import load_dataset
|
| 151 |
+
import numpy as np
|
| 152 |
+
|
| 153 |
+
# Load any lab dataset with the same interface
|
| 154 |
+
ds = load_dataset("your-lab-org/pamap2-activity", split="train")
|
| 155 |
+
|
| 156 |
+
sample = ds[0]
|
| 157 |
+
signal = np.array(sample["signal"]) # shape: (n_channels, n_samples)
|
| 158 |
+
sr = sample["sampling_rate"] # e.g. 100.0
|
| 159 |
+
chs = sample["channel_names"] # e.g. ["acc_x", "acc_y", ...]
|
| 160 |
+
label = sample["label"] # e.g. "running"
|
| 161 |
+
```
|
| 162 |
+
|
| 163 |
+
### Using the Shared Loader (Recommended)
|
| 164 |
+
|
| 165 |
+
Install the lab utility package and use the unified loader, which handles resampling and channel selection automatically:
|
| 166 |
+
|
| 167 |
+
```python
|
| 168 |
+
# pip install git+https://github.com/MultiModalSensing/lab-utils.git
|
| 169 |
+
from lab_utils import load_lab_dataset
|
| 170 |
+
|
| 171 |
+
# Load with optional resampling and channel selection
|
| 172 |
+
ds = load_lab_dataset(
|
| 173 |
+
name = "pamap2-activity",
|
| 174 |
+
split = "train",
|
| 175 |
+
channels = ["acc_x", "acc_y", "acc_z"], # select channels by name
|
| 176 |
+
)
|
| 177 |
+
|
| 178 |
+
# Returns {"x": np.ndarray, "y": str, "sr": float}
|
| 179 |
+
sample = ds[0]
|
| 180 |
+
print(sample["x"].shape) # (3, n_samples)
|
| 181 |
+
```
|
| 182 |
+
|
| 183 |
+
### Accessing Gated Datasets (e.g., MIMIC)
|
| 184 |
+
|
| 185 |
+
```bash
|
| 186 |
+
# Step 1: Log in to HuggingFace
|
| 187 |
+
huggingface-cli login
|
| 188 |
+
|
| 189 |
+
# Step 2: Request access via the dataset page (one-time)
|
| 190 |
+
# https://huggingface.co/datasets/your-lab-org/mimic-waveforms
|
| 191 |
+
```
|
| 192 |
+
|
| 193 |
+
```python
|
| 194 |
+
# Step 3: Load as normal (authentication handled automatically)
|
| 195 |
+
ds = load_dataset("your-lab-org/mimic-waveforms", split="train")
|
| 196 |
+
```
|
| 197 |
+
|
| 198 |
+
---
|
| 199 |
+
|
| 200 |
+
## โ How to Contribute a New Dataset
|
| 201 |
+
|
| 202 |
+
Follow these 4 steps to add your dataset to the organization.
|
| 203 |
+
|
| 204 |
+
### Step 1: Write `convert.py`
|
| 205 |
+
|
| 206 |
+
Use the template below and adapt to your raw data format:
|
| 207 |
+
|
| 208 |
+
```python
|
| 209 |
+
"""
|
| 210 |
+
convert.py โ Template for lab dataset conversion
|
| 211 |
+
Replace all <PLACEHOLDERS> with your dataset's specifics.
|
| 212 |
+
"""
|
| 213 |
+
|
| 214 |
+
import json
|
| 215 |
+
import numpy as np
|
| 216 |
+
import pandas as pd
|
| 217 |
+
from datasets import Dataset
|
| 218 |
+
from lab_schema import LAB_FEATURES # import from lab-utils
|
| 219 |
+
|
| 220 |
+
DATASET_NAME = "<your-dataset-name>"
|
| 221 |
+
MODALITY = "<EEG|ECG|IMU|PPG|...>"
|
| 222 |
+
CHANNEL_NAMES = ["<ch1>", "<ch2>"] # full list of channels
|
| 223 |
+
SAMPLING_RATE = <Hz> # native sampling rate (float)
|
| 224 |
+
UNIT = "<uV|mV|m/s2|...>"
|
| 225 |
+
LABEL_SCHEME = "<sleep_stage|physical_activity|arrhythmia|...>"
|
| 226 |
+
WINDOW_SEC = 5.0 # window length in seconds
|
| 227 |
+
OVERLAP_SEC = 2.5 # overlap between windows
|
| 228 |
+
|
| 229 |
+
LABEL_MAP = {
|
| 230 |
+
<raw_label_value>: "<semantic_label>",
|
| 231 |
+
# e.g. 1: "walking", 2: "running", ...
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
def segment(signal_2d, sr, window_sec, overlap_sec):
|
| 235 |
+
"""Sliding window segmentation. signal_2d: (n_channels, n_total_samples)"""
|
| 236 |
+
win = int(window_sec * sr)
|
| 237 |
+
step = int((window_sec - overlap_sec) * sr)
|
| 238 |
+
segs = []
|
| 239 |
+
for start in range(0, signal_2d.shape[1] - win + 1, step):
|
| 240 |
+
segs.append(signal_2d[:, start:start + win])
|
| 241 |
+
return segs # list of (n_channels, win) arrays
|
| 242 |
+
|
| 243 |
+
def convert_subject(raw_path, subject_id):
|
| 244 |
+
"""Load one subject's raw file and return a list of sample dicts."""
|
| 245 |
+
# โโ load raw data โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 246 |
+
df = pd.read_csv(raw_path) # adapt as needed
|
| 247 |
+
|
| 248 |
+
signal_2d = df[CHANNEL_NAMES].values.T.astype(np.float32)
|
| 249 |
+
labels_ts = df["label"].values # one label per time step
|
| 250 |
+
|
| 251 |
+
segments = segment(signal_2d, SAMPLING_RATE, WINDOW_SEC, OVERLAP_SEC)
|
| 252 |
+
win = int(WINDOW_SEC * SAMPLING_RATE)
|
| 253 |
+
|
| 254 |
+
samples = []
|
| 255 |
+
for i, seg in enumerate(segments):
|
| 256 |
+
start_sample = i * int((WINDOW_SEC - OVERLAP_SEC) * SAMPLING_RATE)
|
| 257 |
+
window_labels = labels_ts[start_sample : start_sample + win]
|
| 258 |
+
majority_label = LABEL_MAP.get(
|
| 259 |
+
pd.Series(window_labels).mode()[0], "unknown"
|
| 260 |
+
)
|
| 261 |
+
|
| 262 |
+
samples.append({
|
| 263 |
+
"signal": seg.tolist(),
|
| 264 |
+
"sampling_rate": float(SAMPLING_RATE),
|
| 265 |
+
"modality": MODALITY,
|
| 266 |
+
"channel_names": CHANNEL_NAMES,
|
| 267 |
+
"n_channels": seg.shape[0],
|
| 268 |
+
"n_samples": seg.shape[1],
|
| 269 |
+
"unit": UNIT,
|
| 270 |
+
"subject_id": str(subject_id),
|
| 271 |
+
"session_id": "session_1",
|
| 272 |
+
"trial_id": f"segment_{i:06d}",
|
| 273 |
+
"start_time_sec": round(start_sample / SAMPLING_RATE, 6),
|
| 274 |
+
"label": majority_label,
|
| 275 |
+
"label_scheme": LABEL_SCHEME,
|
| 276 |
+
"extra": json.dumps({}), # add subject metadata here
|
| 277 |
+
})
|
| 278 |
+
return samples
|
| 279 |
+
|
| 280 |
+
if __name__ == "__main__":
|
| 281 |
+
all_samples = []
|
| 282 |
+
for subject_id in range(1, 10): # adapt to your subject list
|
| 283 |
+
all_samples += convert_subject(f"data/subject{subject_id}.csv", subject_id)
|
| 284 |
+
|
| 285 |
+
ds = Dataset.from_list(all_samples, features=LAB_FEATURES)
|
| 286 |
+
# Optional: train/val/test split
|
| 287 |
+
ds = ds.train_test_split(test_size=0.2, seed=42)
|
| 288 |
+
ds.push_to_hub(f"your-lab-org/{DATASET_NAME}")
|
| 289 |
+
print(f"โ
Uploaded {len(all_samples)} samples to your-lab-org/{DATASET_NAME}")
|
| 290 |
+
```
|
| 291 |
+
|
| 292 |
+
### Step 2: Create a Dataset Card (`README.md`)
|
| 293 |
+
|
| 294 |
+
Every dataset repo must have a `README.md` using the template in the section below.
|
| 295 |
+
|
| 296 |
+
### Step 3: Push to Hub
|
| 297 |
+
|
| 298 |
+
```bash
|
| 299 |
+
huggingface-cli login
|
| 300 |
+
|
| 301 |
+
# Public dataset
|
| 302 |
+
python convert.py
|
| 303 |
+
|
| 304 |
+
# Private / gated dataset (e.g., MIMIC, clinical data)
|
| 305 |
+
python convert.py --private # or set via HF web UI after upload
|
| 306 |
+
```
|
| 307 |
+
|
| 308 |
+
### Step 4: Register in the Index
|
| 309 |
+
|
| 310 |
+
Open a PR to this README and add your dataset to the **Repository Index** table at the top.
|
| 311 |
+
|
| 312 |
+
---
|
| 313 |
+
|
| 314 |
+
## ๐ Dataset Card Template
|
| 315 |
+
|
| 316 |
+
Copy this into your dataset's `README.md`:
|
| 317 |
+
|
| 318 |
+
```markdown
|
| 319 |
+
---
|
| 320 |
+
dataset_name: <your-dataset-name>
|
| 321 |
+
modality: <EEG|ECG|IMU|PPG|...>
|
| 322 |
+
sampling_rate: <Hz>
|
| 323 |
+
n_channels: <N>
|
| 324 |
+
task: <sleep_staging|activity_recognition|arrhythmia_detection|...>
|
| 325 |
+
label_scheme: <scheme_name>
|
| 326 |
+
n_subjects: <N>
|
| 327 |
+
version: 1.0.0
|
| 328 |
+
license: <cc-by-4.0|physionet-1.5|internal>
|
| 329 |
+
---
|
| 330 |
+
|
| 331 |
+
## Overview
|
| 332 |
+
|
| 333 |
+
Brief description of the dataset: source, purpose, key characteristics.
|
| 334 |
+
|
| 335 |
+
## Source
|
| 336 |
+
|
| 337 |
+
- **Original dataset**: [Name](URL)
|
| 338 |
+
- **Paper**: citation
|
| 339 |
+
- **Access**: Public / Gated / Internal
|
| 340 |
+
|
| 341 |
+
## Modality & Channels
|
| 342 |
+
|
| 343 |
+
| Index | Channel Name | Unit | Description |
|
| 344 |
+
|-------|-------------|------|-------------|
|
| 345 |
+
| 0 | `<ch_name>` | uV | <description> |
|
| 346 |
+
|
| 347 |
+
## Label Definition
|
| 348 |
+
|
| 349 |
+
| label | meaning |
|
| 350 |
+
|-------|---------|
|
| 351 |
+
| `"0"` | <class 0> |
|
| 352 |
+
| `"1"` | <class 1> |
|
| 353 |
+
|
| 354 |
+
**label_scheme**: `<scheme_name>`
|
| 355 |
+
|
| 356 |
+
## Splits
|
| 357 |
+
|
| 358 |
+
| Split | Subjects | Segments |
|
| 359 |
+
|------------|----------|----------|
|
| 360 |
+
| train | X | X |
|
| 361 |
+
| validation | X | X |
|
| 362 |
+
| test | X | X |
|
| 363 |
+
|
| 364 |
+
## Preprocessing
|
| 365 |
+
|
| 366 |
+
Describe all transformations applied before storage:
|
| 367 |
+
- Filtering: (e.g., 0.5โ40 Hz bandpass, 50 Hz notch)
|
| 368 |
+
- Normalization: (e.g., z-score per channel per recording)
|
| 369 |
+
- Windowing: X-second windows, Y-second overlap
|
| 370 |
+
- Resampling: original rate โ stored rate
|
| 371 |
+
|
| 372 |
+
> โ ๏ธ Raw data is stored at its **native sampling rate**. Resample in your DataLoader as needed.
|
| 373 |
+
|
| 374 |
+
## Known Issues / Limitations
|
| 375 |
+
|
| 376 |
+
- List any known data quality issues
|
| 377 |
+
- Missing subjects, artifact channels, etc.
|
| 378 |
+
|
| 379 |
+
## Citation
|
| 380 |
+
|
| 381 |
+
\`\`\`bibtex
|
| 382 |
+
@dataset{...}
|
| 383 |
+
\`\`\`
|
| 384 |
+
```
|
| 385 |
+
|
| 386 |
+
---
|
| 387 |
+
|
| 388 |
+
## โ๏ธ Naming Conventions
|
| 389 |
+
|
| 390 |
+
| Entity | Convention | Example |
|
| 391 |
+
|--------|-----------|---------|
|
| 392 |
+
| Dataset repo name | `<source>-<modality>` (lowercase, hyphen) | `mimic-waveforms`, `pamap2-activity` |
|
| 393 |
+
| `subject_id` | `subject<NNN>` or original ID string | `subject101`, `p10032` |
|
| 394 |
+
| `session_id` | `session_<N>` or protocol name | `session_1`, `protocol_run2` |
|
| 395 |
+
| `trial_id` | `segment_<NNNNNN>` (zero-padded) | `segment_000042` |
|
| 396 |
+
| `modality` | Uppercase, `+` separator for multi-modal | `EEG`, `ECG+PPG`, `IMU+HR` |
|
| 397 |
+
| `label_scheme` | lowercase, underscore | `sleep_stage`, `physical_activity` |
|
| 398 |
+
|
| 399 |
+
---
|
| 400 |
+
|
| 401 |
+
## ๐ Access Control Guidelines
|
| 402 |
+
|
| 403 |
+
| Data Type | HuggingFace Setting | Notes |
|
| 404 |
+
|-----------|---------------------|-------|
|
| 405 |
+
| Public benchmark (PAMAP2, etc.) | `public` | Fine to share openly |
|
| 406 |
+
| PhysioNet data (MIMIC, etc.) | `gated` | Require PhysioNet credentialing |
|
| 407 |
+
| Proprietary / in-house data | `private` | Lab members only; get PI approval |
|
| 408 |
+
| De-identified clinical data | `private` or `gated` | Check IRB terms before uploading |
|
| 409 |
+
|
| 410 |
+
> โ ๏ธ **Never upload identifiable patient data.** When in doubt, contact the lab PI before uploading.
|
| 411 |
+
|
| 412 |
+
---
|
| 413 |
+
|
| 414 |
+
## ๐ ๏ธ Common Recipes
|
| 415 |
+
|
| 416 |
+
### Resample a loaded dataset to a target frequency
|
| 417 |
+
|
| 418 |
+
```python
|
| 419 |
+
import scipy.signal as ss
|
| 420 |
+
import numpy as np
|
| 421 |
+
|
| 422 |
+
def resample_sample(sample, target_sr):
|
| 423 |
+
sig = np.array(sample["signal"])
|
| 424 |
+
orig_sr = sample["sampling_rate"]
|
| 425 |
+
if orig_sr == target_sr:
|
| 426 |
+
return sample
|
| 427 |
+
n_target = int(sig.shape[-1] * target_sr / orig_sr)
|
| 428 |
+
sig_resampled = ss.resample(sig, n_target, axis=-1)
|
| 429 |
+
return {**sample, "signal": sig_resampled.tolist(),
|
| 430 |
+
"sampling_rate": target_sr, "n_samples": n_target}
|
| 431 |
+
|
| 432 |
+
ds = ds.map(lambda x: resample_sample(x, target_sr=100))
|
| 433 |
+
```
|
| 434 |
+
|
| 435 |
+
### Select specific channels by name
|
| 436 |
+
|
| 437 |
+
```python
|
| 438 |
+
def select_channels(sample, channel_list):
|
| 439 |
+
chs = sample["channel_names"]
|
| 440 |
+
idx = [chs.index(c) for c in channel_list]
|
| 441 |
+
sig = np.array(sample["signal"])[idx]
|
| 442 |
+
return {**sample, "signal": sig.tolist(),
|
| 443 |
+
"channel_names": channel_list, "n_channels": len(channel_list)}
|
| 444 |
+
|
| 445 |
+
ds = ds.map(lambda x: select_channels(x, ["acc_x", "acc_y", "acc_z"]))
|
| 446 |
+
```
|
| 447 |
+
|
| 448 |
+
### Parse `extra` metadata
|
| 449 |
+
|
| 450 |
+
```python
|
| 451 |
+
import json
|
| 452 |
+
|
| 453 |
+
extras = [json.loads(s["extra"]) for s in ds]
|
| 454 |
+
ages = [e.get("age") for e in extras]
|
| 455 |
+
```
|
| 456 |
+
|
| 457 |
+
---
|
| 458 |
+
|
| 459 |
+
## ๐ฌ Questions & Contributions
|
| 460 |
+
|
| 461 |
+
- **Bug / schema issue**: Open an issue in `MultiModalSensing/lab-utils`
|
| 462 |
+
- **New dataset**: Follow the contribution steps above and open a PR to this README
|
| 463 |
+
- **Access request**: Email `m.r.cui@utwente.nl` with your HuggingFace username
|