Skip to content

Commit 858b99f

Browse files
committed
fix: use actual array shapes for EMG/ADC display, only count ADC when channels exist
1 parent 8ce0f4a commit 858b99f

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

examples/joint_angle_regression/open_ephys_lsl_streamer.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ def _read_channels(ch_list):
465465
adc = adc_arr.T # (n_new, n_adc)
466466
n_samples = emg.shape[0]
467467
info["channels"] = n_emg
468+
info["emg_shape"] = emg.shape # (n_samples, n_emg)
469+
info["adc_shape"] = adc.shape # (n_samples, n_adc)
468470

469471
if n_samples <= 0:
470472
return info
@@ -499,7 +501,8 @@ def _read_channels(ch_list):
499501

500502
self.total_emg += n_samples
501503
self.total_imu += n_samples
502-
self.total_adc += n_samples
504+
if n_adc > 0:
505+
self.total_adc += n_samples
503506
self.last_chunk = n_samples
504507
if n_emg > 0:
505508
self.last_emg_rms = float(np.sqrt(np.mean(emg * emg)))
@@ -797,23 +800,22 @@ def _tick(self):
797800

798801
try:
799802
info = self.streamer.poll_once()
800-
ch = info["channels"]
801-
n_adc = info.get("n_adc", 0)
802-
chunk = info["chunk"]
803803
fs_str = f"{self.streamer.detected_fs:.0f}" if self.streamer.detected_fs > 0 else "?"
804804
hdr = f"{self.streamer._header_fs:.0f}" if self.streamer._header_fs > 0 else "?"
805805
meas = f"{self.streamer._measured_fs}" if self.streamer._measured_fs > 0 else "?"
806+
eshape = info.get("emg_shape", (0, 0))
807+
ashape = info.get("adc_shape", (0, 0))
806808
self.emg_shape.setText(
807-
f"EMG: {info['total_emg']:,} samples | chunk ({chunk}, {ch}) @ {fs_str} Hz"
809+
f"EMG: {info['total_emg']:,} samples | chunk {eshape} @ {fs_str} Hz"
808810
)
809811
self.adc_shape.setText(
810-
f"ADC: {info.get('total_adc', 0):,} samples | chunk ({chunk}, {n_adc})"
811-
if n_adc > 0 else "ADC: none"
812+
f"ADC: {info.get('total_adc', 0):,} samples | chunk {ashape}"
813+
if ashape[1] > 0 else "ADC: none"
812814
)
813815
self.rate.setText(
814816
f"Rate: {info['rate_hz']:.1f} Hz | fs: header={hdr} measured={meas}"
815817
)
816-
if chunk > 0:
818+
if info["chunk"] > 0:
817819
self.emg_stats.setText(
818820
f"EMG RMS: {info['emg_rms']:.3f} | \u03c3: {info['emg_std']:.3f}"
819821
)

0 commit comments

Comments
 (0)