phy icon indicating copy to clipboard operation
phy copied to clipboard

Error while running

Open farazmoradi opened this issue 3 years ago • 7 comments

Hi, I received this error while running Phy on some of the sorted data!

QWidget: Must construct a QApplication before a QWidget zsh: abort phy template-gui params.py

farazmoradi avatar Sep 28 '21 20:09 farazmoradi

I'm also seeing this error... any suggestions?

$ phy template-gui params.py

File "/software/miniconda3/4.9.2/envs/phy2/lib/python3.7/site-packages/phylib/io/model.py", line 475, in _read_array raise IOError() OSError

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

hstern2 avatar Oct 26 '21 16:10 hstern2

I'm seeing a similar error after installing phy using the Developer instructions in the Readme. Has anyone seen anything like this and solved it?

`(phy) [gg121@compute-e-16-229 phylib]$ phy template-gui /n/groups/datta/guitchounts/data/gmou48/gmou48_2021-12-11_14-24-38_odor/tmp_MS4/phy/params.py 16:41:57.386 [W] model:1325 File /n/groups/datta/guitchounts/data/gmou48/gmou48_2021-12-11_14-24-38_odor/tmp_MS4/phy/None does not exist. 16:41:59.642 [E] init:62 An error has occurred (AssertionError): Traceback (most recent call last): File "/home/gg121/anaconda3/envs/phy/bin/phy", line 33, in sys.exit(load_entry_point('phy', 'console_scripts', 'phy')()) File "/home/gg121/anaconda3/envs/phy/lib/python3.8/site-packages/click/core.py", line 1128, in call return self.main(*args, **kwargs) File "/home/gg121/anaconda3/envs/phy/lib/python3.8/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/home/gg121/anaconda3/envs/phy/lib/python3.8/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/gg121/anaconda3/envs/phy/lib/python3.8/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/gg121/anaconda3/envs/phy/lib/python3.8/site-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "/home/gg121/anaconda3/envs/phy/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func return f(get_current_context(), *args, **kwargs) File "/home/gg121/code/phy/phy/apps/init.py", line 159, in cli_template_gui template_gui(params_path, **kwargs) File "/home/gg121/code/phy/phy/apps/template/gui.py", line 209, in template_gui model = load_model(params_path) File "/home/gg121/code/phylib/phylib/io/model.py", line 1350, in load_model return TemplateModel(**get_template_params(params_path)) File "/home/gg121/code/phylib/phylib/io/model.py", line 339, in init self._load_data() File "/home/gg121/code/phylib/phylib/io/model.py", line 358, in _load_data assert self.amplitudes.shape == (ns,) AssertionError

QWidget: Must construct a QApplication before a QWidget Aborted`

guitchounts avatar Dec 17 '21 21:12 guitchounts

I saw the same issue. In my case, it was cased by an incorrect params.py, with an entry for n_channels_dat that did not match the data.

Part of the problem here is, the program aborts without a meaningful error message. In order to address this, I've applied this patch

diff --git a/phylib/io/model.py b/phylib/io/model.py
index ad008f5..e755bc9 100644
--- a/phylib/io/model.py
+++ b/phylib/io/model.py
@@ -380,6 +380,9 @@ class TemplateModel(object):
         self.channel_mapping = self._load_channel_map()
         self.n_channels = nc = self.channel_mapping.shape[0]
         if self.n_channels_dat:
+            if not np.all(self.channel_mapping <= self.n_channels_dat - 1):
+                print("channel miss-match, check n_channels_dat in your params file %d,%d\n",self.channel_mapping,self.n_channels_dat)
+                return
             assert np.all(self.channel_mapping <= self.n_channels_dat - 1)
 
         # Channel positions.

schloegl avatar Apr 08 '22 10:04 schloegl