Skip to content

Commit 0983fef

Browse files
Merge branch 'main' of github.com:MouseLand/Kilosort
2 parents b2a7fa7 + 7c9fe2e commit 0983fef

15 files changed

Lines changed: 133 additions & 89 deletions

kilosort/gui/converter.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pathlib import Path
33

44
import numpy as np
5-
from PyQt5 import QtCore, QtWidgets
5+
from qtpy import QtCore, QtWidgets
66
from kilosort.io import (
77
RecordingExtractorAsArray, BinaryRWFile, spikeinterface_to_binary, load_probe
88
)
@@ -22,8 +22,8 @@
2222

2323

2424
class DataConversionBox(QtWidgets.QWidget):
25-
disableInput = QtCore.pyqtSignal(bool)
26-
fileObjectLoaded = QtCore.pyqtSignal(bool)
25+
disableInput = QtCore.Signal(bool)
26+
fileObjectLoaded = QtCore.Signal(bool)
2727

2828
def __init__(self, gui):
2929
super().__init__()
@@ -134,7 +134,7 @@ def __init__(self, gui):
134134
self.setLayout(layout)
135135

136136

137-
@QtCore.pyqtSlot()
137+
@QtCore.Slot()
138138
def select_file(self):
139139
options = QtWidgets.QFileDialog.DontUseNativeDialog
140140
filename, _ = QtWidgets.QFileDialog.getOpenFileName(
@@ -148,7 +148,7 @@ def select_file(self):
148148
data_location = Path(filename).parent.as_posix()
149149
self.gui.qt_settings.setValue('last_data_location', data_location)
150150

151-
@QtCore.pyqtSlot()
151+
@QtCore.Slot()
152152
def select_folder(self):
153153
options = QtWidgets.QFileDialog.DontUseNativeDialog
154154
directory = QtWidgets.QFileDialog.getExistingDirectory(
@@ -162,11 +162,11 @@ def select_folder(self):
162162
data_location = Path(directory).as_posix()
163163
self.gui.qt_settings.setValue('last_data_location', data_location)
164164

165-
@QtCore.pyqtSlot()
165+
@QtCore.Slot()
166166
def select_filetype(self):
167167
self.filetype = self.filetype_selector.currentText()
168168

169-
@QtCore.pyqtSlot()
169+
@QtCore.Slot()
170170
def set_stream_id(self):
171171
stream_id = self.stream_id_input.text()
172172
if stream_id is None or stream_id == '':
@@ -175,18 +175,18 @@ def set_stream_id(self):
175175
stream_id = stream_id
176176
self.stream_id = stream_id
177177

178-
@QtCore.pyqtSlot()
178+
@QtCore.Slot()
179179
def set_stream_name(self):
180180
stream_name = self.stream_name_input.text()
181181
if stream_name == '':
182182
stream_name = None
183183
self.stream_name = stream_name
184184

185-
@QtCore.pyqtSlot()
185+
@QtCore.Slot()
186186
def set_dtype(self):
187187
self.data_dtype = self.dtype_selector.currentText()
188188

189-
@QtCore.pyqtSlot()
189+
@QtCore.Slot()
190190
def load_as_wrapper(self):
191191
if None in [self.filename, self.filetype, self.data_dtype]:
192192
logger.exception(
@@ -230,7 +230,7 @@ def load_as_wrapper(self):
230230
)
231231
self.gui.settings_box.check_load()
232232

233-
@QtCore.pyqtSlot()
233+
@QtCore.Slot()
234234
def convert_to_binary(self):
235235
# TODO: add option to specify chunksize for conversion
236236
if None in [self.filename, self.filetype, self.data_dtype]:

kilosort/gui/data_view_box.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
import pyqtgraph as pg
33
from kilosort.gui.logger import setup_logger
44
from kilosort.gui.palettes import COLORMAP_COLORS
5-
from PyQt5 import QtCore, QtWidgets
5+
from qtpy import QtCore, QtWidgets
66

77
logger = setup_logger(__name__)
88

99

1010
class DataViewBox(QtWidgets.QGroupBox):
11-
channelChanged = QtCore.pyqtSignal(int, int)
12-
modeChanged = QtCore.pyqtSignal(str, int)
13-
updateContext = QtCore.pyqtSignal(object)
14-
intervalUpdated = QtCore.pyqtSignal()
11+
channelChanged = QtCore.Signal(int, int)
12+
modeChanged = QtCore.Signal(str, int)
13+
updateContext = QtCore.Signal(object)
14+
intervalUpdated = QtCore.Signal()
1515

1616
def __init__(self, parent):
1717
QtWidgets.QGroupBox.__init__(self, parent=parent)
@@ -191,7 +191,7 @@ def setup(self):
191191

192192
self.setLayout(layout)
193193

194-
@QtCore.pyqtSlot()
194+
@QtCore.Slot()
195195
def on_tmin_edited(self):
196196
try:
197197
self.tmin = float(self.tmin_input.text())
@@ -201,7 +201,7 @@ def on_tmin_edited(self):
201201
except AssertionError:
202202
logger.exception('Invalid tmin,tmax: must have 0 <= tmin < tmax')
203203

204-
@QtCore.pyqtSlot()
204+
@QtCore.Slot()
205205
def on_tmax_edited(self):
206206
try:
207207
self.tmax = float(self.tmax_input.text())
@@ -216,7 +216,7 @@ def check_time_interval(self):
216216
assert self.tmin >= 0
217217
assert self.tmin < self.tmax
218218

219-
@QtCore.pyqtSlot()
219+
@QtCore.Slot()
220220
def on_views_clicked(self):
221221
current_state = {key: self.view_buttons[key].isChecked() for key in self._keys}
222222

@@ -242,22 +242,22 @@ def on_views_clicked(self):
242242

243243
self.update_plot()
244244

245-
@QtCore.pyqtSlot(float)
245+
@QtCore.Slot(float)
246246
def on_wheel_scroll(self, direction):
247247
if self.context_set():
248248
self.shift_current_time(direction)
249249

250-
@QtCore.pyqtSlot(float)
250+
@QtCore.Slot(float)
251251
def on_wheel_scroll_plus_control(self, direction):
252252
if self.context_set():
253253
self.change_displayed_channel_count(direction)
254254

255-
@QtCore.pyqtSlot(float)
255+
@QtCore.Slot(float)
256256
def on_wheel_scroll_plus_shift(self, direction):
257257
if self.context_set():
258258
self.change_plot_range(direction)
259259

260-
@QtCore.pyqtSlot(float)
260+
@QtCore.Slot(float)
261261
def on_wheel_scroll_plus_alt(self, direction):
262262
if self.context_set():
263263
self.change_plot_scaling(direction)
@@ -430,7 +430,7 @@ def change_sorting_status(self, status_dict):
430430
self.sorting_status = status_dict
431431
self.enable_view_buttons()
432432

433-
@QtCore.pyqtSlot()
433+
@QtCore.Slot()
434434
def enable_view_buttons(self):
435435
self.raw_button.click()
436436

@@ -474,11 +474,11 @@ def add_image_to_plot(self, raw_traces, level_min, level_max):
474474
self.colormap_image = image_item
475475
self.plot_item.addItem(image_item)
476476

477-
@QtCore.pyqtSlot(object)
477+
@QtCore.Slot(object)
478478
def set_whitening_matrix(self, array):
479479
self.whitening_matrix = array
480480

481-
@QtCore.pyqtSlot(object)
481+
@QtCore.Slot(object)
482482
def set_highpass_filter(self, filter):
483483
self.highpass_filter = filter
484484

@@ -579,10 +579,10 @@ def _update_colormap(
579579

580580

581581
class KSPlotWidget(pg.PlotWidget):
582-
signalChangeTimePoint = QtCore.pyqtSignal(float)
583-
signalChangeChannel = QtCore.pyqtSignal(float)
584-
signalChangeTimeRange = QtCore.pyqtSignal(float)
585-
signalChangeScaling = QtCore.pyqtSignal(float)
582+
signalChangeTimePoint = QtCore.Signal(float)
583+
signalChangeChannel = QtCore.Signal(float)
584+
signalChangeTimeRange = QtCore.Signal(float)
585+
signalChangeScaling = QtCore.Signal(float)
586586

587587
def __init__(self, *args, **kwargs):
588588
super(KSPlotWidget, self).__init__(*args, **kwargs)

kilosort/gui/header_box.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from kilosort import __version__
22
from kilosort.gui.minor_gui_elements import help_popup_text, controls_popup_text
3-
from PyQt5 import QtCore, QtGui, QtWidgets
3+
from qtpy import QtCore, QtGui, QtWidgets
44

55

66
class HeaderBox(QtWidgets.QWidget):
@@ -55,17 +55,17 @@ def __init__(self, parent):
5555
self.setLayout(self.layout)
5656

5757

58-
@QtCore.pyqtSlot()
58+
@QtCore.Slot()
5959
def check_auto_load(self):
6060
self.gui.auto_load = self.auto_load_check.isChecked()
6161
self.gui.qt_settings.setValue('auto_load', self.gui.auto_load)
6262

63-
@QtCore.pyqtSlot()
63+
@QtCore.Slot()
6464
def check_show_plots(self):
6565
self.gui.show_plots = self.show_plots_check.isChecked()
6666
self.gui.qt_settings.setValue('show_plots', self.gui.show_plots)
6767

68-
@QtCore.pyqtSlot()
68+
@QtCore.Slot()
6969
def clear_cache(self):
7070
self.gui.qt_settings.clear()
7171

kilosort/gui/launch.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import pyqtgraph as pg
44
from kilosort.gui import DarkPalette, KiloSortGUI
5-
from PyQt5 import QtWidgets
5+
from qtpy import QtWidgets, QtGui, QtCore
6+
from pathlib import Path
7+
from kilosort.utils import DOWNLOADS_DIR, download_url_to_file
68

79
# TODO: figure out how to fix margin/padding around tooltip text.
810
# property-margin, margin-right not working as expected.
@@ -20,6 +22,25 @@ def launcher(filename=None):
2022
kilosort_application.setStyle("Fusion")
2123
kilosort_application.setPalette(DarkPalette())
2224
kilosort_application.setStyleSheet(_QSS)
25+
26+
# get icon
27+
DOWNLOADS_DIR.mkdir(parents=True, exist_ok=True)
28+
icon_path = DOWNLOADS_DIR / "logo.png"
29+
if not icon_path.is_file():
30+
print("downloading logo")
31+
download_url_to_file(
32+
"https://www.kilosort.org/static/downloads/kilosort_logo_small.png",
33+
icon_path, progress=True)
34+
icon_path = str(icon_path.resolve())
35+
app_icon = QtGui.QIcon()
36+
app_icon.addFile(icon_path, QtCore.QSize(16, 16))
37+
app_icon.addFile(icon_path, QtCore.QSize(24, 24))
38+
app_icon.addFile(icon_path, QtCore.QSize(32, 32))
39+
app_icon.addFile(icon_path, QtCore.QSize(48, 48))
40+
app_icon.addFile(icon_path, QtCore.QSize(64, 64))
41+
app_icon.addFile(icon_path, QtCore.QSize(256, 256))
42+
43+
kilosort_application.setWindowIcon(app_icon)
2344

2445
pg.setConfigOption("background", "k")
2546
pg.setConfigOption("foreground", "w")

kilosort/gui/logger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import sys
33

4-
from PyQt5 import QtCore
4+
from qtpy import QtCore
55

66

77
class QtHandler(logging.Handler):
@@ -17,7 +17,7 @@ def emit(self, record):
1717
class XStream(QtCore.QObject):
1818
_stdout = None
1919
_stderr = None
20-
messageWritten = QtCore.pyqtSignal(str)
20+
messageWritten = QtCore.Signal(str)
2121

2222
def flush(self):
2323
pass

kilosort/gui/main.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from kilosort.gui.logger import setup_logger
1414
from kilosort.io import BinaryFiltered
1515
from kilosort.utils import DOWNLOADS_DIR, download_probes
16-
from PyQt5 import QtCore, QtGui, QtWidgets
16+
from qtpy import QtCore, QtGui, QtWidgets
1717

1818
logger = setup_logger(__name__)
1919

@@ -275,7 +275,7 @@ def toggle_mode(self, mode):
275275
else:
276276
raise ValueError("Invalid mode requested!")
277277

278-
@QtCore.pyqtSlot(bool)
278+
@QtCore.Slot(bool)
279279
def disable_all_input(self, value):
280280
self.settings_box.disable_all_input(value)
281281
self.run_box.disable_all_input(value)
@@ -417,13 +417,13 @@ def setup_context_for_run(self):
417417
self.load_data()
418418
self.context["params"] = self.params
419419

420-
@QtCore.pyqtSlot(object)
420+
@QtCore.Slot(object)
421421
def update_context(self, context):
422422
self.context = context
423423
self.update_probe_view()
424424
self.update_data_view()
425425

426-
@QtCore.pyqtSlot()
426+
@QtCore.Slot()
427427
def update_probe_view(self):
428428
self.probe_view_box.set_layout(self.context)
429429

@@ -435,15 +435,15 @@ def update_run_box(self):
435435
self.run_box.set_data_path(self.data_path)
436436
self.run_box.set_results_directory(self.results_directory)
437437

438-
@QtCore.pyqtSlot()
438+
@QtCore.Slot()
439439
def disable_run(self):
440440
self.run_box.disable_all_buttons()
441441

442-
@QtCore.pyqtSlot()
442+
@QtCore.Slot()
443443
def enable_run(self):
444444
self.run_box.reenable_buttons()
445445

446-
@QtCore.pyqtSlot(dict)
446+
@QtCore.Slot(dict)
447447
def update_sorting_status(self, status_dict):
448448
self.run_box.change_sorting_status(status_dict)
449449
self.data_view_box.change_sorting_status(status_dict)

kilosort/gui/message_log_box.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
22

33
from kilosort.gui.logger import XStream
4-
from PyQt5 import QtCore, QtGui, QtWidgets
4+
from qtpy import QtCore, QtGui, QtWidgets
55

66

77
class MessageLogBox(QtWidgets.QGroupBox):
@@ -35,18 +35,18 @@ def __init__(self, parent):
3535
XStream.stderr().messageWritten.connect(self.update_text)
3636

3737

38-
@QtCore.pyqtSlot(str)
38+
@QtCore.Slot(str)
3939
def update_text(self, text):
4040
self.log_box.moveCursor(QtGui.QTextCursor.End)
4141
self.log_box.appendPlainText(text)
4242
self.log_box.ensureCursorVisible()
4343
self.popout_window.update_text(text)
4444

45-
@QtCore.pyqtSlot()
45+
@QtCore.Slot()
4646
def show_log_popout(self):
4747
self.popout_window.show()
4848

49-
@QtCore.pyqtSlot()
49+
@QtCore.Slot()
5050
def dump_settings(self):
5151
# For debugging purposes, check for mismatch between displayed parameter
5252
# values and the values that are actually being used.

kilosort/gui/minor_gui_elements.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy as np
22
from kilosort.gui.logger import setup_logger
3-
from PyQt5 import QtGui, QtWidgets, QtCore
3+
from qtpy import QtGui, QtWidgets, QtCore
44

55
logger = setup_logger(__name__)
66

@@ -247,8 +247,7 @@ def get_probe(self):
247247
Welcome to Kilosort4!
248248
249249
##### Documentation #####
250-
Pykilosort is the Python port of Kilosort2, which was originally written in Matlab.
251-
For documentation of the underlying algorithm or the GUI, please visit https://github.com/MouseLand/Kilosort/wiki
250+
For documentation of the underlying algorithm or the GUI, please visit https://github.com/MouseLand/Kilosort/
252251
or https://www.biorxiv.org/content/10.1101/2023.01.07.523036v1.
253252
254253
##### Troubleshooting #####

kilosort/gui/palettes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy as np
2-
from PyQt5 import QtGui
2+
from qtpy import QtGui
33

44

55
class DarkPalette(QtGui.QPalette):

0 commit comments

Comments
 (0)