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

Function _simulate_erplike_mixed_data

mne/preprocessing/tests/test_xdawn.py:314–349  ·  view source on GitHub ↗
(n_epochs=100, n_channels=10)

Source from the content-addressed store, hash-verified

312
313
314def _simulate_erplike_mixed_data(n_epochs=100, n_channels=10):
315 rng = np.random.RandomState(42)
316 tmin, tmax = 0.0, 1.0
317 sfreq = 100.0
318 informative_ch_idx = 0
319
320 y = rng.randint(0, 2, n_epochs)
321 n_times = int((tmax - tmin) * sfreq)
322 epoch_times = np.linspace(tmin, tmax, n_times)
323
324 target_template = 1e-6 * (epoch_times - tmax) * np.sin(2 * np.pi * epoch_times)
325 nontarget_template = (
326 0.7e-6 * (epoch_times - tmax) * np.sin(2 * np.pi * (epoch_times - 0.1))
327 )
328
329 epoch_data = rng.randn(n_epochs, n_channels, n_times) * 5e-7
330 epoch_data[y == 0, informative_ch_idx, :] += nontarget_template
331 epoch_data[y == 1, informative_ch_idx, :] += target_template
332
333 mixing_mat = _safe_svd(rng.randn(n_channels, n_channels))[0]
334 mixed_epoch_data = np.dot(mixing_mat.T, epoch_data).transpose((1, 0, 2))
335
336 events = np.zeros((n_epochs, 3), dtype=int)
337 events[:, 0] = np.arange(0, n_epochs * n_times, n_times)
338 events[:, 2] = y
339
340 info = create_info(
341 ch_names=[f"C{i:02d}" for i in range(n_channels)],
342 ch_types=["eeg"] * n_channels,
343 sfreq=sfreq,
344 )
345 epochs = EpochsArray(
346 mixed_epoch_data, info, events, tmin=tmin, event_id={"nt": 0, "t": 1}
347 )
348
349 return epochs, mixing_mat
350
351
352def test_xdawn_decoding_performance():

Callers 1

Calls 3

_safe_svdFunction · 0.90
create_infoFunction · 0.90
EpochsArrayClass · 0.90

Tested by

no test coverage detected