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