Skip to content

Commit f03e8fd

Browse files
Fix Smoothness examples and correct SPARC interpretation in documentation
1 parent ada3ede commit f03e8fd

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

docs/user_guide/theoretical_framework/low_level/smoothness.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ import numpy as np
121121

122122
# Initialize analyzer
123123
smoothness = Smoothness(rate_hz=100.0)
124-
window = SlidingWindow(window_size=200)
124+
window = SlidingWindow(max_length=200, n_columns=1)
125125

126-
# Add motion data (3D coordinates)
127-
for frame in motion_data:
128-
window.add_frame(frame)
126+
# Add motion data (velocity values)
127+
for value in motion_data:
128+
window.append([value])
129129

130130
if len(window) >= 5: # Minimum data requirement
131131
metrics = smoothness(window)
@@ -141,12 +141,15 @@ conditions = ['baseline', 'fatigue', 'recovery']
141141
smoothness_data = {}
142142

143143
for condition in conditions:
144-
data = load_condition_data(condition)
145-
metrics = smoothness(data)
144+
motion_data = load_condition_data(condition)
145+
window = SlidingWindow(max_length=200, n_columns=1)
146+
for value in motion_data:
147+
window.append([value])
148+
metrics = smoothness(window)
146149
smoothness_data[condition] = metrics['sparc']
147150

148-
# Lower SPARC values indicate smoother movement
149-
print(f"Smoothest condition: {min(smoothness_data, key=smoothness_data.get)}")
151+
# SPARC closer to 0 indicates smoother movement
152+
print(f"Smoothest condition: {max(smoothness_data, key=smoothness_data.get)}")
150153
```
151154

152155
## References

pyeyesweb/mid_level/smoothness.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ class Smoothness:
5252
--------
5353
>>> from pyeyesweb.mid_level.smoothness import Smoothness
5454
>>> from pyeyesweb.data_models.sliding_window import SlidingWindow
55+
>>> import numpy as np
56+
>>>
57+
>>> # Generate sample movement data (simulated velocity profile)
58+
>>> t = np.linspace(0, 2, 200)
59+
>>> movement_data = np.sin(2 * np.pi * t) + 0.1 * np.random.randn(200)
5560
>>>
5661
>>> smooth = Smoothness(rate_hz=100.0, use_filter=True)
5762
>>> window = SlidingWindow(max_length=200, n_columns=1)
@@ -65,7 +70,7 @@ class Smoothness:
6570
6671
Notes
6772
-----
68-
1. SPARC: More negative values indicate smoother movement
73+
1. SPARC: Values closer to 0 indicate smoother movement (less negative = smoother)
6974
2. Jerk RMS: Lower values indicate smoother movement
7075
3. Requires at least 5 samples for meaningful analysis
7176
@@ -109,7 +114,7 @@ def __call__(self, sliding_window: SlidingWindow):
109114
-------
110115
dict
111116
Dictionary containing:
112-
- 'sparc': Spectral Arc Length (more negative = smoother).
117+
- 'sparc': Spectral Arc Length (closer to 0 = smoother).
113118
Returns NaN if insufficient data.
114119
- 'jerk_rms': RMS of jerk (third derivative).
115120
Returns NaN if insufficient data.

0 commit comments

Comments
 (0)