Skip to content

Commit 4f14070

Browse files
committed
Merge branch 'hotfix/2.2.1' into develop
2 parents 931abc9 + 56684e9 commit 4f14070

File tree

4 files changed

+43
-13
lines changed

4 files changed

+43
-13
lines changed

ibllib/pipes/misc.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import shutil
44
from pathlib import Path
55
import re
6+
from typing import Union, List
67

78
import iblutil.io.params as params
89
from one.alf.spec import is_uuid_string, is_session_path
@@ -346,6 +347,23 @@ def confirm_ephys_remote_folder(
346347
check_create_raw_session_flag(remote_session_path)
347348

348349

350+
def probe_labels_from_session_path(session_path: Union[str, Path]) -> List[str]:
351+
"""
352+
Finds ephys probes according to the metadata spikeglx files. Only returns first subfolder
353+
name under raw_ephys_data folder, ie. raw_ephys_data/probe00/copy_of_probe00 won't be returned
354+
:param session_path:
355+
:return: list of strings
356+
"""
357+
plabels = []
358+
raw_ephys_folder = session_path.joinpath('raw_ephys_data')
359+
for meta_file in raw_ephys_folder.rglob('*.ap.meta'):
360+
if meta_file.parents[1] != raw_ephys_folder:
361+
continue
362+
plabels.append(meta_file.parts[-2])
363+
plabels.sort()
364+
return plabels
365+
366+
349367
def create_alyx_probe_insertions(
350368
session_path: str,
351369
force: bool = False,
@@ -363,24 +381,15 @@ def create_alyx_probe_insertions(
363381
pmodel = "3B2" if probe_model == "3B" else probe_model
364382
else:
365383
pmodel = model
366-
raw_ephys_data_path = Path(session_path) / "raw_ephys_data"
367-
if labels is None:
368-
probe_labels = [
369-
x.name
370-
for x in Path(raw_ephys_data_path).glob("*")
371-
if x.is_dir() and ("00" in x.name or "01" in x.name)
372-
]
373-
else:
374-
probe_labels = labels
375-
384+
labels = labels or probe_labels_from_session_path(session_path)
376385
# create the qc fields in the json field
377386
qc_dict = {}
378387
qc_dict.update({"qc": "NOT_SET"})
379388
qc_dict.update({"extended_qc": {}})
380389

381390
# create the dictionary
382391
insertions = []
383-
for plabel in probe_labels:
392+
for plabel in labels:
384393
insdict = {"session": eid, "name": plabel, "model": pmodel, "json": qc_dict}
385394
# search for the corresponding insertion in Alyx
386395
alyx_insertion = one.alyx.get(f'/insertions?&session={eid}&name={plabel}', clobber=True)

ibllib/tests/test_pipes.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,22 @@ def test_create_alyx_probe_insertions(self):
301301
one.alyx.rest("insertions", "delete", id=alyx_insertion[0]["id"])
302302
one.alyx.rest("insertions", "delete", id=alyx_insertion[1]["id"])
303303

304+
def test_probe_names_from_session_path(self):
305+
pnames = ['probe01', 'probe03', 'just_a_probe']
306+
307+
with tempfile.TemporaryDirectory() as tdir:
308+
session_path = Path(tdir).joinpath('Algernon', '2021-02-12', '001')
309+
raw_ephys_path = session_path.joinpath('raw_ephys_data')
310+
raw_ephys_path.mkdir(parents=True, exist_ok=True)
311+
raw_ephys_path.joinpath("_spikeglx_ephysData_g0_t0.nidq.meta").touch()
312+
for pname in pnames:
313+
probe_path = raw_ephys_path.joinpath(pname)
314+
probe_path.mkdir()
315+
probe_path.joinpath('_spikeglx_ephysData_g0_t0.imec0.ap.meta').touch()
316+
probe_path.joinpath('nested_folder').mkdir()
317+
probe_path.joinpath('nested_folder', 'toto.ap.meta').touch()
318+
assert set(misc.probe_labels_from_session_path(session_path)) == set(pnames)
319+
304320
def test_rename_session(self):
305321
self._inputs = ('foo', '2020-02-02', '002')
306322
with mock.patch('builtins.input', self._input_side_effect):

release_notes.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
## Develop
1+
## Release Notes 2.2
2+
### Release Notes 2.2.0 2021-11-02
3+
- allows more than 2 probes in ephys computer probe creation
4+
5+
### Release Notes 2.2.0 2021-10-29
26
- brainbox.io.one load_spike_sorting fast: merge channel info in clusters
37
- brainbox.io.one generic function to interpolate channels after alignment
48
- dsp: spike detection by voltage thresholding and cadzow filtering docs
59
- ibllib.io.spikeglx: get geometry from metadata
610
- RawEphysQC outputs basic detection spike rates
11+
- ibllib.atlas.regions: add new mapping cosmos and revise Beryl
712

813
## Release Notes 2.1
914
### Release Notes 2.1.0 2021-10-05

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
setup(
2626
name='ibllib',
27-
version='2.1.3',
27+
version='2.2.1',
2828
python_requires='>={}.{}'.format(*REQUIRED_PYTHON),
2929
description='IBL libraries',
3030
license="MIT",

0 commit comments

Comments
 (0)