Closed anshu957 closed 1 year ago
We could probably set that env variable in JABS before importing PySide2 (We don't use PyQt5.x, we are using PySide2 for our Python Qt bindings).
I'd try making this change to app.py
:
import argparse
import sys
import os
os.environ['QT_MAC_WANTS_LAYER'] = '1'
from PySide2 import QtWidgets
from src import APP_NAME, APP_NAME_LONG
from src.ui import MainWindow
if you could test that and let me know (make sure you're not also setting it in your shell) that would be great (I don't have access to a M1 mac to test on)
Thanks! Yes, it is working without exporting the variable in the shell.
Thanks. I'm a little confused because we had this problem once, and then upgrading to Qt 5.15 fixed the problem. I guess the work around is still needed for some Mac OS versions and/or specifically the Apple M2 architecture.
I'll do a little more investigation and then will make a pull request to commit this change.
Adding recent notes to this:
Anshul created a pull request using a conda environment, since a bunch of the GUI libraries aren't on pypi yet as pre-compiled binaries: https://github.com/KumarLabJax/JABS-behavior-classifier/pull/13
Single mouse appears to operate just fine in that conda env, but it appears that feature calculation for multi-mouse isn't operating correctly. User log from trying to to train a multimouse classifier (upon train button click):
Traceback (most recent call last):
File "/Users/hamilc/Jax/JABS-behavior-classifier/src/feature_extraction/features.py", line 113, in __init__
self.__load_from_file()
File "/Users/hamilc/Jax/JABS-behavior-classifier/src/feature_extraction/features.py", line 152, in __load_from_file
with h5py.File(path, 'r') as features_h5:
File "/Users/hamilc/anaconda3/envs/jabs/lib/python3.10/site-packages/h5py/_hl/files.py", line 533, in __init__
fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
File "/Users/hamilc/anaconda3/envs/jabs/lib/python3.10/site-packages/h5py/_hl/files.py", line 226, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5f.pyx", line 106, in h5py.h5f.open
FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name = '/Users/hamilc/Jax/JABS-behavior-classifier/feeding_project/rotta/features/MDB0007_2020-10-04_22-00-00_10/0/per_frame.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/hamilc/Jax/JABS-behavior-classifier/src/ui/training_thread.py", line 54, in run
features, group_mapping = self._project.get_labeled_features(
File "/Users/hamilc/Jax/JABS-behavior-classifier/src/project/project.py", line 657, in get_labeled_features
features = fe.IdentityFeatures(
File "/Users/hamilc/Jax/JABS-behavior-classifier/src/feature_extraction/features.py", line 117, in __init__
self.__initialize_from_pose_estimation(pose_est)
File "/Users/hamilc/Jax/JABS-behavior-classifier/src/feature_extraction/features.py", line 132, in __initialize_from_pose_estimation
self._feature_modules[key].per_frame(self._identity))
File "/Users/hamilc/Jax/JABS-behavior-classifier/src/feature_extraction/feature_group_base_class.py", line 35, in per_frame
feature_modules = self._init_feature_mods(identity)
File "/Users/hamilc/Jax/JABS-behavior-classifier/src/feature_extraction/social_features/social_group.py", line 36, in _init_feature_mods
self._closest_identities_cache = ClosestIdentityInfo(
File "/Users/hamilc/Jax/JABS-behavior-classifier/src/feature_extraction/social_features/social_distance.py", line 64, in __init__
view_angle = self.compute_angle(
File "/Users/hamilc/Jax/JABS-behavior-classifier/src/feature_extraction/social_features/social_distance.py", line 105, in compute_angle
math.atan2(int(c[1]) - int(b[1]), int(c[0]) - int(b[0])) -
IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed
I suspect there was another library version change in the conda env that is causing this conflict. Even though it appears to be an index out of range, I suspect it's actually a numpy (1.21 -> 1.24) change for sorting of animals (in multimouse projects).
Probably last update for this ticket before the merges occur:
The conda patch (https://github.com/KumarLabJax/JABS-behavior-classifier/pull/13) that @anshu957 made will be getting v0.16.3, so that all the analysis conducted in his environment can be adequately cited. Pull https://github.com/KumarLabJax/JABS-behavior-classifier/pull/27 will revert and replace these changes with an upgrade to pyside6 (available on newer macs).
I'm working with M1 Mac -- Monterey 12.4 with PyQt5.15 and when running
python3 app.py
the window freezes indefinitely. Upon searching, the only solution that worked for me is setting environment variableexport QT_MAC_WANTS_LAYER=1
. Is there a better way to fix this?