Skip to content

Commit d452bdb

Browse files
Fix: Return NaN instead of None for errors and remove print statements from Smoothness
1 parent 67d324a commit d452bdb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pyeyesweb/mid_level/smoothness.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,24 @@ def __call__(self, sliding_window: SlidingWindow):
111111
RMS of jerk (third derivative).
112112
Returns None if insufficient data.
113113
114-
Output
115-
------------
116-
Prints smoothness metrics to stdout.
114+
Returns
115+
-------
116+
tuple of (float, float)
117+
(SPARC value, Jerk RMS value) or (NaN, NaN) if insufficient data.
117118
"""
118119
if len(sliding_window) < 5:
119-
return None, None
120+
return float("nan"), float("nan")
120121

121122
signal, _ = sliding_window.to_array()
122123

124+
# If multi-channel, compute for first channel only
125+
if signal.ndim > 1 and signal.shape[1] > 1:
126+
signal = signal[:, 0]
127+
123128
filtered = self._filter_signal(signal.squeeze())
124129
normalized = normalize_signal(filtered)
125130

126131
sparc = compute_sparc(normalized, self.rate_hz)
127132
jerk = compute_jerk_rms(filtered, self.rate_hz)
128133

129-
print(f"SPARC: {sparc:.3f}, Jerk RMS: {jerk:.3f}")
130134
return sparc, jerk

0 commit comments

Comments
 (0)