Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add history for changes in channel properties dialog #59

Merged
merged 3 commits into from
Aug 12, 2019
Merged
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## [Unreleased] - XXXX-XX-XX
### Added
- Add option to interpolate bad channels ([#55](https://github.com/cbrnr/mnelab/pull/55) by [Victor Férat](https://github.com/vferat))
- Add dialog to show the command history ([#58](https://github.com/cbrnr/mnelab/pull/57) by [Clemens Brunner](https://github.com/cbrnr))
- Add dialog to show the command history ([#58](https://github.com/cbrnr/mnelab/pull/58) by [Clemens Brunner](https://github.com/cbrnr))
- Add history when changing channel properties (e.g. bads, channel names, channel types) ([#59](https://github.com/cbrnr/mnelab/pull/59) by [Clemens Brunner](https://github.com/cbrnr))

### Fixed
- Update view when all bads have been deselected in channel properties dialog (by [Clemens Brunner](https://github.com/cbrnr))
Expand Down
6 changes: 6 additions & 0 deletions mnelab/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@ def edit_events(self):

def plot_data(self):
"""Plot data."""
# self.bad is needed to update history if bad channels are selected in
# the interactive plot window (see also self.eventFilter)
self.bads = self.model.current["data"].info["bads"]
events = self.model.current["events"]
nchan = self.model.current["data"].info["nchan"]
fig = self.model.current["data"].plot(events=events, n_channels=nchan,
Expand Down Expand Up @@ -820,4 +823,7 @@ def eventFilter(self, source, event):
# currently the only source is the raw plot window
if event.type() == QEvent.Close:
self.data_changed()
bads = self.model.current["data"].info["bads"]
if self.bads != bads:
self.model.history.append(f"data.info['bads'] = {bads}")
return QObject.eventFilter(self, source, event)
6 changes: 5 additions & 1 deletion mnelab/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,15 @@ def drop_channels(self, drops):

@data_changed
def set_channel_properties(self, bads=None, names=None, types=None):
self.current["data"].info["bads"] = bads
if bads != self.current["data"].info["bads"]:
self.current["data"].info["bads"] = bads
self.history.append(f"data.info['bads'] = {bads}")
if names:
mne.rename_channels(self.current["data"].info, names)
self.history.append(f"mne.rename_channels(data.info, {names})")
if types:
self.current["data"].set_channel_types(types)
self.history.append(f"data.set_channel_types({types})")

@data_changed
def set_montage(self, montage):
Expand Down