Skip to content

Commit

Permalink
Changed default channel settings to 32
Browse files Browse the repository at this point in the history
  • Loading branch information
D3njo committed Jul 11, 2024
1 parent 7963cdd commit 8781876
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/mnelab/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,10 @@ def plot_data(self):
self.bads = self.model.current["data"].info["bads"]
events = self.model.current["events"]
nchan = self.model.current["data"].info["nchan"]

if nchan >= read_settings("max_channels"):
nchan = read_settings("max_channels")

fig = self.model.current["data"].plot(
events=events,
n_channels=nchan,
Expand Down
19 changes: 15 additions & 4 deletions src/mnelab/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

_DEFAULTS = {
"max_recent": 6,
"max_channels":32,
"recent": [],
"toolbar": True,
"statusbar": True,
Expand Down Expand Up @@ -78,27 +79,34 @@ def __init__(self, parent, backends):
self.plot_backend.setCurrentIndex(backends.index(backend))
grid.addWidget(self.plot_backend, 0, 1)

grid.addWidget(QLabel("Maximum recent files:"), 1, 0)
grid.addWidget(QLabel("Recent files:"), 1, 0)
self.max_recent = QSpinBox()
self.max_recent.setRange(5, 25)
self.max_recent.setValue(_get_value("max_recent"))
self.max_recent.setAlignment(Qt.AlignRight)
grid.addWidget(self.max_recent, 1, 1)

grid.addWidget(QLabel("Displayed channels:"), 2, 0)
self.max_channels = QSpinBox()
self.max_channels.setRange(1, 256)
self.max_channels.setValue(_get_value("max_channels"))
self.max_channels.setAlignment(Qt.AlignRight)
grid.addWidget(self.max_channels, 2, 1)

self.reset_to_defaults = QPushButton("Reset to defaults")
self.reset_to_defaults.clicked.connect(self.reset_settings)
grid.addWidget(self.reset_to_defaults, 2, 0)
grid.addWidget(self.reset_to_defaults, 3, 0)

self.reset_to_defaults = QPushButton("Reset window")
self.reset_to_defaults.clicked.connect(self.reset_window)
grid.addWidget(self.reset_to_defaults, 3, 0)
grid.addWidget(self.reset_to_defaults, 4, 0)

hbox = QHBoxLayout()
self.buttonbox = QDialogButtonBox(
QDialogButtonBox.Apply | QDialogButtonBox.Ok | QDialogButtonBox.Cancel
)
hbox.addWidget(self.buttonbox)
grid.addLayout(hbox, 4, 0, 1, 2)
grid.addLayout(hbox, 5, 0, 1, 2)
self.buttonbox.button(QDialogButtonBox.Apply).clicked.connect(self.apply_settings)
self.buttonbox.accepted.connect(self.accept)
self.buttonbox.accepted.connect(self.apply_settings)
Expand All @@ -108,12 +116,15 @@ def __init__(self, parent, backends):
def apply_settings(self):
QSettings().setValue("max_recent", int(self.max_recent.text()))
self.parent().recent = self.parent().recent[: _get_value("max_recent")]
QSettings().setValue("max_channels", int(self.max_channels.text()))
self.parent().recent = self.parent().recent[: _get_value("max_channels")]
QSettings().setValue("recent", self.parent().recent)
QSettings().setValue("plot_backend", self.plot_backend.currentText())

@Slot()
def reset_settings(self):
self.max_recent.setValue(_DEFAULTS["max_recent"])
self.max_channels.setValue(_DEFAULTS["max_channels"])
self.plot_backend.setValue(_DEFAULTS["plot_backend"])

@Slot()
Expand Down

0 comments on commit 8781876

Please sign in to comment.