Fola-lad commited on
Commit
0dd88b3
·
1 Parent(s): 710afb8

Add session-break detection and clearer recording instructions

Browse files
Files changed (1) hide show
  1. src/phyphox_app_block.py +18 -2
src/phyphox_app_block.py CHANGED
@@ -75,8 +75,9 @@ def render_phyphox_tab(
75
  1. Install [Phyphox](https://phyphox.org/) on your phone
76
  2. Open **Acceleration (with g)** and **Gyroscope**: record simultaneously
77
  3. Hold the phone at your waist (same position as the UCI dataset)
78
- 4. Record at least 3 seconds of a single activity
79
- 5. Export both experiments as CSV and upload below
 
80
  """)
81
 
82
  if "phyphox_run" not in st.session_state:
@@ -125,6 +126,21 @@ def render_phyphox_tab(
125
  return
126
  else:
127
  st.caption(f"Signal check: mean magnitude = {_mag:.2f} m/s² (gravity present)")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  except Exception:
129
  pass
130
 
 
75
  1. Install [Phyphox](https://phyphox.org/) on your phone
76
  2. Open **Acceleration (with g)** and **Gyroscope**: record simultaneously
77
  3. Hold the phone at your waist (same position as the UCI dataset)
78
+ 4. **Before recording:** tap the trash icon in Phyphox to clear any previous data
79
+ 5. Record 10–15 seconds of a single activity without pausing
80
+ 6. Export both experiments as CSV and upload below
81
  """)
82
 
83
  if "phyphox_run" not in st.session_state:
 
126
  return
127
  else:
128
  st.caption(f"Signal check: mean magnitude = {_mag:.2f} m/s² (gravity present)")
129
+
130
+ # Detect Phyphox pause/resume sessions: large gaps in the time column
131
+ # mean different activities were stitched together in one CSV.
132
+ _t = pd.to_numeric(_df["Time (s)"], errors="coerce").dropna().values
133
+ _gaps = np.diff(_t)
134
+ _expected_dt = np.median(_gaps)
135
+ _session_breaks = int(np.sum(_gaps > _expected_dt * 20))
136
+ if _session_breaks > 0:
137
+ st.warning(
138
+ f"**{_session_breaks} session break(s) detected** in this recording. "
139
+ "Phyphox accumulates data across pause/resume cycles — your CSV contains "
140
+ f"{_session_breaks + 1} separate recordings stitched together. "
141
+ "Only windows from a single activity will predict correctly. "
142
+ "To fix: tap the **trash icon** in Phyphox to clear data before each new recording."
143
+ )
144
  except Exception:
145
  pass
146