Skip to content

Commit 986f262

Browse files
committed
add test and define new metadata
1 parent 6e1a5b5 commit 986f262

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

neo/rawio/spikeglxrawio.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,17 +376,26 @@ def get_probe_tuple(info):
376376
dock = normalize(info.get("probe_dock"))
377377
return (slot, port, dock)
378378

379-
unique_probe_tuples = {get_probe_tuple(info) for info in info_list}
379+
info_list_imec = [info for info in info_list if info.get("device") != "nidq"]
380+
unique_probe_tuples = {get_probe_tuple(info) for info in info_list_imec}
380381
sorted_probe_keys = sorted(unique_probe_tuples)
381382
probe_tuple_to_probe_index = {key: idx for idx, key in enumerate(sorted_probe_keys)}
382383

383384
for info in info_list:
384385
if info.get("device") == "nidq":
385-
info["device_index"] = 0 # TODO: Handle multi nidq case
386+
info["device_index"] = "" # TODO: Handle multi nidq case, maybe use meta["typeNiEnabled"]
386387
else:
387388
info["device_index"] = probe_tuple_to_probe_index[get_probe_tuple(info)]
388389

390+
# Define stream base on device [imec|nidq], device_index and stream_kind [ap|lf] for imec
391+
for info in info_list:
392+
device_kind = info["device_kind"]
393+
device_index = info["device_index"]
394+
stream_kind = f".{info['stream_kind']}" if info["stream_kind"] else ""
395+
stream_name = f"{device_kind}{device_index}{stream_kind}"
389396

397+
info["stream_name"] = stream_name
398+
390399
return info_list
391400

392401

@@ -513,7 +522,6 @@ def extract_stream_info(meta_file, meta):
513522
if "imec" in fname.split(".")[-2]:
514523
device = fname.split(".")[-2]
515524
stream_kind = fname.split(".")[-1]
516-
stream_name = device + "." + stream_kind
517525
units = "uV"
518526
# please note the 1e6 in gain for this uV
519527

@@ -553,7 +561,6 @@ def extract_stream_info(meta_file, meta):
553561
else:
554562
device = fname.split(".")[-1]
555563
stream_kind = ""
556-
stream_name = device
557564
units = "V"
558565
channel_gains = np.ones(num_chan)
559566

@@ -586,7 +593,7 @@ def extract_stream_info(meta_file, meta):
586593
info["trigger_num"] = trigger_num
587594
info["device"] = device
588595
info["stream_kind"] = stream_kind
589-
info["stream_name"] = stream_name
596+
info["device_kind"] = meta.get("typeThis", device.split(".")[0])
590597
info["units"] = units
591598
info["channel_names"] = [txt.split(";")[0] for txt in meta["snsChanMap"]]
592599
info["channel_gains"] = channel_gains

neo/test/rawiotest/test_spikeglxrawio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class TestSpikeGLXRawIO(BaseTestRawIO, unittest.TestCase):
3232
"spikeglx/NP2_subset_with_sync",
3333
# NP-ultra
3434
"spikeglx/np_ultra_stub",
35+
# Filename changed by the user, multi-dock
36+
"spikeglx/multi_probe_multi_dock_multi_shank_filename_without_info",
3537
# CatGT
3638
"spikeglx/multi_trigger_multi_gate/CatGT/CatGT-A",
3739
"spikeglx/multi_trigger_multi_gate/CatGT/CatGT-B",

0 commit comments

Comments
 (0)