Skip to content

Commit 60e84cc

Browse files
authored
Merge branch 'main' into ruff-test
2 parents 0e61521 + 697058e commit 60e84cc

3 files changed

Lines changed: 24 additions & 20 deletions

File tree

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ extractors = [
7272
"sonpy;python_version<'3.10'",
7373
"lxml", # lxml for neuroscope
7474
"scipy",
75-
"ONE-api>=2.7.0", # alf sorter and streaming IBL
76-
"ibllib>=2.36.0", # streaming IBL
75+
"ONE-api>=2.7.0,<3.0.0", # alf sorter and streaming IBL
76+
"ibllib>=2.36.0,<3.0.0", # streaming IBL
7777
"pymatreader>=0.0.32", # For cell explorer matlab files
7878
"zugbruecke>=0.2; sys_platform!='win32'", # For plexon2
7979
]
8080

8181
streaming_extractors = [
82-
"ONE-api>=2.7.0,<2.10.0", # alf sorter and streaming IBL
83-
"ibllib>=2.36.0", # streaming IBL
82+
"ONE-api>=2.7.0,<3.0.0", # alf sorter and streaming IBL
83+
"ibllib>=2.36.0,<3.0.0", # streaming IBL
8484
# Following dependencies are for streaming with nwb files
8585
"pynwb>=2.6.0",
8686
"fsspec",

src/spikeinterface/extractors/iblextractors.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,16 @@ class IblSortingExtractor(BaseSorting):
294294
>>> one = ONE(base_url="https://openalyx.internationalbrainlab.org", password="international", silent=True)
295295
>>> pids, _ = one.eid2pid("session_eid")
296296
>>> pid = pids[0]
297+
one: One | dict, required
298+
Instance of ONE.api or dict to use for data loading.
299+
For multi-processing applications, this can also be a dictionary of ONE.api arguments
300+
For example: one=dict(base_url='https://alyx.internationalbrainlab.org', mode='remote')
297301
good_clusters_only: bool, default: False
298302
If True, only load the good clusters
299303
load_unit_properties: bool, default: True
300304
If True, load the unit properties from the IBL database
301-
one: One | dict, default: None
302-
Instance of ONE.api or dict to use for data loading.
303-
For multi-processing applications, this can also be a dictionary of ONE.api arguments
304-
For example: one={} or one=dict(base_url='https://alyx.internationalbrainlab.org', mode='remote')
305-
305+
kwargs: dict, optional
306+
Additional keyword arguments to pass to the IBL SpikeSortingLoader constructor, such as `revision`.
306307
Returns
307308
-------
308309
extractor : IBLSortingExtractor
@@ -311,13 +312,14 @@ class IblSortingExtractor(BaseSorting):
311312

312313
installation_mesg = "IBL extractors require ibllib as a dependency." " To install, run: \n\n pip install ibllib\n\n"
313314

314-
def __init__(self, pid: str, good_clusters_only: bool = False, load_unit_properties: bool = True, one=None):
315+
def __init__(
316+
self, pid: str, good_clusters_only: bool = False, load_unit_properties: bool = True, one=None, **kwargs
317+
):
315318
try:
316319
from one.api import ONE
317320
from brainbox.io.one import SpikeSortingLoader
318321

319-
if one is None:
320-
one = {}
322+
assert one is not None, "one is a required parameter."
321323
if isinstance(one, dict):
322324
one = ONE(**one)
323325
else:
@@ -327,12 +329,11 @@ def __init__(self, pid: str, good_clusters_only: bool = False, load_unit_propert
327329
self.ssl = SpikeSortingLoader(one=one, pid=pid)
328330
sr = self.ssl.raw_electrophysiology(band="ap", stream=True)
329331
self._folder_path = self.ssl.session_path
330-
spikes, clusters, channels = self.ssl.load_spike_sorting(dataset_types=["spikes.samples"])
332+
spikes, clusters, channels = self.ssl.load_spike_sorting(dataset_types=["spikes.samples"], **kwargs)
331333
clusters = self.ssl.merge_clusters(spikes, clusters, channels)
332334

333335
if good_clusters_only:
334336
good_cluster_slice = clusters["cluster_id"][clusters["label"] == 1]
335-
unit_ids = clusters["cluster_id"][good_cluster_slice]
336337
else:
337338
good_cluster_slice = slice(None)
338339
unit_ids = clusters["cluster_id"][good_cluster_slice]

src/spikeinterface/extractors/tests/test_iblextractors.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
@pytest.mark.streaming_extractors
15+
@pytest.mark.xfail(reason="We need to fix ibllib/one-api dependency")
1516
class TestDefaultIblRecordingExtractorApBand(TestCase):
1617
@classmethod
1718
def setUpClass(cls):
@@ -106,6 +107,7 @@ def test_unscaled_trace_dtype(self):
106107

107108

108109
@pytest.mark.streaming_extractors
110+
@pytest.mark.xfail(reason="We need to fix ibllib/one-api dependency")
109111
class TestIblStreamingRecordingExtractorApBandWithLoadSyncChannel(TestCase):
110112
@classmethod
111113
def setUpClass(cls):
@@ -180,6 +182,7 @@ def test_unscaled_trace_dtype(self):
180182

181183

182184
@pytest.mark.streaming_extractors
185+
@pytest.mark.xfail(reason="We need to fix ibllib/one-api dependency")
183186
class TestIblSortingExtractor(TestCase):
184187
def test_ibl_sorting_extractor(self):
185188
"""
@@ -197,9 +200,9 @@ def test_ibl_sorting_extractor(self):
197200
)
198201
except:
199202
pytest.skip("Skipping test due to server being down.")
200-
sorting = read_ibl_sorting(pid=PID, one=one)
203+
sorting = read_ibl_sorting(pid=PID, one=one, revision="2023-12-05")
201204
assert len(sorting.unit_ids) == 733
202-
sorting_good = read_ibl_sorting(pid=PID, good_clusters_only=True)
205+
sorting_good = read_ibl_sorting(pid=PID, good_clusters_only=True, one=one, revision="2023-12-05")
203206
assert len(sorting_good.unit_ids) == 108
204207

205208
# check properties
@@ -208,14 +211,14 @@ def test_ibl_sorting_extractor(self):
208211
assert "brain_area" in sorting_good.get_property_keys()
209212

210213
# load without properties
211-
sorting_no_properties = read_ibl_sorting(pid=PID, load_unit_properties=False)
214+
sorting_no_properties = read_ibl_sorting(pid=PID, one=one, load_unit_properties=False, revision="2023-12-05")
212215
# check properties
213216
assert "firing_rate" not in sorting_no_properties.get_property_keys()
214217

215218

216219
if __name__ == "__main__":
217-
TestDefaultIblStreamingRecordingExtractorApBand.setUpClass()
218-
test1 = TestDefaultIblStreamingExtractorApBand()
220+
TestDefaultIblRecordingExtractorApBand.setUpClass()
221+
test1 = TestDefaultIblRecordingExtractorApBand()
219222
test1.setUp()
220223
test1.test_get_stream_names()
221224
test1.test_dtype()
@@ -230,7 +233,7 @@ def test_ibl_sorting_extractor(self):
230233
test1.test_unscaled_trace_dtype()
231234

232235
TestIblStreamingRecordingExtractorApBandWithLoadSyncChannel.setUpClass()
233-
test2 = TestIblStreamingExtractorApBandWithLoadSyncChannel()
236+
test2 = TestIblStreamingRecordingExtractorApBandWithLoadSyncChannel()
234237
test2.setUp()
235238
test2.test_get_stream_names()
236239
test2.test_get_stream_names()

0 commit comments

Comments
 (0)