From 5bf5da2291e011de9a249777126fbab7f5fdc091 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 24 Mar 2022 13:56:53 +0100 Subject: [PATCH 1/2] Show more on events in info widget --- mnelab/model.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mnelab/model.py b/mnelab/model.py index 64a374a9..a06d7175 100644 --- a/mnelab/model.py +++ b/mnelab/model.py @@ -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 = "-" From 23f9f21d265705dc871746b4bdecbabe4db0c8da Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 24 Mar 2022 14:02:25 +0100 Subject: [PATCH 2/2] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9db368c5..6860b560 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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))