MCPcopy Index your code
hub / github.com/mne-tools/mne-python / simulate_data

Function simulate_data

mne/decoding/tests/test_csp.py:38–56  ·  view source on GitHub ↗

Simulate data according to an instantaneous mixin model. Data are simulated in the statistical source space, where one source is modulated according to a target variable, before being mixed with a random mixing matrix.

(target, n_trials=100, n_channels=10, random_state=42)

Source from the content-addressed store, hash-verified

36
37
38def simulate_data(target, n_trials=100, n_channels=10, random_state=42):
39 """Simulate data according to an instantaneous mixin model.
40
41 Data are simulated in the statistical source space, where one source is
42 modulated according to a target variable, before being mixed with a
43 random mixing matrix.
44 """
45 rs = np.random.RandomState(random_state)
46
47 # generate a orthogonal mixin matrix
48 mixing_mat = np.linalg.svd(rs.randn(n_channels, n_channels))[0]
49
50 S = rs.randn(n_trials, n_channels, 50)
51 S[:, 0] *= np.atleast_2d(np.sqrt(target)).T
52 S[:, 1:] *= 0.01 # less noise
53
54 X = np.dot(mixing_mat, S).transpose((1, 0, 2))
55
56 return X, mixing_mat
57
58
59def deterministic_toy_data(classes=("class_a", "class_b")):

Callers 2

test_cspFunction · 0.70
test_spocFunction · 0.70

Calls 1

sqrtMethod · 0.80

Tested by

no test coverage detected