cortex-lab / phy

phy: interactive visualization and manual spike sorting of large-scale ephys data
BSD 3-Clause "New" or "Revised" License
304 stars 155 forks source link

Error "QWidget: Must construct a QApplication before a QWidget" #1273

Closed adam-hockley closed 1 month ago

adam-hockley commented 2 months ago

I keep getting this error when trying to open a fresh install of Phy on a dataset sorted with KS4 using spike interface. I followed the installation instructions on the readme, with the required changes to the python version "python=3.11" and also I had to run "conda install git".

Any help much appreciated!

Here is the traceback and the conda list:


(phy2_test) C:\SortingFolder\NPH5\5\Sorting\KS4\sorter_output>phy template-gui params.py

10:08:09.916 [W] model:667 Skipping spike waveforms that do not exist, they will be extracted on the fly from the raw data as needed. 10:08:09.916 [E] init:62 An error has occurred (AssertionError): No extension found in file C:\SortingFolder Traceback (most recent call last): File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\ANL\anaconda3\envs\phy2_test\Scripts\phy.exe__main.py", line 7, in sys.exit(phycli()) File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\click\core.py", line 1157, in call return self.main(args, kwargs) File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\click\core.py", line 1078, in main rv = self.invoke(ctx) File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\click\core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\click\core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\click\core.py", line 783, in invoke return __callback(args, *kwargs) File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\click\decorators.py", line 33, in new_func return f(get_current_context(), args, **kwargs) File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\phy\apps\init.py", line 159, in cli_template_gui template_gui(params_path, kwargs) File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\phy\apps\template\gui.py", line 209, in template_gui model = load_model(params_path) File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\phylib\io\model.py", line 1433, in load_model return TemplateModel(get_template_params(params_path)) File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\phylib\io\model.py", line 339, in init__ self._load_data() File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\phylib\io\model.py", line 449, in _load_data self.traces = self._load_traces(self.channel_mapping) File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\phylib\io\model.py", line 580, in _load_traces traces = get_ephys_reader( File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\phylib\io\traces.py", line 496, in get_ephys_reader klass, arg, kwargs = _get_ephys_constructor(obj, kwargs) File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\phylib\io\traces.py", line 483, in _get_ephys_constructor klass, arg, kwargs = _get_ephys_constructor(obj[0], kwargs) File "C:\Users\ANL\anaconda3\envs\phy2_test\lib\site-packages\phylib\io\traces.py", line 466, in _get_ephys_constructor assert ext, "No extension found in file %s" % path AssertionError: No extension found in file C:\SortingFolder

QWidget: Must construct a QApplication before a QWidget


packages in environment at C:\Users\ANL\anaconda3\envs\phy2_test:

#

Name Version Build Channel

