Skip to content

Commit a09dd57

Browse files
authored
Merge pull request #3449 from alejoe91/ibl-extractor-pid
Improve IBL recording extractors by PID
2 parents b0c2bae + cba0f3b commit a09dd57

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/spikeinterface/extractors/iblextractors.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ def get_stream_names(eid: str, cache_folder: Optional[Union[Path, str]] = None,
105105
An instance of the ONE API to use for data loading.
106106
If not provided, a default instance is created using the default parameters.
107107
If you need to use a specific instance, you can create it using the ONE API and pass it here.
108+
stream_type : "ap" | "lf" | None, default: None
109+
The stream type to load, required when pid is provided and stream_name is not.
108110
109111
Returns
110112
-------
@@ -140,6 +142,7 @@ def __init__(
140142
remove_cached: bool = True,
141143
stream: bool = True,
142144
one: "one.api.OneAlyx" = None,
145+
stream_type: str | None = None,
143146
):
144147
try:
145148
from brainbox.io.one import SpikeSortingLoader
@@ -154,20 +157,24 @@ def __init__(
154157
one = IblRecordingExtractor._get_default_one(cache_folder=cache_folder)
155158

156159
if pid is not None:
160+
assert stream_type is not None, "When providing a PID, you must also provide a stream type."
157161
eid, _ = one.pid2eid(pid)
158-
159-
stream_names = IblRecordingExtractor.get_stream_names(eid=eid, cache_folder=cache_folder, one=one)
160-
if len(stream_names) > 1:
161-
assert (
162-
stream_name is not None
163-
), f"Multiple streams found for session. Please specify a stream name from {stream_names}."
164-
assert stream_name in stream_names, (
165-
f"The `stream_name` '{stream_name}' is not available for this experiment {eid}! "
166-
f"Please choose one of {stream_names}."
167-
)
162+
pids, probes = one.eid2pid(eid)
163+
pname = probes[pids.index(pid)]
164+
stream_name = f"{pname}.{stream_type}"
168165
else:
169-
stream_name = stream_names[0]
170-
pname, stream_type = stream_name.split(".")
166+
stream_names = IblRecordingExtractor.get_stream_names(eid=eid, cache_folder=cache_folder, one=one)
167+
if len(stream_names) > 1:
168+
assert (
169+
stream_name is not None
170+
), f"Multiple streams found for session. Please specify a stream name from {stream_names}."
171+
assert stream_name in stream_names, (
172+
f"The `stream_name` '{stream_name}' is not available for this experiment {eid}! "
173+
f"Please choose one of {stream_names}."
174+
)
175+
else:
176+
stream_name = stream_names[0]
177+
pname, stream_type = stream_name.split(".")
171178

172179
self.ssl = SpikeSortingLoader(one=one, eid=eid, pid=pid, pname=pname)
173180
if pid is None:

0 commit comments

Comments
 (0)