Forward Modeling¶
The forward module provides utilities for working with forward models (leadfield matrices) and source spaces.
Overview¶
Forward modeling utilities include:
- Leadfield manipulation: Normalization, depth weighting, and subspace selection
- Source space operations: Working with MNE source spaces and vertices
- Channel selection: Matching channels between forward models and data
Quick Start¶
import mne
from invert.forward import prepare_forward
# Load a forward model
forward = mne.read_forward_solution('forward-sol.fif')
# Prepare for inverse modeling
forward_prepared = prepare_forward(forward, depth=0.8)
API Reference¶
create_forward_model ¶
create_forward_model(
sampling="ico3",
info=None,
fixed_ori=True,
conductivity=None,
n_jobs=1,
verbose=0,
)
Create a forward model using the fsaverage template form freesurfer.
Parameters:
sampling : str the downsampling of the forward model. Recommended are 'ico3' (small), 'ico4' (medium) or 'ico5' (large). info : mne.Info info instance which contains the desired electrode names and positions. This can be obtained e.g. from your processed mne.Raw.info, mne.Epochs.info or mne.Evoked.info If info is None the Info instance is created where electrodes are chosen automatically from the easycap-M10 layout. fixed_ori : bool Whether orientation of dipoles shall be fixed (set to True) or free (set to False).
Return
fwd : mne.Forward The forward model object
Source code in invert/forward/forward.py
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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
get_info ¶
Create some generic mne.Info object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
kind, for examples see: https://mne.tools/stable/generated/mne.channels.make_standard_montage.html#mne.channels.make_standard_montage |
'easycap-M10'
|
Return
info : mne.Info The mne.Info object
https://mne.tools/stable/generated/mne.create_info.html#mne.create_info https://mne.tools/stable/auto_tutorials/simulation/plot_creating_data_structures.html
Source code in invert/forward/forward.py
create_muse_montage ¶
Create a montage for the Muse headband (4 electrodes).
The Muse headband uses 4 dry EEG electrodes positioned at: - TP9 (left temporal) - AF7 (left frontal) - AF8 (right frontal) - TP10 (right temporal)
The positions are extracted from the standard_1020 montage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sfreq
|
float
|
Sampling frequency in Hz (default: 256 Hz for Muse) |
256
|
Return
info : mne.Info The mne.Info object with Muse montage montage : mne.channels.DigMontage The montage object (useful for visualization)
Example
info, montage = create_muse_montage() montage.plot() # Visualize electrode positions fwd = create_forward_model(info=info, sampling='ico3')
Source code in invert/forward/forward.py
create_8channel_montage ¶
Create an evenly spaced 8-channel EEG montage.
This montage uses 8 electrodes evenly distributed across the scalp: - Fp1, Fp2 (frontal) - C3, Cz, C4 (central) - P3, P4 (parietal) - Oz (occipital)
The positions are extracted from the standard_1020 montage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sfreq
|
float
|
Sampling frequency in Hz (default: 1000 Hz) |
1000
|
Return
info : mne.Info The mne.Info object with 8-channel montage montage : mne.channels.DigMontage The montage object (useful for visualization)
Example
info, montage = create_8channel_montage() montage.plot() # Visualize electrode positions fwd = create_forward_model(info=info, sampling='ico3')