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

Function test_transform_data

mne/tests/test_source_estimate.py:1072–1101  ·  view source on GitHub ↗

Test applying linear (time) transform to data.

()

Source from the content-addressed store, hash-verified

1070
1071
1072def test_transform_data():
1073 """Test applying linear (time) transform to data."""
1074 # make up some data
1075 n_sensors, n_vertices, n_times = 10, 20, 4
1076 kernel = rng.randn(n_vertices, n_sensors)
1077 sens_data = rng.randn(n_sensors, n_times)
1078
1079 vertices = [np.arange(n_vertices)]
1080 data = np.dot(kernel, sens_data)
1081
1082 for idx, tmin_idx, tmax_idx in zip(
1083 [None, np.arange(n_vertices // 2, n_vertices)], [None, 1], [None, 3]
1084 ):
1085 if idx is None:
1086 idx_use = slice(None, None)
1087 else:
1088 idx_use = idx
1089
1090 data_f, _ = _my_trans(data[idx_use, tmin_idx:tmax_idx])
1091
1092 for stc_data in (data, (kernel, sens_data)):
1093 stc = VolSourceEstimate(stc_data, vertices=vertices, tmin=0.0, tstep=1.0)
1094 stc_data_t = stc.transform_data(
1095 _my_trans, idx=idx, tmin_idx=tmin_idx, tmax_idx=tmax_idx
1096 )
1097 assert_allclose(data_f, stc_data_t)
1098 # bad sens_data
1099 sens_data = sens_data[..., np.newaxis]
1100 with pytest.raises(ValueError, match="sensor data must have 2"):
1101 VolSourceEstimate((kernel, sens_data), vertices, 0, 1)
1102
1103
1104def test_transform():

Callers

nothing calls this directly

Calls 3

VolSourceEstimateClass · 0.90
_my_transFunction · 0.85
transform_dataMethod · 0.80

Tested by

no test coverage detected