Skip to content

Commit 6b17860

Browse files
authored
Merge pull request #411 from int-brain-lab/pykilosort_version
rerun based on pykilosort version in log
2 parents 9f7335f + 56edd38 commit 6b17860

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

brainbox/io/one.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,9 @@ def _load_channel_locations_traj(eid, probe=None, one=None, revision=None, align
331331

332332
channels[probe] = _channels_traj2bunch(chans, brain_atlas)
333333

334+
channels[probe]['axial_um'] = chn_coords[:, 1]
335+
channels[probe]['lateral_um'] = chn_coords[:, 0]
336+
334337
else:
335338
_logger.warning(f'Histology tracing for {probe} does not exist. '
336339
f'No channels for {probe}')

ibllib/pipes/ephys_preprocessing.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from collections import OrderedDict
66
import traceback
77
from pathlib import Path
8+
import packaging.version
89

910
import numpy as np
1011
import pandas as pd
@@ -243,6 +244,14 @@ def _fetch_pykilosort_version(repo_path):
243244
pass
244245
return f"pykilosort_{version}"
245246

247+
@staticmethod
248+
def _fetch_pykilosort_run_version(log_file):
249+
with open(log_file) as fid:
250+
line = fid.readline()
251+
version = re.search('version (.*), output', line).group(1)
252+
253+
return f"pykilosort_{version}"
254+
246255
@staticmethod
247256
def _fetch_ks2_commit_hash(repo_path):
248257
command2run = f"git --git-dir {repo_path}/.git rev-parse --verify HEAD"
@@ -283,10 +292,13 @@ def _run_pykilosort(self, ap_file):
283292
sorter_dir = self.session_path.joinpath("spike_sorters", self.SPIKE_SORTER_NAME, label)
284293
FORCE_RERUN = False
285294
if not FORCE_RERUN:
286-
if sorter_dir.joinpath(f"spike_sorting_{self.SPIKE_SORTER_NAME}.log").exists():
287-
_logger.info(f"Already ran: spike_sorting_{self.SPIKE_SORTER_NAME}.log"
288-
f" found in {sorter_dir}, skipping.")
289-
return sorter_dir
295+
log_file = sorter_dir.joinpath(f"spike_sorting_{self.SPIKE_SORTER_NAME}.log")
296+
if log_file.exists():
297+
run_version = self._fetch_pykilosort_run_version(log_file)
298+
if packaging.version.parse(run_version) >= packaging.version.parse('pykilosort_ibl_1.1.0'):
299+
_logger.info(f"Already ran: spike_sorting_{self.SPIKE_SORTER_NAME}.log"
300+
f" found in {sorter_dir}, skipping.")
301+
return sorter_dir
290302
print(sorter_dir.joinpath(f"spike_sorting_{self.SPIKE_SORTER_NAME}.log"))
291303
# get the scratch drive from the shell script
292304
with open(self.SHELL_SCRIPT) as fid:

ibllib/pipes/tasks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ def tearDown(self):
223223
Does not run if a lock is encountered by the task (status -2)
224224
"""
225225
if self.gpu >= 1:
226-
self._lock_file_path().unlink()
226+
if self._lock_file_path().exists():
227+
self._lock_file_path().unlink()
227228

228229
def cleanUp(self):
229230
"""

0 commit comments

Comments
 (0)