|
39 | 39 | src = fs_dir / "bem" / "fsaverage-ico-5-src.fif" |
40 | 40 | bem = fs_dir / "bem" / "fsaverage-5120-5120-5120-bem-sol.fif" |
41 | 41 |
|
42 | | -############################################################################## |
| 42 | +# %% |
43 | 43 | # Load the data |
44 | 44 | # ^^^^^^^^^^^^^ |
45 | 45 | # |
|
52 | 52 | raw = mne.io.read_raw_edf(raw_fname, preload=True) |
53 | 53 |
|
54 | 54 | # Clean channel names to be able to use a standard 1005 montage |
55 | | -new_names = dict( |
56 | | - (ch_name, ch_name.rstrip(".").upper().replace("Z", "z").replace("FP", "Fp")) |
57 | | - for ch_name in raw.ch_names |
58 | | -) |
59 | | -raw.rename_channels(new_names) |
| 55 | +eegbci.standardize(raw) |
60 | 56 |
|
61 | 57 | # Read and set the EEG electrode locations, which are already in fsaverage's |
62 | 58 | # space (MNI space) for standard_1020: |
|
75 | 71 | dig="fiducials", |
76 | 72 | ) |
77 | 73 |
|
78 | | -############################################################################## |
| 74 | +# %% |
79 | 75 | # Setup source space and compute forward |
80 | 76 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
81 | 77 |
|
|
84 | 80 | ) |
85 | 81 | fwd |
86 | 82 |
|
87 | | -############################################################################## |
| 83 | +# %% |
88 | 84 | # From here on, standard inverse imaging methods can be used! |
89 | 85 | # |
90 | 86 | # Infant MRI surrogates |
|
96 | 92 | info = mne.create_info(ch_names, 1000.0, "eeg") |
97 | 93 | raw = mne.io.RawArray(data, info) |
98 | 94 |
|
99 | | -############################################################################## |
| 95 | +# %% |
100 | 96 | # Get an infant MRI template |
101 | 97 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
102 | 98 | # To use an infant head model for M/EEG data, you can use |
103 | 99 | # :func:`mne.datasets.fetch_infant_template` to download an infant template: |
104 | 100 |
|
105 | 101 | subject = mne.datasets.fetch_infant_template("6mo", subjects_dir, verbose=True) |
106 | 102 |
|
107 | | -############################################################################## |
| 103 | +# %% |
108 | 104 | # It comes with several helpful built-in files, including a 10-20 montage |
109 | 105 | # in the MRI coordinate frame, which can be used to compute the |
110 | 106 | # MRI<->head transform ``trans``: |
|
115 | 111 | raw.set_montage(mon) |
116 | 112 | print(trans) |
117 | 113 |
|
118 | | -############################################################################## |
| 114 | +# %% |
119 | 115 | # There are also BEM and source spaces: |
120 | 116 |
|
121 | 117 | bem_dir = subjects_dir / subject / "bem" |
|
125 | 121 | fname_bem = bem_dir / f"{subject}-5120-5120-5120-bem-sol.fif" |
126 | 122 | bem = mne.read_bem_solution(fname_bem) |
127 | 123 |
|
128 | | -############################################################################## |
| 124 | +# %% |
129 | 125 | # You can ensure everything is as expected by plotting the result: |
130 | 126 | fig = mne.viz.plot_alignment( |
131 | 127 | raw.info, |
|
141 | 137 | ) |
142 | 138 | mne.viz.set_3d_view(fig, 25, 70, focalpoint=[0, -0.005, 0.01]) |
143 | 139 |
|
144 | | -############################################################################## |
| 140 | +# %% |
145 | 141 | # From here, standard forward and inverse operators can be computed |
146 | 142 | # |
147 | 143 | # If you have digitized head positions or MEG data, consider using |
|
0 commit comments