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

Function test_vec_stc_basic

mne/tests/test_source_estimate.py:1342–1437  ·  view source on GitHub ↗

Test (vol)vector source estimate.

(tmp_path, klass, kind, dtype)

Source from the content-addressed store, hash-verified

1340)
1341@pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128])
1342def test_vec_stc_basic(tmp_path, klass, kind, dtype):
1343 """Test (vol)vector source estimate."""
1344 pytest.importorskip("h5io")
1345 nn = np.array(
1346 [
1347 [1, 0, 0],
1348 [0, 1, 0],
1349 [np.sqrt(1.0 / 2.0), 0, np.sqrt(1.0 / 2.0)],
1350 [np.sqrt(1 / 3.0)] * 3,
1351 ],
1352 np.float32,
1353 )
1354
1355 data = np.array(
1356 [
1357 [1, 0, 0],
1358 [0, 2, 0],
1359 [-3, 0, 0],
1360 [1, 1, 1],
1361 ],
1362 dtype,
1363 )[:, :, np.newaxis]
1364 amplitudes = np.array([1, 2, 3, np.sqrt(3)], dtype)
1365 magnitudes = amplitudes.copy()
1366 normals = np.array([1, 2, -3.0 / np.sqrt(2), np.sqrt(3)], dtype)
1367 if dtype in (np.complex64, np.complex128):
1368 data *= 1j
1369 amplitudes *= 1j
1370 normals *= 1j
1371 directions = np.array([[1, 0, 0], [0, 1, 0], [-1, 0, 0], [1.0 / np.sqrt(3)] * 3])
1372 vol_kind = kind if kind in ("discrete", "vol") else "vol"
1373 vol_src = SourceSpaces([dict(nn=nn, type=vol_kind)])
1374 assert vol_src.kind == dict(vol="volume").get(vol_kind, vol_kind)
1375 vol_verts = [np.arange(4)]
1376 surf_src = SourceSpaces(
1377 [dict(nn=nn[:2], type="surf"), dict(nn=nn[2:], type="surf")]
1378 )
1379 assert surf_src.kind == "surface"
1380 surf_verts = [np.array([0, 1]), np.array([0, 1])]
1381 if klass is VolVectorSourceEstimate:
1382 src = vol_src
1383 verts = vol_verts
1384 elif klass is VectorSourceEstimate:
1385 src = surf_src
1386 verts = surf_verts
1387 if klass is MixedVectorSourceEstimate:
1388 src = surf_src + vol_src
1389 verts = surf_verts + vol_verts
1390 assert src.kind == "mixed"
1391 data = np.tile(data, (2, 1, 1))
1392 amplitudes = np.tile(amplitudes, 2)
1393 magnitudes = np.tile(magnitudes, 2)
1394 normals = np.tile(normals, 2)
1395 directions = np.tile(directions, (2, 1))
1396 stc = klass(data, verts, 0, 1, "foo")
1397 amplitudes = amplitudes[:, np.newaxis]
1398 magnitudes = magnitudes[:, np.newaxis]
1399

Callers

nothing calls this directly

Calls 7

SourceSpacesClass · 0.90
read_source_estimateFunction · 0.90
sqrtMethod · 0.80
magnitudeMethod · 0.80
copyMethod · 0.45
projectMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected