Skip to content

Commit 0e09163

Browse files
authored
use eegbci.standardize instead of custom code (#12997)
1 parent ed2fd8d commit 0e09163

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

tutorials/forward/35_eeg_no_mri.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
src = fs_dir / "bem" / "fsaverage-ico-5-src.fif"
4040
bem = fs_dir / "bem" / "fsaverage-5120-5120-5120-bem-sol.fif"
4141

42-
##############################################################################
42+
# %%
4343
# Load the data
4444
# ^^^^^^^^^^^^^
4545
#
@@ -52,11 +52,7 @@
5252
raw = mne.io.read_raw_edf(raw_fname, preload=True)
5353

5454
# 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)
6056

6157
# Read and set the EEG electrode locations, which are already in fsaverage's
6258
# space (MNI space) for standard_1020:
@@ -75,7 +71,7 @@
7571
dig="fiducials",
7672
)
7773

78-
##############################################################################
74+
# %%
7975
# Setup source space and compute forward
8076
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8177

@@ -84,7 +80,7 @@
8480
)
8581
fwd
8682

87-
##############################################################################
83+
# %%
8884
# From here on, standard inverse imaging methods can be used!
8985
#
9086
# Infant MRI surrogates
@@ -96,15 +92,15 @@
9692
info = mne.create_info(ch_names, 1000.0, "eeg")
9793
raw = mne.io.RawArray(data, info)
9894

99-
##############################################################################
95+
# %%
10096
# Get an infant MRI template
10197
# ^^^^^^^^^^^^^^^^^^^^^^^^^^
10298
# To use an infant head model for M/EEG data, you can use
10399
# :func:`mne.datasets.fetch_infant_template` to download an infant template:
104100

105101
subject = mne.datasets.fetch_infant_template("6mo", subjects_dir, verbose=True)
106102

107-
##############################################################################
103+
# %%
108104
# It comes with several helpful built-in files, including a 10-20 montage
109105
# in the MRI coordinate frame, which can be used to compute the
110106
# MRI<->head transform ``trans``:
@@ -115,7 +111,7 @@
115111
raw.set_montage(mon)
116112
print(trans)
117113

118-
##############################################################################
114+
# %%
119115
# There are also BEM and source spaces:
120116

121117
bem_dir = subjects_dir / subject / "bem"
@@ -125,7 +121,7 @@
125121
fname_bem = bem_dir / f"{subject}-5120-5120-5120-bem-sol.fif"
126122
bem = mne.read_bem_solution(fname_bem)
127123

128-
##############################################################################
124+
# %%
129125
# You can ensure everything is as expected by plotting the result:
130126
fig = mne.viz.plot_alignment(
131127
raw.info,
@@ -141,7 +137,7 @@
141137
)
142138
mne.viz.set_3d_view(fig, 25, 70, focalpoint=[0, -0.005, 0.01])
143139

144-
##############################################################################
140+
# %%
145141
# From here, standard forward and inverse operators can be computed
146142
#
147143
# If you have digitized head positions or MEG data, consider using

0 commit comments

Comments
 (0)