Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to qtpy/pyqt6 #125

Merged
merged 9 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ jobs:
- name: Install Linux libraries
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 \
libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 \
libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0
libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 pkg-config libhdf5-103 libhdf5-dev \
libegl1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ FaceMap/ops_user.npy
*.sh
*.pkl
*.h5

*.mp4
#
# =========================
# Operating System Files
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The software has been heavily tested on Ubuntu 18.04, and less well tested on Wi

Facemap python relies on these awesome packages:
- [pyqtgraph](http://pyqtgraph.org/)
- [PyQt5](http://pyqt.sourceforge.net/Docs/PyQt5/)
- [PyQt6](http://pyqt.sourceforge.net/Docs/PyQt6/)
- [numpy](http://www.numpy.org/) (>=1.13.0)
- [scipy](https://www.scipy.org/)
- [opencv](https://opencv.org/)
Expand Down
4 changes: 2 additions & 2 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Dependencies
Facemap (python package) relies on these awesome packages:

- `pyqtgraph`_
- `pyqt5`_
- `pyqt6`_
- `numpy`_ (>=1.13.0)
- `scipy`_
- `opencv`_
Expand All @@ -40,7 +40,7 @@ Facemap (python package) relies on these awesome packages:
- `UMAP`_

.. _pyqtgraph: http://pyqtgraph.org/
.. _pyqt5: http://pyqt.sourceforge.net/Docs/PyQt5/
.. _pyqt6: http://pyqt.sourceforge.net/Docs/PyQt6/
.. _numpy: http://www.numpy.org/
.. _scipy: https://www.scipy.org/
.. _opencv: https://opencv.org/
Expand Down
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies:
- torch>=1.9
- h5py
- pyqtgraph>=0.12.0
- pyqt5
- pyqt5.sip
- qtpy
- pyqt6
- umap-learn

5 changes: 4 additions & 1 deletion facemap/.github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ jobs:
- name: Install Linux libraries
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 \
libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 \
libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0
libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 pkg-config libhdf5-103 libhdf5-dev \
libegl1 libgl1
sudo apt-get install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
# strategy borrowed from vispy for installing opengl libs on windows
- name: Install Windows OpenGL
if: runner.os == 'Windows'
Expand Down
14 changes: 7 additions & 7 deletions facemap/gui/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

# import hdbscan
from matplotlib import cm
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import (
from qtpy import QtCore, QtWidgets
from qtpy.QtGui import QFont
from qtpy.QtWidgets import (
QButtonGroup,
QCheckBox,
QLabel,
Expand Down Expand Up @@ -408,9 +408,9 @@ def run(self, clicked, parent):
else:
self.data_type = None
msg = QMessageBox(parent)
msg.setIcon(QMessageBox.Warning)
msg.setIcon(QMessageBox.Icon.Warning)
msg.setText("Please select data for clustering")
msg.setStandardButtons(QMessageBox.Ok)
msg.setStandardButtons(QMessageBox.StandardButton.Ok)
msg.exec_()
return
if self.cluster_method == "UMAP":
Expand Down Expand Up @@ -718,9 +718,9 @@ def ok_save(self, dialogBox, parent):
pass
else:
msg = QMessageBox(parent)
msg.setIcon(QMessageBox.Warning)
msg.setIcon(QMessageBox.Icon.Warning)
msg.setText("Please generate cluster labels for saving cluster videos")
msg.setStandardButtons(QMessageBox.Ok)
msg.setStandardButtons(QMessageBox.StandardButton.Ok)
msg.exec_()
if dialogBox.data_checkbox.isChecked():
self.save_cluster_output(parent)
Expand Down
34 changes: 17 additions & 17 deletions facemap/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,18 @@
import sys
from pathlib import Path

import cv2
import h5py
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pyqtgraph as pg
import scipy.io as sio
import torch
from matplotlib import cm
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtGui import QFont, QIcon, QPainterPath
from PyQt5.QtWidgets import (
from qtpy import QtCore, QtWidgets, QtGui
from qtpy.QtGui import QFont, QIcon, QPainterPath
from qtpy.QtWidgets import (
QButtonGroup,
QCheckBox,
QComboBox,
QDesktopWidget,
QFileDialog,
QGridLayout,
QGroupBox,
Expand Down Expand Up @@ -125,18 +121,22 @@ def __init__(
self.scene_grid_layout = QGridLayout()
self.central_widget.setLayout(self.scene_grid_layout)
# --- cells image
self.sizeObject = QDesktopWidget().screenGeometry(-1)
self.sizeObject = QtGui.QGuiApplication.primaryScreen().availableGeometry()
self.resize(self.sizeObject.width(), self.sizeObject.height())

self.video_window = pg.GraphicsLayoutWidget()
self.video_window.viewport().setAttribute(QtCore.Qt.WidgetAttribute.WA_AcceptTouchEvents, False)

self.scene_grid_layout.addWidget(self.video_window, 0, 2, 5, 5)

# Create a window for embedding and ROI plot
self.roi_embed_window = pg.GraphicsLayoutWidget()
self.roi_embed_window.viewport().setAttribute(QtCore.Qt.WidgetAttribute.WA_AcceptTouchEvents, False)
self.scene_grid_layout.addWidget(self.roi_embed_window, 0, 7, 5, 5)

# Create a window for plots
self.plots_window = pg.GraphicsLayoutWidget()
self.plots_window.viewport().setAttribute(QtCore.Qt.WidgetAttribute.WA_AcceptTouchEvents, False)
self.scene_grid_layout.addWidget(self.plots_window, 5, 2, 4, 10)

# A plot area (ViewBox + axes) for displaying the image
Expand Down Expand Up @@ -833,17 +833,17 @@ def add_pose_model(self, pose_model_path=None):
break
# Display QMessage box to inform user that the model was successfully added
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setIcon(QMessageBox.Icon.Information)
msg.setText("Pose model successfully added.")
msg.setWindowTitle("Pose model added")
msg.setStandardButtons(QMessageBox.Ok)
msg.setStandardButtons(QMessageBox.StandardButton.Ok)
msg.exec_()
except Exception as e:
msg = QMessageBox()
msg.setIcon(QMessageBox.Error)
msg.setIcon(QMessageBox.Icon.Critical)
msg.setText("Pose model not added. Error: " + str(e))
msg.setWindowTitle("Eror")
msg.setStandardButtons(QMessageBox.Ok)
msg.setStandardButtons(QMessageBox.StandardButton.Ok)
msg.exec_()


Expand Down Expand Up @@ -2255,7 +2255,7 @@ def load_video_popup(self):
# Open a qmessage box to notify the user that the video is not loaded
msg = QtWidgets.QMessageBox()
# Error icon in the top left corner
msg.setIcon(QtWidgets.QMessageBox.Critical)
msg.setIcon(QtWidgets.QMessageBox.Icon.Critical)
msg.setText("Please load a video first.")
msg.setWindowTitle("No video loaded")
msg.exec_()
Expand All @@ -2269,16 +2269,16 @@ def invalid_trace_popup(self):

def invalid_roi_popup(self):
msg = QMessageBox(self)
msg.setIcon(QMessageBox.Warning)
msg.setIcon(QMessageBox.Icon.Warning)
msg.setText("only pupil ROI allowed during online mode")
msg.setStandardButtons(QMessageBox.Ok)
msg.setStandardButtons(QMessageBox.StandardButton.Ok)
msg.exec_()

def show_roi_selection_error(self):
msg = QMessageBox(self)
msg.setIcon(QMessageBox.Warning)
msg.setIcon(QMessageBox.Icon.Warning)
msg.setText("Please select a ROI")
msg.setStandardButtons(QMessageBox.Ok)
msg.setStandardButtons(QMessageBox.StandardButton.Ok)
msg.exec_()

def model_loaded_popup(self, model_path):
Expand Down
6 changes: 3 additions & 3 deletions facemap/gui/guiparts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"""
import numpy as np
import pyqtgraph as pg
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import (
from qtpy import QtCore, QtGui, QtWidgets
from qtpy.QtWidgets import (
QAbstractItemView,
QButtonGroup,
QDialog,
Expand Down Expand Up @@ -232,7 +232,7 @@ class ImageDraw(pg.ImageItem):
for controlling the levels and lookup table used to display the image.
"""

sigImageChanged = QtCore.pyqtSignal()
sigImageChanged = QtCore.Signal()

def __init__(self, image=None, viewbox=None, parent=None, **kargs):
super(ImageDraw, self).__init__()
Expand Down
11 changes: 5 additions & 6 deletions facemap/gui/help_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
import typing

import numpy as np
from PyQt5 import QtCore
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import (
QDesktopWidget,
from qtpy import QtCore
from qtpy.QtCore import Qt
from qtpy.QtGui import QPixmap, QGuiApplication
from qtpy.QtWidgets import (
QDialog,
QGroupBox,
QHBoxLayout,
Expand Down Expand Up @@ -510,7 +509,7 @@ def __init__(self, gui, window_title):
super().__init__(gui)
self.gui = gui
self.setWindowTitle(window_title)
window_size = QDesktopWidget().screenGeometry(-1)
window_size = QGuiApplication.primaryScreen().availableGeometry()
self.setFixedSize(
int(np.floor(window_size.width() * 0.31)),
int(np.floor(window_size.height() * 0.31 * 0.5)),
Expand Down
18 changes: 9 additions & 9 deletions facemap/gui/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import numpy as np
from natsort import natsorted
from PyQt5.QtWidgets import QFileDialog, QMessageBox
from qtpy.QtWidgets import QFileDialog, QMessageBox

from facemap import roi, utils

Expand Down Expand Up @@ -279,7 +279,7 @@ def get_folder_path(parent):
else:
# Open a qmessagebox to inform the user that the path does not exist
msg = QMessageBox()
msg.setIcon(QMessageBox.Warning)
msg.setIcon(QMessageBox.Icon.Warning)
msg.setText("The path does not exist")
msg.setWindowTitle("Warning")
msg.exec_()
Expand Down Expand Up @@ -367,7 +367,7 @@ def load_npy_file(parent, allow_mat=False):
else:
# Open a qmessagebox to inform the user that the path does not exist
msg = QMessageBox()
msg.setIcon(QMessageBox.Warning)
msg.setIcon(QMessageBox.Icon.Warning)
msg.setText("The path does not exist")
msg.setWindowTitle("Warning")
msg.exec_()
Expand Down Expand Up @@ -423,9 +423,9 @@ def load_cluster_labels(parent):
return
except Exception as e:
msg = QMessageBox(parent)
msg.setIcon(QMessageBox.Warning)
msg.setIcon(QMessageBox.Icon.Warning)
msg.setText("Error: not a supported filetype")
msg.setStandardButtons(QMessageBox.Ok)
msg.setStandardButtons(QMessageBox.StandardButton.Ok)
msg.exec_()
print(e)

Expand Down Expand Up @@ -457,9 +457,9 @@ def load_umap(parent):
return embedded_data
except Exception as e:
msg = QMessageBox(parent)
msg.setIcon(QMessageBox.Warning)
msg.setIcon(QMessageBox.Icon.Warning)
msg.setText("Error: not a supported filetype")
msg.setStandardButtons(QMessageBox.Ok)
msg.setStandardButtons(QMessageBox.StandardButton.Ok)
msg.exec_()
print(e)

Expand All @@ -480,9 +480,9 @@ def load_trace_data(parent):
return dat
except Exception as e:
msg = QMessageBox(parent)
msg.setIcon(QMessageBox.Warning)
msg.setIcon(QMessageBox.Icon.Warning)
msg.setText("Error: not a supported filetype")
msg.setStandardButtons(QMessageBox.Ok)
msg.setStandardButtons(QMessageBox.StandardButton.Ok)
msg.exec_()
print(e)

Expand Down
7 changes: 4 additions & 3 deletions facemap/gui/menus.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""
Copright © 2023 Howard Hughes Medical Institute, Authored by Carsen Stringer and Atika Syeda.
"""
from PyQt5.QtWidgets import QAction, QDesktopWidget
from qtpy.QtWidgets import QAction
from qtpy.QtGui import QGuiApplication

from . import help_windows, io

Expand Down Expand Up @@ -116,8 +117,8 @@ def mainmenu(parent):


def launch_user_manual(parent):
help_windows.MainWindowHelp(parent, QDesktopWidget().screenGeometry(-1))
help_windows.MainWindowHelp(parent, QGuiApplication.primaryScreen().availableGeometry())


def show_about(parent):
help_windows.AboutWindow(parent, QDesktopWidget().screenGeometry(-1))
help_windows.AboutWindow(parent, QGuiApplication.primaryScreen().availableGeometry())
Loading