|
16 | 16 | _get_stim_channel, |
17 | 17 | _validate_type, |
18 | 18 | legacy, |
| 19 | + sizeof_fmt, |
19 | 20 | verbose, |
20 | 21 | ) |
21 | 22 | from ..utils.spectrum import _split_psd_kwargs |
@@ -137,8 +138,9 @@ def plot_raw( |
137 | 138 | show_options : bool |
138 | 139 | If True, a dialog for options related to projection is shown. |
139 | 140 | title : str | None |
140 | | - The title of the window. If None, and either the filename of the |
141 | | - raw object or '<unknown>' will be displayed as title. |
| 141 | + The title of the window. If None, the filename of the raw object is |
| 142 | + used; for in-memory instances without a filename (e.g., |
| 143 | + `~mne.io.RawArray`), the class name and approximate size are used. |
142 | 144 | show : bool |
143 | 145 | Show figure if True. |
144 | 146 | block : bool |
@@ -369,16 +371,18 @@ def plot_raw( |
369 | 371 | start += first_time |
370 | 372 | event_id_rev = {v: k for k, v in (event_id or {}).items()} |
371 | 373 |
|
372 | | - # generate window title; allow instances without a filename (e.g., ICA) |
| 374 | + # generate window title; allow instances without a filename (e.g., RawArray) |
373 | 375 | if title is None: |
374 | | - title = "<unknown>" |
375 | | - fnames = list(tuple(raw.filenames)) # get a list of a copy of the filenames |
| 376 | + # in-memory instances (e.g., RawArray) have filenames of (None,) |
| 377 | + fnames = [fname for fname in raw.filenames if fname is not None] |
376 | 378 | if len(fnames): |
377 | 379 | title = fnames.pop(0) |
378 | 380 | extra = f" ... (+ {len(fnames)} more)" if len(fnames) else "" |
379 | 381 | title = f"{title}{extra}" |
380 | 382 | if len(title) > 60: |
381 | 383 | title = _shorten_path_from_middle(title) |
| 384 | + else: # give at least a hint about the data being shown |
| 385 | + title = f"{type(raw).__name__} (~{sizeof_fmt(raw._size)})" |
382 | 386 | elif not isinstance(title, str): |
383 | 387 | raise TypeError(f"title must be None or a string, got a {type(title)}") |
384 | 388 |
|
|
0 commit comments