Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def ks2_to_alf(ks_path, out_path, ampfactor=1, label=None, force=True):
"""
Convert Kilosort 2 output to ALF dataset for single probe data
:param ks_path:
:param out_path:
:return:
TODO change/remove `ampfactor` after seeing how amplitudes are calculated by ks2
"""
m = ephysqc.phy_model_from_ks2_path(ks_path)
ephysqc.unit_metrics_ks2(ks_path, m, save=True)
ac = alf.EphysAlfCreator(m)
ac.convert(out_path, label=label, force=force, ampfactor=ampfactor)
"""Convert an ephys dataset into ALF. If several directories are specified, it is assumed
that each directory contains the data for one probe of the same recording."""
from phylib.io.alf import EphysAlfCreator
from phylib.io.merge import Merger
from phylib.io.model import load_model
out_dir = Path(out_dir)
if len(subdirs) >= 2:
# Merge in the `merged` subdirectory inside the output directory.
m = Merger(subdirs, out_dir / '_tmp_merged')
model = m.merge()
else:
model = load_model(Path(subdirs[0]) / 'params.py')
c = EphysAlfCreator(model)
c.convert(out_dir)