Skip to content

Commit ab1046a

Browse files
committed
Stimulator: scan ALL underlying epochprobemaps for channels
MATLAB's getchanneldevinfo iterates ALL epochprobemaps in the underlying epoch and extracts channels from every matching one. The Python version only looked at the single matching epm stored in the probe's epoch table entry. Also print all underlying epochprobemaps and their devicestrings in the test diagnostic to understand what channels are available. https://claude.ai/code/session_01A7rAxYf5pSvs19iVJe3ncL
1 parent 46782ea commit ab1046a

2 files changed

Lines changed: 31 additions & 10 deletions

File tree

src/ndi/probe/timeseries_stimulator.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,27 @@ def getchanneldevinfo(
431431
if dev is None:
432432
return None
433433

434-
# Get channel info from the epochprobemap's devicestring
435-
epms = base_info.get("epochprobemap", [])
434+
# Get channel info from ALL epochprobemaps in the underlying epoch
435+
# that match this probe. MATLAB iterates all maps in the underlying
436+
# epoch and extracts channels from every matching one.
437+
et, _ = self.epochtable()
438+
entry = et[epoch - 1] if isinstance(epoch, int) and epoch <= len(et) else None
439+
underlying = entry.get("underlying_epochs", {}) if entry else {}
440+
all_epms = underlying.get("epochprobemap", base_info.get("epochprobemap", []))
441+
if not isinstance(all_epms, list):
442+
all_epms = [all_epms]
443+
436444
channeltype = []
437445
channel = []
438446

439-
for epm in epms:
447+
for epm in all_epms:
448+
if not self.epochprobemapmatch(epm):
449+
continue
440450
if hasattr(epm, "devicestring") and epm.devicestring:
451+
logger.debug(
452+
"stimulator: matched epm devicestring='%s'",
453+
epm.devicestring,
454+
)
441455
try:
442456
from ..daq.daqsystemstring import ndi_daq_daqsystemstring
443457

tests/test_cloud_read_ingested.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,20 @@ def test_stimulator_probe_timeseries(self, session):
283283
ch = devinfo.get("channel", [])
284284
print(f" dev={type(dev).__name__}, devepoch={devepoch}")
285285
print(f" channeltype={ct}, channel={ch}")
286-
# Print the epochprobemap devicestring
287-
et, _ = stim.epochtable()
288-
if et:
289-
entry_epm = et[0].get("epochprobemap", [])
290-
for m in (entry_epm if isinstance(entry_epm, list) else [entry_epm]):
291-
if hasattr(m, "devicestring"):
292-
print(f" devicestring: {m.devicestring}")
286+
# Print ALL epochprobemaps from underlying epoch
287+
et_stim, _ = stim.epochtable()
288+
if et_stim:
289+
underlying = et_stim[0].get("underlying_epochs", {})
290+
all_epms = underlying.get("epochprobemap", [])
291+
if not isinstance(all_epms, list):
292+
all_epms = [all_epms]
293+
print(f" underlying epochprobemaps count: {len(all_epms)}")
294+
for i, m in enumerate(all_epms):
295+
ds = getattr(m, "devicestring", "?")
296+
nm = getattr(m, "name", "?")
297+
print(f" epm[{i}]: name={nm} devicestring={ds}")
298+
match = stim.epochprobemapmatch(m) if hasattr(stim, "epochprobemapmatch") else "?"
299+
print(f" matches this probe: {match}")
293300

294301
# Try readevents directly to see the error
295302
if dev is not None and ct:

0 commit comments

Comments
 (0)