|
19 | 19 |
|
20 | 20 | # %% |
21 | 21 |
|
| 22 | +import sys |
| 23 | + |
22 | 24 | import mne |
23 | 25 |
|
24 | 26 | data_path = mne.datasets.sample.data_path() |
|
44 | 46 |
|
45 | 47 | # %% |
46 | 48 | # Remove components with postural muscle artifact using ICA |
47 | | -ica.plot_sources(raw) |
| 49 | +if sys.platform != "emscripten": |
| 50 | + ica.plot_sources(raw) |
48 | 51 |
|
49 | 52 | # %% |
50 | 53 | # By inspection, let's select out the muscle-artifact components based on |
|
71 | 74 | # slope in log-log units; this is a very typical pattern for muscle artifact. |
72 | 75 |
|
73 | 76 | muscle_idx = [6, 7, 8, 9, 10, 11, 12, 13, 14] |
74 | | -ica.plot_properties(raw, picks=muscle_idx, log_scale=True) |
| 77 | +if sys.platform != "emscripten": |
| 78 | + ica.plot_properties(raw, picks=muscle_idx, log_scale=True) |
75 | 79 |
|
76 | 80 | # first, remove blinks and heartbeat to compare |
77 | 81 | blink_idx = [0] |
78 | 82 | heartbeat_idx = [5] |
79 | 83 | ica.apply(raw, exclude=blink_idx + heartbeat_idx) |
80 | | -ica.plot_overlay(raw, exclude=muscle_idx) |
| 84 | +if sys.platform != "emscripten": |
| 85 | + ica.plot_overlay(raw, exclude=muscle_idx) |
81 | 86 |
|
82 | 87 | # %% |
83 | 88 | # Finally, let's try an automated algorithm to find muscle components |
84 | 89 | # and ensure that it gets the same components we did manually. |
85 | 90 | muscle_idx_auto, scores = ica.find_bads_muscle(raw) |
86 | | -ica.plot_scores(scores, exclude=muscle_idx_auto) |
| 91 | +if sys.platform != "emscripten": |
| 92 | + ica.plot_scores(scores, exclude=muscle_idx_auto) |
87 | 93 | print( |
88 | 94 | f"Manually found muscle artifact ICA components: {muscle_idx}\n" |
89 | 95 | f"Automatically found muscle artifact ICA components: {muscle_idx_auto}" |
|
107 | 113 | n_components=15, method="picard", max_iter="auto", random_state=97 |
108 | 114 | ) |
109 | 115 | ica.fit(raw) |
110 | | - ica.plot_sources(raw) |
| 116 | + if sys.platform != "emscripten": |
| 117 | + ica.plot_sources(raw) |
111 | 118 | muscle_idx_auto, scores = ica.find_bads_muscle(raw) |
112 | | - ica.plot_properties(raw, picks=muscle_idx_auto, log_scale=True) |
113 | | - ica.plot_scores(scores, exclude=muscle_idx_auto) |
| 119 | + if sys.platform != "emscripten": |
| 120 | + ica.plot_properties(raw, picks=muscle_idx_auto, log_scale=True) |
| 121 | + ica.plot_scores(scores, exclude=muscle_idx_auto) |
114 | 122 |
|
115 | 123 | print( |
116 | 124 | f"Manually found muscle artifact ICA components: {muscle_idx}\n" |
|
0 commit comments