Commit 5979f12
committed
ENH: plot variable-duration epochs without padding
The epochs browser already draws its trials as a pseudo-continuous strip,
concatenating them and ruling a line at each boundary, so ragged epochs
need the samples they actually hold rather than a padded copy. plot()
leaves the not-implemented table and becomes native.
The x axis is built from those samples:
lengths = per-epoch sample counts
boundary_samples = np.r_[0, np.cumsum(lengths)]
boundary_times = boundary_samples / sfreq
n_times = boundary_samples[-1]
_n_times_per_epoch returns len(times) when durations are equal, so this
is one code path and reproduces the previous uniform grid exactly while
never reading `times`, which variable-duration epochs refuse to provide.
A window of k epochs from index i spans boundary_times[i + k] minus
boundary_times[i]; _epoch_window computes that for both backends, and
_get_start_stop and _load_data share _get_epoch_ix_range so the sample
bounds and the concatenated array agree by construction. That is what
makes the existing shape assertions meaningful for ragged windows.
Arrow keys step whole epochs and shift steps whole windows, home and end
ask the boundaries how many seconds an epoch is worth, and the scrollbar
draws each epoch at its own width. Vertical lines mark a latency relative
to each epoch's own event and are omitted from epochs too short to reach
it, replacing arithmetic that took the remainder against one duration.
Events map through each epoch's own window; the fixed path keeps its
existing bounds, whose upper limit overshoots the last sample by |tmin|,
rather than have that copied.
_compute_scalings failed first of all, before any of the above, since it
reshaped _data as an array. ICA sources reach the same browser without
supplying the new per-epoch arrays, so those are derived from the
boundaries when absent.
Non-matplotlib backends decline with a message naming matplotlib until
mne-qt-browser can consume boundary_times, boundary_samples and n_times,
which the params dict now carries; the browser tests skip there for the
same reason.1 parent 34809b9 commit 5979f12
7 files changed
Lines changed: 442 additions & 59 deletions
File tree
- mne
- tests
- viz
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4066 | 4066 | | |
4067 | 4067 | | |
4068 | 4068 | | |
4069 | | - | |
4070 | 4069 | | |
4071 | 4070 | | |
4072 | 4071 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
262 | 269 | | |
263 | 270 | | |
264 | 271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
47 | 78 | | |
48 | 79 | | |
49 | 80 | | |
| |||
78 | 109 | | |
79 | 110 | | |
80 | 111 | | |
81 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
82 | 119 | | |
83 | 120 | | |
84 | 121 | | |
| |||
120 | 157 | | |
121 | 158 | | |
122 | 159 | | |
123 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
124 | 166 | | |
125 | 167 | | |
126 | 168 | | |
| |||
157 | 199 | | |
158 | 200 | | |
159 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
160 | 219 | | |
161 | 220 | | |
162 | 221 | | |
| |||
328 | 387 | | |
329 | 388 | | |
330 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
331 | 411 | | |
332 | 412 | | |
333 | 413 | | |
334 | 414 | | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
339 | 420 | | |
340 | 421 | | |
341 | 422 | | |
| |||
355 | 436 | | |
356 | 437 | | |
357 | 438 | | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
| 439 | + | |
365 | 440 | | |
366 | 441 | | |
367 | 442 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
492 | | - | |
| 492 | + | |
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
| |||
791 | 791 | | |
792 | 792 | | |
793 | 793 | | |
794 | | - | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
795 | 803 | | |
796 | 804 | | |
797 | | - | |
798 | | - | |
799 | | - | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
800 | 808 | | |
801 | 809 | | |
802 | 810 | | |
| |||
828 | 836 | | |
829 | 837 | | |
830 | 838 | | |
| 839 | + | |
831 | 840 | | |
832 | | - | |
833 | | - | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
834 | 848 | | |
835 | | - | |
836 | | - | |
837 | | - | |
| 849 | + | |
838 | 850 | | |
839 | 851 | | |
840 | 852 | | |
| |||
843 | 855 | | |
844 | 856 | | |
845 | 857 | | |
846 | | - | |
847 | | - | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
848 | 862 | | |
849 | 863 | | |
850 | 864 | | |
| |||
998 | 1012 | | |
999 | 1013 | | |
1000 | 1014 | | |
1001 | | - | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
1002 | 1019 | | |
1003 | 1020 | | |
1004 | 1021 | | |
| |||
1917 | 1934 | | |
1918 | 1935 | | |
1919 | 1936 | | |
1920 | | - | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
1921 | 1941 | | |
1922 | 1942 | | |
1923 | 1943 | | |
| |||
2252 | 2272 | | |
2253 | 2273 | | |
2254 | 2274 | | |
2255 | | - | |
2256 | | - | |
2257 | | - | |
| 2275 | + | |
2258 | 2276 | | |
2259 | | - | |
| 2277 | + | |
2260 | 2278 | | |
2261 | 2279 | | |
2262 | 2280 | | |
| |||
2408 | 2426 | | |
2409 | 2427 | | |
2410 | 2428 | | |
2411 | | - | |
2412 | | - | |
2413 | | - | |
2414 | | - | |
2415 | | - | |
2416 | | - | |
2417 | | - | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
2418 | 2454 | | |
2419 | 2455 | | |
2420 | 2456 | | |
2421 | | - | |
| 2457 | + | |
2422 | 2458 | | |
2423 | | - | |
| 2459 | + | |
2424 | 2460 | | |
2425 | 2461 | | |
2426 | 2462 | | |
2427 | 2463 | | |
2428 | | - | |
2429 | | - | |
2430 | | - | |
| 2464 | + | |
| 2465 | + | |
2431 | 2466 | | |
2432 | 2467 | | |
2433 | 2468 | | |
| |||
0 commit comments