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

Function test_make_forward_iterative

mne/forward/tests/test_make_forward.py:921–949  ·  view source on GitHub ↗

Test that points are excluded that are outside BEM sphere inner layer.

()

Source from the content-addressed store, hash-verified

919
920
921def test_make_forward_iterative():
922 """Test that points are excluded that are outside BEM sphere inner layer."""
923 r0 = (0.0, 0.0, 0.04)
924 head_radius = 0.08
925 bem = make_sphere_model(r0=r0, head_radius=head_radius)
926 src = setup_volume_source_space(
927 pos=10.0,
928 sphere=r0 + (head_radius,),
929 exclude=10,
930 )
931 assert 500 < src[0]["nuse"] < 4000
932 trans = Transform("mri", "head")
933 raw = read_raw_fif(fname_raw)
934 raw.pick(raw.ch_names[:2])
935 fwd = make_forward_solution(raw.info, trans, src, bem, mindist=0, verbose=True)
936 # check against iterative version
937 fm = _ForwardModeler(raw.info, trans, bem)
938 fwd_iterative = fm.compute(src)
939 _compare_forwards(fwd, fwd_iterative, fwd["nchan"], 3 * fwd["nsource"])
940 midpt = fwd["nsource"] // 2
941 assert fwd["coord_frame"] == FIFF.FIFFV_COORD_HEAD
942 fwd_data = list()
943 rr = apply_trans(invert_transform(fwd["mri_head_t"]), fwd["source_rr"])
944 nn = apply_trans(invert_transform(fwd["mri_head_t"]), fwd["source_nn"], move=False)
945 for sl in (slice(None, midpt), slice(midpt, None)):
946 ss = setup_volume_source_space(pos=dict(rr=rr[sl], nn=nn[sl]))
947 fwd_data.append(fm.compute(ss)["sol"]["data"])
948 fwd_data = np.concatenate(fwd_data, axis=1)
949 assert_allclose(fwd_data, fwd["sol"]["data"])

Callers

nothing calls this directly

Calls 12

make_sphere_modelFunction · 0.90
TransformClass · 0.90
read_raw_fifFunction · 0.90
make_forward_solutionFunction · 0.90
_ForwardModelerClass · 0.90
apply_transFunction · 0.90
invert_transformFunction · 0.90
_compare_forwardsFunction · 0.85
computeMethod · 0.80
pickMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected