Skip to content

Commit

Permalink
Show more on events in info widget (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrnr authored Mar 24, 2022
1 parent 5a3403a commit a9f921b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
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

0 comments on commit a9f921b

Please sign in to comment.