Skip to content

Commit

Permalink
Hotfix/2.2.1 (#400)
Browse files Browse the repository at this point in the history
* probe creator finds probes based on hierarchy and metadata file

* bump version number and release notes

* fix type hint
  • Loading branch information
oliche authored Nov 2, 2021
1 parent dd4fea3 commit 5dee8e4
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
31 changes: 20 additions & 11 deletions ibllib/pipes/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shutil
from pathlib import Path
import re
from typing import Union, List

import iblutil.io.params as params
from one.alf.spec import is_uuid_string, is_session_path
Expand Down Expand Up @@ -346,6 +347,23 @@ def confirm_ephys_remote_folder(
check_create_raw_session_flag(remote_session_path)


def probe_labels_from_session_path(session_path: Union[str, Path]) -> List[str]:
"""
Finds ephys probes according to the metadata spikeglx files. Only returns first subfolder
name under raw_ephys_data folder, ie. raw_ephys_data/probe00/copy_of_probe00 won't be returned
:param session_path:
:return: list of strings
"""
plabels = []
raw_ephys_folder = session_path.joinpath('raw_ephys_data')
for meta_file in raw_ephys_folder.rglob('*.ap.meta'):
if meta_file.parents[1] != raw_ephys_folder:
continue
plabels.append(meta_file.parts[-2])
plabels.sort()
return plabels


def create_alyx_probe_insertions(
session_path: str,
force: bool = False,
Expand All @@ -363,24 +381,15 @@ def create_alyx_probe_insertions(
pmodel = "3B2" if probe_model == "3B" else probe_model
else:
pmodel = model
raw_ephys_data_path = Path(session_path) / "raw_ephys_data"
if labels is None:
probe_labels = [
x.name
for x in Path(raw_ephys_data_path).glob("*")
if x.is_dir() and ("00" in x.name or "01" in x.name)
]
else:
probe_labels = labels

labels = labels or probe_labels_from_session_path(session_path)
# create the qc fields in the json field
qc_dict = {}
qc_dict.update({"qc": "NOT_SET"})
qc_dict.update({"extended_qc": {}})

# create the dictionary
insertions = []
for plabel in probe_labels:
for plabel in labels:
insdict = {"session": eid, "name": plabel, "model": pmodel, "json": qc_dict}
# search for the corresponding insertion in Alyx
alyx_insertion = one.alyx.get(f'/insertions?&session={eid}&name={plabel}', clobber=True)
Expand Down
16 changes: 16 additions & 0 deletions ibllib/tests/test_pipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,22 @@ def test_create_alyx_probe_insertions(self):
one.alyx.rest("insertions", "delete", id=alyx_insertion[0]["id"])
one.alyx.rest("insertions", "delete", id=alyx_insertion[1]["id"])

def test_probe_names_from_session_path(self):
pnames = ['probe01', 'probe03', 'just_a_probe']

with tempfile.TemporaryDirectory() as tdir:
session_path = Path(tdir).joinpath('Algernon', '2021-02-12', '001')
raw_ephys_path = session_path.joinpath('raw_ephys_data')
raw_ephys_path.mkdir(parents=True, exist_ok=True)
raw_ephys_path.joinpath("_spikeglx_ephysData_g0_t0.nidq.meta").touch()
for pname in pnames:
probe_path = raw_ephys_path.joinpath(pname)
probe_path.mkdir()
probe_path.joinpath('_spikeglx_ephysData_g0_t0.imec0.ap.meta').touch()
probe_path.joinpath('nested_folder').mkdir()
probe_path.joinpath('nested_folder', 'toto.ap.meta').touch()
assert set(misc.probe_labels_from_session_path(session_path)) == set(pnames)

def test_rename_session(self):
self._inputs = ('foo', '2020-02-02', '002')
with mock.patch('builtins.input', self._input_side_effect):
Expand Down
3 changes: 3 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## Release Notes 2.2
### Release Notes 2.2.0 2021-11-02
- allows more than 2 probes in ephys computer probe creation

### Release Notes 2.2.0 2021-10-29
- brainbox.io.one load_spike_sorting fast: merge channel info in clusters
- brainbox.io.one generic function to interpolate channels after alignment
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

setup(
name='ibllib',
version='2.2.0',
version='2.2.1',
python_requires='>={}.{}'.format(*REQUIRED_PYTHON),
description='IBL libraries',
license="MIT",
Expand Down

0 comments on commit 5dee8e4

Please sign in to comment.