Skip to content

Commit 380c5e3

Browse files
committed
add optional save path argument for spikesorting metrics
1 parent 0b4a2f8 commit 380c5e3

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

ibllib/ephys/ephysqc.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,18 @@ def _single_test(assertion, str_ok, str_ko):
389389
return ok
390390

391391

392-
def spike_sorting_metrics_ks2(ks2_path=None, m=None, save=True):
392+
def spike_sorting_metrics_ks2(ks2_path=None, m=None, save=True, save_path=None):
393393
"""
394394
Given a path containing kilosort 2 output, compute quality metrics and optionally save them
395395
to a clusters_metric.csv file
396396
:param ks2_path:
397397
:param save
398+
:param save_path: If not given will save into the path given as ks2_path
398399
:return:
399400
"""
400401

402+
save_path = save_path or ks2_path
403+
401404
# ensure that either a ks2_path or a phylib `TemplateModel` object with unit info is given
402405
assert not(ks2_path is None and m is None), 'Must either specify a path to a ks2 output ' \
403406
'directory, or a phylib `TemplateModel` object'
@@ -419,8 +422,9 @@ def spike_sorting_metrics_ks2(ks2_path=None, m=None, save=True):
419422
c = c.set_index('cluster_id', drop=False).join(ks2_labels.set_index('cluster_id'))
420423

421424
if save:
425+
Path(save_path).mkdir(exist_ok=True, parents=True)
422426
# the file name contains the label of the probe (directory name in this case)
423-
c.to_csv(ks2_path.joinpath('cluster_metrics.csv'))
427+
c.to_csv(Path(save_path).joinpath('cluster_metrics.csv'))
424428

425429
return c
426430

ibllib/ephys/sync_probes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ def version3B(ses_path, display=True, type=None, tol=2.5):
146146
raise Neuropixel3BSyncFrontsNonMatching(f"{ses_path}")
147147

148148
# Find the indexes in case the sizes don't match
149+
if sync_nidq.times.size != sync_probe.times.size:
150+
_logger.warning(f'Sync mismatch by {np.abs(sync_nidq.times.size - sync_probe.times.size)} '
151+
f'NIDQ sync times: {sync_nidq.times.size}, Probe sync times {sync_probe.times.size}')
149152
sync_idx = np.min([sync_nidq.times.size, sync_probe.times.size])
150153

151154
# if the qc of the diff finds anomalies, do not attempt to smooth the interp function

release_notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## To be added to next release
22
- Fix in EphysDLC task to not return multiple copies of outputs
3+
- Loading examples for different IBL data types
4+
- Fix for probe syncing when Nidq and probe pulses don't match
35

46
## Release Note 2.9
57

0 commit comments

Comments
 (0)