# EEG positions on the BEM head model

If you have a question or issue with MNE-Python, please include the following info:

• MNE version: e.g. 0.24.0
• operating system: e.g. macOS 12 / Windows 10 / Ubuntu 18.04

Hi, dear MNE users!

I have a specific question, and need assistance with a particular task. I aim to position specific sources (dipoles) on the BEM model with 3 layers. To accomplish this, I require the exact EEG electrode (sensor) coordinates in a 3D case. I found the “eeg-positions” module, which provides positions of standard electrodes with both 2D and 3D coordinates. However, I’m uncertain whether it accounts for the BEM outer head model when determining electrode positions.

My objective is to create specific dipoles and then find their leadfield matrix to understand their impact on sensor space through topo-maps.

Below is my code, along with the encountered error:

``````def gen_forward_solution(pos, bem, info, trans, verbose=True):
# Arbitrary amplitude and orientation (to instantiate Dipole object)
amplitude = np.array([1, 1, 1])  # Specify your desired amplitude in nAm
ori = np.array([0.5878, 0.0, 0.809])  # Orientation towards C4 electrode
ori /= np.linalg.norm(ori)  # Normalize orientation vector

# Position calculation: 4cm below C4 electrode channel
c4_position = np.array([0.5878, 0.0, 0.809])  # C4 electrode position
pos = c4_position - np.array([0, 0, 0.04])  # 4cm below C4 electrode channel

# Instantiate Dipole object
dip = mne.Dipole(times=[0], pos=pos.reshape(1, 3), ori=ori.reshape(1, 3), amplitude=amplitude, gof=100)  # Assuming gof is fixed

# Compute forward solution
forward, _ = mne.make_forward_dipole(dip, bem = bem, info = raw.info, trans = trans, verbose = verbose)

# Convert forward solution to free orientation mode
forward = mne.convert_forward_solution(fwd, force_fixed=False, verbose=verbose)

return forward

bem = bem
info = raw.info
trans = None

# Position calculation: 4cm below C4 electrode channel
c4_position = np.array([0.5878, 0.0, 0.809])  # C4 electrode position
pos = c4_position - np.array([0, 0, 0.04])  # 4cm below C4 electrode channel

#Example usage
forward = gen_forward_solution(pos, bem, info, trans = trans, verbose=True)
print(forward)

RuntimeError: No points left in source space after excluding points close to inner skull.
``````

In this code, I attempted to create a dipole located 4cm below the C4 channel. However, for consistency, I believe I need the exact positions of channels on the BEM model. Could you please help me resolve this issue? Thank you in advance!

Use `mne.viz.plot_alignment` to visualize the head and sensors and check if everything lines up.

As you have no digitized 3D positions for your EEG electrodes and need to rely an default locations, I also assume you do not have an MRI scan of the subject’s head and need to rely on a template head model as well. Completely fine and as expected if one is doing simulations of course. In that case, I assume you are using `fsaverage` as template head model. In this case, `trans` should be set to the string `"fsaverage"` for MNE-Python to use the build-in MRI->head transform.

For example:

``````import mne
mon = mne.channels.make_standard_montage('standard_1005')
info = mne.create_info(mon.ch_names, 1, ch_types='eeg')