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 more on events in info widget #335

Merged
merged 2 commits into from
Mar 24, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- Replace "(channels dropped)" suffix with "(channels picked)" and use `pick_channels` instead of `drop_channels` ([#285](https://github.com/cbrnr/mnelab/pull/285) by [Florian Hofer](https://github.com/hofaflo))
- The overwrite confirmation dialog is now fail-safe because it defaults to creating a new dataset ([#304](https://github.com/cbrnr/mnelab/pull/304) by [Clemens Brunner](https://github.com/cbrnr))
- Show signal length in hours, minutes, and seconds ([#334](https://github.com/cbrnr/mnelab/pull/334) by [Clemens Brunner](https://github.com/cbrnr))
- Show unique event counts if there are no more than seven unique event types in the main window ([#335](https://github.com/cbrnr/mnelab/pull/335) by [Clemens Brunner](https://github.com/cbrnr))

### Fixed
- Fix splitting name and extension for compatibility with Python 3.8 ([#252](https://github.com/cbrnr/mnelab/pull/252) by [Johan Medrano](https://github.com/yop0))
Expand Down
17 changes: 10 additions & 7 deletions mnelab/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,17 @@ def get_info(self):
chans = ", ".join([" ".join([str(v), k.upper()]) for k, v in chans])

if events is not None and events.shape[0] > 0:
nevents = events.shape[0]
unique = [str(e) for e in sorted(set(events[:, 2]))]
if len(unique) > 20: # do not show all events
first = ", ".join(unique[:10])
last = ", ".join(unique[-10:])
events = f"{nevents} ({first + ', ..., ' + last})"
unique, counts = np.unique(events[:, 2], return_counts=True)
events = f"{events.shape[0]} ("
if len(unique) < 8:
events += ", ".join([f"{u}: {c}" for u, c in zip(unique, counts)])
elif 8 <= len(unique) <= 12:
events += ", ".join([f"{u}" for u in unique])
else:
events = f"{nevents} ({', '.join(unique)})"
first = ", ".join([f"{u}" for u in unique[:6]])
last = ", ".join([f"{u}" for u in unique[-6:]])
events += f"{first}, ..., {last}"
events += ")"
else:
events = "-"

Expand Down