Compare commits
No commits in common. "56c8b59ccd8f61323fd2ec10014e3975c1de5845" and "c33e4cc32fc784bc7c74ddef1b7689a94d2f0964" have entirely different histories.
56c8b59ccd
...
c33e4cc32f
@ -6,13 +6,11 @@ from PyQt6.QtWidgets import QApplication
|
|||||||
from pyrelacs import info
|
from pyrelacs import info
|
||||||
from pyrelacs.ui.mainwindow import PyRelacs
|
from pyrelacs.ui.mainwindow import PyRelacs
|
||||||
from pyrelacs.util.logging import config_logging
|
from pyrelacs.util.logging import config_logging
|
||||||
|
import resources
|
||||||
|
|
||||||
log = config_logging()
|
log = config_logging()
|
||||||
|
|
||||||
from pyrelacs import (
|
from . import resources # best created with pyside6-rcc resources.qrc -o resources.py (rcc produces an error...)
|
||||||
resources,
|
|
||||||
) # best created with pyside6-rcc resources.qrc -o resources.py (rcc produces an error...)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
|
@ -44,7 +44,6 @@ class PyRelacs(QMainWindow):
|
|||||||
self.power_plot.addLegend()
|
self.power_plot.addLegend()
|
||||||
self.beat_plot.setBackground("w")
|
self.beat_plot.setBackground("w")
|
||||||
self.power_plot.setBackground("w")
|
self.power_plot.setBackground("w")
|
||||||
self.power_plot.setLogMode(x=False, y=True)
|
|
||||||
|
|
||||||
self.threadpool = QThreadPool()
|
self.threadpool = QThreadPool()
|
||||||
self.repros = Repro()
|
self.repros = Repro()
|
||||||
@ -68,10 +67,7 @@ class PyRelacs(QMainWindow):
|
|||||||
self.setCentralWidget(widget)
|
self.setCentralWidget(widget)
|
||||||
|
|
||||||
filename = path.joinpath(path.cwd(), "data.nix")
|
filename = path.joinpath(path.cwd(), "data.nix")
|
||||||
if filename.exists():
|
self.nix_file = nix.File.open(str(filename), nix.FileMode.ReadWrite)
|
||||||
self.nix_file = nix.File.open(str(filename), nix.FileMode.ReadOnly)
|
|
||||||
else:
|
|
||||||
self.nix_file = nix.File.open(str(filename), nix.FileMode.Overwrite)
|
|
||||||
|
|
||||||
def create_actions(self):
|
def create_actions(self):
|
||||||
self._rlx_exitaction = QAction(QIcon(":/icons/exit.png"), "Exit", self)
|
self._rlx_exitaction = QAction(QIcon(":/icons/exit.png"), "Exit", self)
|
||||||
@ -84,23 +80,17 @@ class PyRelacs(QMainWindow):
|
|||||||
self._rlx_aboutaction.setEnabled(True)
|
self._rlx_aboutaction.setEnabled(True)
|
||||||
self._rlx_aboutaction.triggered.connect(self.on_about)
|
self._rlx_aboutaction.triggered.connect(self.on_about)
|
||||||
|
|
||||||
self._daq_connectaction = QAction(
|
self._daq_connectaction = QAction(QIcon(":icons/connect.png"), "Connect DAQ", self)
|
||||||
QIcon(":icons/connect.png"), "Connect DAQ", self
|
|
||||||
)
|
|
||||||
self._daq_connectaction.setStatusTip("Connect to daq device")
|
self._daq_connectaction.setStatusTip("Connect to daq device")
|
||||||
# self._daq_connectaction.setShortcut(QKeySequence("Alt+d"))
|
# self._daq_connectaction.setShortcut(QKeySequence("Alt+d"))
|
||||||
self._daq_connectaction.triggered.connect(self.connect_dac)
|
self._daq_connectaction.triggered.connect(self.connect_dac)
|
||||||
|
|
||||||
self._daq_disconnectaction = QAction(
|
self._daq_disconnectaction = QAction(QIcon(":/icons/disconnect.png"), "Disconnect DAQ", self)
|
||||||
QIcon(":/icons/disconnect.png"), "Disconnect DAQ", self
|
|
||||||
)
|
|
||||||
self._daq_disconnectaction.setStatusTip("Disconnect the DAQ device")
|
self._daq_disconnectaction.setStatusTip("Disconnect the DAQ device")
|
||||||
# self._daq_connectaction.setShortcut(QKeySequence("Alt+d"))
|
# self._daq_connectaction.setShortcut(QKeySequence("Alt+d"))
|
||||||
self._daq_disconnectaction.triggered.connect(self.disconnect_dac)
|
self._daq_disconnectaction.triggered.connect(self.disconnect_dac)
|
||||||
|
|
||||||
self._daq_calibaction = QAction(
|
self._daq_calibaction = QAction(QIcon(":/icons/calibration.png"), "Plot calibration", self)
|
||||||
QIcon(":/icons/calibration.png"), "Plot calibration", self
|
|
||||||
)
|
|
||||||
self._daq_calibaction.setStatusTip("Calibrate the attenuator device")
|
self._daq_calibaction.setStatusTip("Calibrate the attenuator device")
|
||||||
# self._daq_calibaction.setShortcut(QKeySequence("Alt+d"))
|
# self._daq_calibaction.setShortcut(QKeySequence("Alt+d"))
|
||||||
self._daq_calibaction.triggered.connect(self.plot_calibration)
|
self._daq_calibaction.triggered.connect(self.plot_calibration)
|
||||||
@ -215,24 +205,21 @@ class PyRelacs(QMainWindow):
|
|||||||
beat = stim[:] + fish[:]
|
beat = stim[:] + fish[:]
|
||||||
beat_squared = beat**2
|
beat_squared = beat**2
|
||||||
|
|
||||||
f, powerspec = welch(
|
f, powerspec = welch(beat, fs=40_000.0)
|
||||||
beat_squared,
|
powerspec = decibel(powerspec)
|
||||||
window="flattop",
|
|
||||||
fs=40_000.0,
|
|
||||||
nperseg=100_000,
|
|
||||||
)
|
|
||||||
|
|
||||||
peaks = find_peaks(powerspec, prominence=0.001)[0]
|
f_sq, powerspec_sq = welch(beat_squared, fs=40_000.0)
|
||||||
|
powerspec_sq = decibel(powerspec_sq)
|
||||||
|
peaks = find_peaks(powerspec_sq, prominence=10)[0]
|
||||||
pen = pg.mkPen(colors[i])
|
pen = pg.mkPen(colors[i])
|
||||||
|
|
||||||
self.beat_plot.plot(
|
self.beat_plot.plot(
|
||||||
np.arange(0, len(beat)) / 40_000.0,
|
np.arange(0, len(beat)) / 40_000.0,
|
||||||
beat,
|
beat_squared,
|
||||||
pen=pen,
|
pen=pen,
|
||||||
name=stim.name,
|
name=stim.name,
|
||||||
)
|
)
|
||||||
self.power_plot.plot(f, powerspec, pen=pen, name=stim.name)
|
self.power_plot.plot(f_sq, powerspec_sq, pen=pen, name=stim.name)
|
||||||
self.power_plot.plot(f[peaks], powerspec[peaks], pen=None, symbol="x")
|
self.power_plot.plot(f[peaks], powerspec_sq[peaks], pen=None, symbol="x")
|
||||||
|
|
||||||
def connect_dac(self):
|
def connect_dac(self):
|
||||||
devices = uldaq.get_daq_device_inventory(uldaq.InterfaceType.USB)
|
devices = uldaq.get_daq_device_inventory(uldaq.InterfaceType.USB)
|
||||||
@ -274,12 +261,8 @@ class PyRelacs(QMainWindow):
|
|||||||
|
|
||||||
self.threadpool.start(worker)
|
self.threadpool.start(worker)
|
||||||
|
|
||||||
def add_to_textfield(self, s: str):
|
|
||||||
self.text.appendPlainText(s)
|
|
||||||
|
|
||||||
def on_exit(self):
|
def on_exit(self):
|
||||||
log.info("exit button!")
|
print("exit button!")
|
||||||
self.add_to_textfield("exiting")
|
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def on_about(self, e):
|
def on_about(self, e):
|
||||||
@ -287,12 +270,10 @@ class PyRelacs(QMainWindow):
|
|||||||
about.show()
|
about.show()
|
||||||
|
|
||||||
def print_output(self, s):
|
def print_output(self, s):
|
||||||
log.info(s)
|
print(s)
|
||||||
self.add_to_textfield(s)
|
|
||||||
|
|
||||||
def thread_complete(self):
|
def thread_complete(self):
|
||||||
log.info("Thread complete!")
|
print("THREAD COMPLETE!")
|
||||||
self.add_to_textfield("Thread complete!")
|
|
||||||
|
|
||||||
def progress_fn(self, n):
|
def progress_fn(self, n):
|
||||||
print("%d%% done" % n)
|
print("%d%% done" % n)
|
||||||
|
Loading…
Reference in New Issue
Block a user