int-brain-lab / iblapps

pyqt5 dependent applications for IBL sessions
MIT License
23 stars 15 forks source link

ephysqc.spike_sorting_metrics_ks2 function called with too many arguments in extract_files #51

Open cbimbo opened 2 years ago

cbimbo commented 2 years ago

Hi! I am very new to this pipeline, and am trying to prepare some ephys data for future alignment with histology using the extract_data function with the following code:

from pathlib import Path
from atlaselectrophysiology.extract_files import extract_data

ks_path = Path(r'D:\spikeSorting_Celian\CB008_2021-03-11_bank0_audioVis_g0\sorting') # Path to KS2 output
ephys_path = Path(r'\\znas\Subjects\CB008\2021-03-11\ephys\CB008_2021-03-11_bank0_audioVis_g0') # Path to raw ephys data
out_path = Path(r'D:\spikeSorting_Celian\CB008_2021-03-11_bank0_audioVis_g0\alf') # Save path

extract_data(ks_path, ephys_path, out_path)

However, I get this error:

Traceback (most recent call last):

  Input In [1] in <module>
    extract_data(ks_path, ephys_path, out_path)

  File ~\Documents\int-brain-lab\iblapps\atlaselectrophysiology\extract_files.py:129 in extract_data
    ks2_to_alf(ks_path, ephys_path, out_path, bin_file=efile.ap,

  File ~\Documents\int-brain-lab\iblapps\atlaselectrophysiology\extract_files.py:119 in ks2_to_alf
    ephysqc.spike_sorting_metrics_ks2(ks_path, m, save=True, save_path=out_path)

TypeError: spike_sorting_metrics_ks2() got an unexpected keyword argument 'save_path'

I think it's because ephysqc.spike_sorting_metrics_ks2 takes only 3 arguments (def spike_sorting_metrics_ks2(ks2_path=None, m=None, save=True): ...) but is called with 4 (ephysqc.spike_sorting_metrics_ks2(ks_path, m, save=True, save_path=out_path)).

I'm not sure how it's possible (it should crash for everyone..)? I'm on the dev branch of iblapps and ibllib (I followed the instructions here. Maybe I've missed some obvious step?

Many thanks for your help, Celian

mayofaulkner commented 2 years ago

Hi, sorry about that. If you pull the latest changes from ibllib develop branch that should be fixed. Let me know if not!

cbimbo commented 2 years ago

Hi Mayo, Thanks for that. This fixed it for me. However, I'm still getting an error:

  File ~\Documents\int-brain-lab\phylib\phylib\io\traces.py:654 in export_waveforms
    writer = NpyWriter(path, shape, dtype)

  File ~\Documents\int-brain-lab\phylib\phylib\io\traces.py:555 in __init__
    self.fp = open(path, 'wb')

OSError: [Errno 22] Invalid argument: 'D:\\spikeSorting_Celian\\CB008_2021-03-11_bank0_audioVis_g0\\sorting\\_phy_spikes_subset.waveforms.npy

I still have to dive into it, and if I can't fix it maybe I'll open another issue. Thanks again for the quick reply! Celian

mayofaulkner commented 1 year ago

Hi, following up on this. Did you fix this path issue?