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",
)
| 93 | |
| 94 | @fill_doc |
| 95 | def 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 |