phy icon indicating copy to clipboard operation
phy copied to clipboard

Fail to load kilosort4 output

Open David-H-Chang opened this issue 1 year ago • 0 comments

(phy2) [zhangdaohan20h@gpu01 Kilosort-2.5.2]$ phy template-gui  /share/home/zhangdaohan20h/CODES/NPX/kilosort4_output/sorter_output/params.py 
17:01:27.838 [E] __init__:62          An error has occurred (IndexError): index 343 is out of bounds for axis 0 with size 343
Traceback (most recent call last):
  File "/home/zhangdaohan20h/.conda/envs/phy2/bin/phy", line 8, in <module>
    sys.exit(phycli())
             ^^^^^^^^
  File "/home/zhangdaohan20h/.conda/envs/phy2/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zhangdaohan20h/.conda/envs/phy2/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/zhangdaohan20h/.conda/envs/phy2/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zhangdaohan20h/.conda/envs/phy2/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zhangdaohan20h/.conda/envs/phy2/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zhangdaohan20h/.conda/envs/phy2/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zhangdaohan20h/.conda/envs/phy2/lib/python3.11/site-packages/phy/apps/__init__.py", line 159, in cli_template_gui
    template_gui(params_path, **kwargs)
  File "/home/zhangdaohan20h/.conda/envs/phy2/lib/python3.11/site-packages/phy/apps/template/gui.py", line 209, in template_gui
    model = load_model(params_path)
            ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zhangdaohan20h/.conda/envs/phy2/lib/python3.11/site-packages/phylib/io/model.py", line 1440, in load_model
    return TemplateModel(**get_template_params(params_path))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zhangdaohan20h/.conda/envs/phy2/lib/python3.11/site-packages/phylib/io/model.py", line 339, in __init__
    self._load_data()
  File "/home/zhangdaohan20h/.conda/envs/phy2/lib/python3.11/site-packages/phylib/io/model.py", line 419, in _load_data
    self.sparse_clusters = self.cluster_waveforms()
                           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zhangdaohan20h/.conda/envs/phy2/lib/python3.11/site-packages/phylib/io/model.py", line 1330, in cluster_waveforms
    data[clust, :, :] = self.sparse_templates.data[val[0], :, :]
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/home/zhangdaohan20h/.conda/envs/phy2/lib/python3.11/site-packages/numpy/core/memmap.py", line 335, in __getitem__
    res = super().__getitem__(index)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
IndexError: index 343 is out of bounds for axis 0 with size 343

QWidget: Must construct a QApplication before a QWidget
Aborted (core dumped)

however, if i use spikeinterface.exporter.export_to_phy

sorting = se.read_kilosort('/home/zhangdaohan20h/CODES/NPX/HS102/kilosort4_output/sorter_output')
analyzer = create_sorting_analyzer(sorting=sorting,
                                   recording=rec_interpolated,
                                   overwrite=True,
                                   format="binary_folder",
                                   return_scaled=True, # this is the default to attempt to return scaled
                                   folder=folder,
                                   n_jobs = 20
                                   )
from spikeinterface.exporters import export_to_phy
export_to_phy(sorting_analyzer=analyzer, output_folder='phy_folder',**job_kwargs)
(phy2) [zhangdaohan20h@gpu01 Kilosort-2.5.2]$ phy template-gui  /share/home/zhangdaohan20h/CODES/NPX/phy_folder/params.py 

it works

David-H-Chang avatar Feb 01 '25 09:02 David-H-Chang