abseil-cpp 20211102.0 hd77b12b_0 arrow-cpp 14.0.2 ha81ea56_1 asttokens 2.0.5 pyhd3eb1b0_0 aws-c-auth 0.6.19 h2bbff1b_0 aws-c-cal 0.5.20 h2bbff1b_0 aws-c-common 0.8.5 h2bbff1b_0 aws-c-compression 0.2.16 h2bbff1b_0 aws-c-event-stream 0.2.15 hd77b12b_0 aws-c-http 0.6.25 h2bbff1b_0 aws-c-io 0.13.10 h2bbff1b_0 aws-c-mqtt 0.7.13 h2bbff1b_0 aws-c-s3 0.1.51 h2bbff1b_0 aws-c-sdkutils 0.1.6 h2bbff1b_0 aws-checksums 0.1.13 h2bbff1b_0 aws-crt-cpp 0.18.16 hd77b12b_0 aws-sdk-cpp 1.10.55 hd77b12b_0 blas 1.0 mkl bokeh 3.4.0 py311h746a85d_1 boost-cpp 1.82.0 h59b6b97_2 bottleneck 1.3.7 py311hd7041d2_0 brotli 1.0.9 h2bbff1b_7 brotli-bin 1.0.9 h2bbff1b_7 brotli-python 1.0.9 py311hd77b12b_7 bzip2 1.0.8 h2bbff1b_5 c-ares 1.19.1 h2bbff1b_0 ca-certificates 2024.3.11 haa95532_0 certifi 2024.2.2 py311haa95532_0 charset-normalizer 2.0.4 pyhd3eb1b0_0 click 8.1.7 py311haa95532_0 cloudpickle 2.2.1 py311haa95532_0 colorama 0.4.6 py311haa95532_0 colorcet 3.1.0 pypi_0 pypi comm 0.2.1 py311haa95532_0 contourpy 1.2.0 py311h59b6b97_0 cycler 0.11.0 pyhd3eb1b0_0 cython 3.0.10 py311h2bbff1b_0 cytoolz 0.12.2 py311h2bbff1b_0 dask 2023.11.0 py311haa95532_0 dask-core 2023.11.0 py311haa95532_0 debugpy 1.6.7 py311hd77b12b_0 decorator 5.1.1 pyhd3eb1b0_0 distributed 2023.11.0 py311haa95532_0 executing 0.8.3 pyhd3eb1b0_0 fonttools 4.51.0 py311h2bbff1b_0 freetype 2.12.1 ha860e81_0 fsspec 2024.3.1 py311haa95532_0 gflags 2.2.2 hd77b12b_1 ghp-import 2.1.0 pypi_0 pypi git 2.40.1 haa95532_1 glog 0.5.0 hd77b12b_1 grpc-cpp 1.48.2 hfe90ff0_1 h5py 3.9.0 py311h4e0e482_0 hdf5 1.12.1 h51c971a_3 heapdict 1.0.1 pyhd3eb1b0_0 icc_rt 2022.1.0 h6049295_2 icu 73.1 h6c2663c_0 idna 3.7 py311haa95532_0 importlib-metadata 7.0.1 py311haa95532_0 iniconfig 1.1.1 pyhd3eb1b0_0 intel-openmp 2023.1.0 h59b6b97_46320 ipykernel 6.28.0 py311haa95532_0 ipython 8.20.0 py311haa95532_0 jedi 0.18.1 py311haa95532_1 jinja2 3.1.3 py311haa95532_0 joblib 1.4.0 py311haa95532_0 jpeg 9e h2bbff1b_1 jupyter_client 8.6.0 py311haa95532_0 jupyter_core 5.5.0 py311haa95532_0 kiwisolver 1.4.4 py311hd77b12b_0 krb5 1.20.1 h5b6d351_0 lcms2 2.12 h83e58a3_0 lerc 3.0 hd77b12b_0 libboost 1.82.0 h3399ecb_2 libbrotlicommon 1.0.9 h2bbff1b_7 libbrotlidec 1.0.9 h2bbff1b_7 libbrotlienc 1.0.9 h2bbff1b_7 libclang 14.0.6 default_hb5a9fac_1 libclang13 14.0.6 default_h8e68704_1 libcurl 8.5.0 h86230a5_0 libdeflate 1.17 h2bbff1b_1 libevent 2.1.12 h56d1f94_1 libffi 3.4.4 hd77b12b_0 libpng 1.6.39 h8cc25b3_0 libpq 12.17 h906ac69_0 libprotobuf 3.20.3 h23ce68f_0 libsodium 1.0.18 h62dcd97_0 libssh2 1.10.0 he2ea4bf_2 libthrift 0.15.0 h4364b78_2 libtiff 4.5.1 hd77b12b_0 libwebp-base 1.3.2 h2bbff1b_0 locket 1.0.0 py311haa95532_0 lz4 4.3.2 py311h2bbff1b_0 lz4-c 1.9.4 h2bbff1b_0 markdown 3.6 pypi_0 pypi markupsafe 2.1.3 py311h2bbff1b_0 matplotlib 3.8.4 py311haa95532_0 matplotlib-base 3.8.4 py311hf62ec03_0 matplotlib-inline 0.1.6 py311haa95532_0 mergedeep 1.3.4 pypi_0 pypi mkdocs 1.6.0 pypi_0 pypi mkdocs-get-deps 0.2.0 pypi_0 pypi mkl 2023.1.0 h6b88ed4_46358 mkl-service 2.4.0 py311h2bbff1b_1 mkl_fft 1.3.8 py311h2bbff1b_0 mkl_random 1.2.4 py311h59b6b97_0 msgpack-python 1.0.3 py311h59b6b97_0 mtscomp 1.0.2 pypi_0 pypi nest-asyncio 1.6.0 py311haa95532_0 numexpr 2.8.7 py311h1fcbade_0 numpy 1.26.4 py311hdab7c0b_0 numpy-base 1.26.4 py311hd01c5d8_0 openjpeg 2.4.0 h4fc8c34_0 openssl 3.0.13 h2bbff1b_0 orc 1.7.4 h623e30f_1 packaging 23.2 py311haa95532_0 pandas 2.2.1 py311hea22821_0 parso 0.8.3 pyhd3eb1b0_0 partd 1.4.1 py311haa95532_0 pathspec 0.12.1 pypi_0 pypi phy 2.0b5 pypi_0 pypi phylib 2.4.3 pypi_0 pypi pillow 10.3.0 py311h2bbff1b_0 pip 23.3.1 py311haa95532_0 platformdirs 3.10.0 py311haa95532_0 pluggy 1.0.0 py311haa95532_1 ply 3.11 py311haa95532_0 prompt-toolkit 3.0.43 py311haa95532_0 prompt_toolkit 3.0.43 hd3eb1b0_0 psutil 5.9.0 py311h2bbff1b_0 pure_eval 0.2.2 pyhd3eb1b0_0 pyarrow 14.0.2 py311h847bd2a_0 pybind11-abi 5 hd3eb1b0_0 pygments 2.15.1 py311haa95532_1 pyopengl 3.1.1a1 py311haa95532_0 pyparsing 3.0.9 py311haa95532_0 pyqt 5.15.10 py311hd77b12b_0 pyqt5-sip 12.13.0 py311h2bbff1b_0 pyqtwebengine 5.15.10 py311hd77b12b_0 pysocks 1.7.1 py311haa95532_0 pytest 7.4.0 py311haa95532_0 python 3.11.9 he1021f5_0 python-dateutil 2.8.2 pyhd3eb1b0_0 python-lmdb 1.4.1 py311hd77b12b_0 python-tzdata 2023.3 pyhd3eb1b0_0 pytz 2024.1 py311haa95532_0 pywin32 305 py311h2bbff1b_0 pyyaml 6.0.1 py311h2bbff1b_0 pyyaml-env-tag 0.1 pypi_0 pypi pyzmq 25.1.2 py311hd77b12b_0 qt-main 5.15.2 h19c9488_10 qt-webengine 5.15.9 h5bd16bc_7 qtconsole 5.5.1 py311haa95532_0 qtpy 2.4.1 py311haa95532_0 re2 2022.04.01 hd77b12b_0 requests 2.31.0 py311haa95532_1 responses 0.25.0 py311haa95532_0 scikit-learn 1.4.2 py311hf62ec03_1 scipy 1.13.0 py311h9f229c6_0 setuptools 68.2.2 py311haa95532_0 sip 6.7.12 py311hd77b12b_0 six 1.16.0 pyhd3eb1b0_1 snappy 1.1.10 h6c2663c_1 sortedcontainers 2.4.0 pyhd3eb1b0_0 sqlite 3.41.2 h2bbff1b_0 stack_data 0.2.0 pyhd3eb1b0_0 tbb 2021.8.0 h59b6b97_0 tblib 1.7.0 pyhd3eb1b0_0 threadpoolctl 2.2.0 pyh0d69192_0 tk 8.6.12 h2bbff1b_0 toolz 0.12.0 py311haa95532_0 tornado 6.3.3 py311h2bbff1b_0 tqdm 4.66.2 pypi_0 pypi traitlets 5.7.1 py311haa95532_0 tzdata 2024a h04d1e81_0 unicodedata2 15.1.0 py311h2bbff1b_0 urllib3 2.1.0 py311haa95532_1 utf8proc 2.6.1 h2bbff1b_1 vc 14.2 h21ff451_1 vs2015_runtime 14.27.29016 h5e58377_2 watchdog 4.0.0 pypi_0 pypi wcwidth 0.2.5 pyhd3eb1b0_0 wheel 0.41.2 py311haa95532_0 win_inet_pton 1.1.0 py311haa95532_0 xyzservices 2022.9.0 py311haa95532_1 xz 5.4.6 h8cc25b3_0 yaml 0.2.5 he774522_0 zeromq 4.3.5 hd77b12b_0 zict 3.0.0 py311haa95532_0 zipp 3.17.0 py311haa95532_0 zlib 1.2.13 h8cc25b3_0 zstd 1.5.5 hd43e919_0

zm711 commented 2 months ago

What file format are you using. I haven't seen that specific cause of the error but it seems like it is struggling to read the binary file. Could you post the contents of the params.py file here?

asheff794 commented 2 months ago

I was getting the same error. The problem for me was indeed in the params.py file, the dat_path was referring to the directory where I ran kilosort but not the actual bin file. I was running kilosort4 from spikeinterface so I imagine that's why the param.py file was incorrect.

I changed the dat_path to point to the actual .bin file and everything works now (see below), hope that solves it for you as well!

Before dat_path = '/vast/palmer/home.mccleary/ags72/Documents/Ephys/' n_channels_dat = 32 dtype = 'uint16' offset = 0 sample_rate = 30000.0 hp_filtered = False

After dat_path = '/vast/palmer/home.mccleary/ags72/Documents/Ephys/Test_data/data.bin' n_channels_dat = 32 dtype = 'uint16' offset = 0 sample_rate = 30000.0 hp_filtered = False

zm711 commented 2 months ago

That's what I assumed the issue was. We were discussing trying to fix this at the spikeinterface level, but we hadn't decided on that yet since some people don't have a binary file with spikeinterface. But just editing the params.py manually should fix it when using the wrapper.