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

Show channel stats #462

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
### Added
- Add close icon to sidebar on hover ([#454](https://github.com/cbrnr/mnelab/pull/454) by [Benedikt Klöckl](https://github.com/bkloeckl))
- Add Python 3.13 support ([#457](https://github.com/cbrnr/mnelab/pull/457) by [Clemens Brunner](https://github.com/cbrnr))
- Add functionality to display channel stats ([#462](https://github.com/cbrnr/mnelab/pull/462) by [Benedikt Klöckl](https://github.com/bkloeckl))

### Changed
- Change the append dialog appearance to include original indices used for identifying the data ([#449](https://github.com/cbrnr/mnelab/pull/449) by [Benedikt Klöckl](https://github.com/bkloeckl))
Expand Down
10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ classifiers = [
]
keywords = ["EEG", "MEG", "MNE", "GUI", "electrophysiology"]
dependencies = [
"mne >= 1.7.0",
"PySide6 >= 6.7.1",
"edfio >= 0.4.2",
"matplotlib >= 3.8.0",
"mne >= 1.7.0",
"numpy >= 2.0.0",
"scipy >= 1.14.1",
"pandas >= 2.2.3",
"pybv >= 0.7.4",
"pyobjc-framework-cocoa >= 10.0; platform_system=='darwin'",
"pyxdf >= 1.16.4",
"pyobjc-framework-Cocoa >= 10.0; platform_system=='Darwin'",
"pyside6 >= 6.7.1",
"scipy >= 1.14.1",
]

dynamic = ["version"]

[project.optional-dependencies]
Expand Down
46 changes: 46 additions & 0 deletions src/mnelab/dialogs/channel_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# © MNELAB developers
#
# License: BSD (3-clause)
from PySide6.QtWidgets import (
QDialog,
QPushButton,
QTableWidget,
QTableWidgetItem,
QVBoxLayout,
)


class ChannelStats(QDialog):
def __init__(self, parent, data):
super().__init__(parent=parent)

# window
self.setWindowTitle("Channel Stats")
self.resize(690, 800)
self.setMinimumSize(200, 150)
self.setMaximumWidth(690)
layout = QVBoxLayout(self)

# table widget
self.table = QTableWidget()
self.table.setRowCount(len(data))
self.table.setColumnCount(len(data.columns))
self.table.setHorizontalHeaderLabels(data.columns)

# populate table
for row in range(len(data)):
for col in range(len(data.columns)):
item = QTableWidgetItem(str(data.iloc[row, col]))
self.table.setItem(row, col, item)

self.table.resizeColumnToContents(0) # name
self.table.resizeColumnToContents(1) # type
self.table.resizeColumnToContents(2) # unit
layout.addWidget(self.table)

# add close button
close_button = QPushButton("Close")
close_button.clicked.connect(self.close)
layout.addWidget(close_button)

self.setLayout(layout)
13 changes: 13 additions & 0 deletions src/mnelab/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from pyxdf import resolve_streams

from mnelab.dialogs import * # noqa: F403
from mnelab.dialogs.channel_stats import ChannelStats
from mnelab.io import writers
from mnelab.io.mat import parse_mat
from mnelab.io.npy import parse_npy
Expand Down Expand Up @@ -315,6 +316,10 @@ def __init__(self, model: Model):
self.show_history,
QKeySequence(Qt.CTRL | Qt.Key_Y),
)
self.actions["channel_stats"] = view_menu.addAction(
"&Channel Stats",
self.show_channel_stats,
)
self.actions["toolbar"] = view_menu.addAction("&Toolbar", self._toggle_toolbar)
self.actions["toolbar"].setCheckable(True)
self.actions["statusbar"] = view_menu.addAction(
Expand Down Expand Up @@ -537,6 +542,9 @@ def data_changed(self):
self.actions["epoch_data"].setEnabled(
enabled and events and self.model.current["dtype"] == "raw"
)
self.actions["channel_stats"].setEnabled(
enabled and self.model.current["dtype"] == "raw"
)
self.actions["drop_bad_epochs"].setEnabled(
enabled and events and self.model.current["dtype"] == "epochs"
)
Expand Down Expand Up @@ -1245,6 +1253,11 @@ def show_history(self):
dialog = HistoryDialog(self, "\n".join(self.model.history))
dialog.exec()

def show_channel_stats(self):
"""Show channel stats."""
dialog = ChannelStats(self, self.model.current["data"].describe(True))
dialog.exec_()

def show_about(self):
"""Show About dialog."""
from . import __version__
Expand Down