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

Function test_source_simulator

mne/simulation/tests/test_source.py:347–479  ·  view source on GitHub ↗

Test Source Simulator.

(_get_fwd_labels)

Source from the content-addressed store, hash-verified

345
346
347def test_source_simulator(_get_fwd_labels):
348 """Test Source Simulator."""
349 fwd, _ = _get_fwd_labels
350
351 src = fwd["src"]
352 hemi_to_ind = {"lh": 0, "rh": 1}
353 tstep = 1.0 / 6.0
354
355 label_vertices = [[], [], []]
356 label_vertices[0] = np.arange(1000)
357 label_vertices[1] = np.arange(500, 1500)
358 label_vertices[2] = np.arange(1000)
359
360 hemis = ["lh", "lh", "rh"]
361
362 mylabels = []
363 src_vertices = []
364 for i, vert in enumerate(label_vertices):
365 new_label = Label(vertices=vert, hemi=hemis[i])
366 mylabels.append(new_label)
367 src_vertices.append(
368 np.intersect1d(src[hemi_to_ind[hemis[i]]]["vertno"], new_label.vertices)
369 )
370
371 wfs = [[], [], []]
372
373 wfs[0] = np.array([0, 1.0, 0]) # 1d array
374 wfs[1] = [np.array([0, 1.0, 0]), np.array([0, 1.5, 0])] # list
375 wfs[2] = np.array([[1, 1, 1.0]]) # 2d array
376
377 events = [[], [], []]
378 events[0] = np.array([[0, 0, 1], [3, 0, 1]])
379 events[1] = np.array([[0, 0, 1], [3, 0, 1]])
380 events[2] = np.array([[0, 0, 1], [2, 0, 1]])
381
382 verts_lh = np.intersect1d(range(1500), src[0]["vertno"])
383 verts_rh = np.intersect1d(range(1000), src[1]["vertno"])
384 diff_01 = len(np.setdiff1d(src_vertices[0], src_vertices[1]))
385 diff_10 = len(np.setdiff1d(src_vertices[1], src_vertices[0]))
386 inter_10 = len(np.intersect1d(src_vertices[1], src_vertices[0]))
387
388 output_data_lh = np.zeros([len(verts_lh), 6])
389 tmp = np.array([0, 1.0, 0, 0, 1, 0])
390 output_data_lh[:diff_01, :] = np.tile(tmp, (diff_01, 1))
391
392 tmp = np.array([0, 2, 0, 0, 2.5, 0])
393 output_data_lh[diff_01 : diff_01 + inter_10, :] = np.tile(tmp, (inter_10, 1))
394 tmp = np.array([0, 1, 0, 0, 1.5, 0])
395 output_data_lh[diff_01 + inter_10 :, :] = np.tile(tmp, (diff_10, 1))
396
397 data_rh_wf = np.array([1.0, 1, 2, 1, 1, 0])
398 output_data_rh = np.tile(data_rh_wf, (len(src_vertices[2]), 1))
399 output_data = np.vstack([output_data_lh, output_data_rh])
400
401 ss = SourceSimulator(src, tstep)
402 for i in range(3):
403 ss.add_data(mylabels[i], wfs[i], events[i])
404

Callers

nothing calls this directly

Calls 6

add_dataMethod · 0.95
get_stcMethod · 0.95
get_stim_channelMethod · 0.95
LabelClass · 0.90
SourceSimulatorClass · 0.90
appendMethod · 0.45

Tested by

no test coverage detected