MCPcopy
hub / github.com/mne-tools/mne-python / simulate_sparse_stc

Function simulate_sparse_stc

mne/simulation/source.py:95–233  ·  view source on GitHub ↗

Generate sparse (n_dipoles) sources time courses from data_fun. This function randomly selects ``n_dipoles`` vertices in the whole cortex or one single vertex (randomly in or in the center of) each label if ``labels is not None``. It uses ``data_fun`` to generate waveforms for each

(
    src,
    n_dipoles,
    times,
    data_fun=lambda t: 1e-7 * np.sin(20 * np.pi * t),
    labels=None,
    random_state=None,
    location="random",
    subject=None,
    subjects_dir=None,
    surf="sphere",
)

Source from the content-addressed store, hash-verified

93
94@fill_doc
95def simulate_sparse_stc(
96 src,
97 n_dipoles,
98 times,
99 data_fun=lambda t: 1e-7 * np.sin(20 * np.pi * t),
100 labels=None,
101 random_state=None,
102 location="random",
103 subject=None,
104 subjects_dir=None,
105 surf="sphere",
106):
107 """Generate sparse (n_dipoles) sources time courses from data_fun.
108
109 This function randomly selects ``n_dipoles`` vertices in the whole
110 cortex or one single vertex (randomly in or in the center of) each
111 label if ``labels is not None``. It uses ``data_fun`` to generate
112 waveforms for each vertex.
113
114 Parameters
115 ----------
116 src : instance of SourceSpaces
117 The source space.
118 n_dipoles : int
119 Number of dipoles to simulate.
120 times : array
121 Time array.
122 data_fun : callable
123 Function to generate the waveforms. The default is a 100 nAm, 10 Hz
124 sinusoid as ``1e-7 * np.sin(20 * pi * t)``. The function should take
125 as input the array of time samples in seconds and return an array of
126 the same length containing the time courses.
127 labels : None | list of Label
128 The labels. The default is None, otherwise its size must be n_dipoles.
129 %(random_state)s
130 location : str
131 The label location to choose. Can be ``'random'`` (default) or
132 ``'center'`` to use :func:`mne.Label.center_of_mass`. Note that for
133 ``'center'`` mode the label values are used as weights.
134
135 .. versionadded:: 0.13
136 subject : str | None
137 The subject the label is defined for.
138 Only used with ``location='center'``.
139
140 .. versionadded:: 0.13
141 %(subjects_dir)s
142
143 .. versionadded:: 0.13
144 surf : str
145 The surface to use for Euclidean distance center of mass
146 finding. The default here is "sphere", which finds the center
147 of mass on the spherical surface to help avoid potential issues
148 with cortical folding.
149
150 .. versionadded:: 0.13
151
152 Returns

Callers 10

css.pyFile · 0.90
test_metricsFunction · 0.90
_make_stcFunction · 0.90
test_simulate_evokedFunction · 0.90
test_orderFunction · 0.90
test_simulate_sparse_stcFunction · 0.90

Calls 6

check_random_stateFunction · 0.85
_ensure_srcFunction · 0.85
warnFunction · 0.85
select_source_in_labelFunction · 0.85
data_funFunction · 0.50
appendMethod · 0.45

Tested by 7

test_metricsFunction · 0.72
_make_stcFunction · 0.72
test_simulate_evokedFunction · 0.72
test_orderFunction · 0.72
test_simulate_sparse_stcFunction · 0.72