Fola-lad commited on
Commit
7dda26b
·
1 Parent(s): 52f360c

Fix accelerometer unit conversion: divide Phyphox m/s² by 9.80665 to match UCI g units

Browse files
src/phyphox_app_block.py CHANGED
@@ -130,8 +130,8 @@ def render_phyphox_tab(
130
  min_vals, max_vals = _load_norm_params(norm_params_path)
131
  features = _normalize(features, min_vals, max_vals)
132
  st.caption(
133
- "Features scaled to [−1, 1] using per-feature min/max from the UCI HAR "
134
- "training set. Values outside the training range are clipped before scaling."
135
  )
136
  else:
137
  st.warning(
 
130
  min_vals, max_vals = _load_norm_params(norm_params_path)
131
  features = _normalize(features, min_vals, max_vals)
132
  st.caption(
133
+ "Accelerometer converted from m/s² to g units to match UCI training data. "
134
+ "Features scaled to [−1, 1] using per-feature min/max from the UCI HAR training set."
135
  )
136
  else:
137
  st.warning(
src/phyphox_pipeline.py CHANGED
@@ -427,9 +427,10 @@ def process_phyphox_files(
427
 
428
  Pipeline:
429
  1. Parse + validate both CSVs
430
- 2. Interpolate onto common 50 Hz grid
431
- 3. Segment: 128-sample windows, 64-sample hop (50% overlap)
432
- 4. Per window: median filter → 20 Hz Butterworth → gravity separation
 
433
  at 0.3 Hz → jerk → magnitudes → 561 features
434
 
435
  Args:
@@ -452,7 +453,7 @@ def process_phyphox_files(
452
  gyro_df = _parse_csv(gyro_file, GYRO_COLS)
453
 
454
  acc_t = acc_df["Time (s)"].values
455
- acc_xyz = acc_df[["X (m/s^2)", "Y (m/s^2)", "Z (m/s^2)"]].values
456
  gyro_t = gyro_df["Time (s)"].values
457
  gyro_xyz = gyro_df[["X (rad/s)", "Y (rad/s)", "Z (rad/s)"]].values
458
 
 
427
 
428
  Pipeline:
429
  1. Parse + validate both CSVs
430
+ 2. Convert accelerometer from m/s² to g (÷ 9.80665) to match UCI training units
431
+ 3. Interpolate onto common 50 Hz grid
432
+ 4. Segment: 128-sample windows, 64-sample hop (50% overlap)
433
+ 5. Per window: median filter → 20 Hz Butterworth → gravity separation
434
  at 0.3 Hz → jerk → magnitudes → 561 features
435
 
436
  Args:
 
453
  gyro_df = _parse_csv(gyro_file, GYRO_COLS)
454
 
455
  acc_t = acc_df["Time (s)"].values
456
+ acc_xyz = acc_df[["X (m/s^2)", "Y (m/s^2)", "Z (m/s^2)"]].values / 9.80665 # m/s² → g
457
  gyro_t = gyro_df["Time (s)"].values
458
  gyro_xyz = gyro_df[["X (rad/s)", "Y (rad/s)", "Z (rad/s)"]].values
459