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

Function test_morph_stc_sparse

mne/tests/test_morph.py:831–900  ·  view source on GitHub ↗

Test morphing stc with sparse=True.

()

Source from the content-addressed store, hash-verified

829
830@testing.requires_testing_data
831def test_morph_stc_sparse():
832 """Test morphing stc with sparse=True."""
833 subject_from = "sample"
834 subject_to = "fsaverage"
835 # Morph sparse data
836 # Make a sparse stc
837 stc_from = read_source_estimate(fname_smorph, subject="sample")
838 stc_from.vertices[0] = stc_from.vertices[0][[100, 500]]
839 stc_from.vertices[1] = stc_from.vertices[1][[200]]
840 stc_from._data = stc_from._data[:3]
841
842 stc_to_sparse = compute_source_morph(
843 stc_from,
844 subject_from=subject_from,
845 subject_to=subject_to,
846 spacing=None,
847 sparse=True,
848 subjects_dir=subjects_dir,
849 ).apply(stc_from)
850
851 assert_allclose(
852 np.sort(stc_from.data.sum(axis=1)), np.sort(stc_to_sparse.data.sum(axis=1))
853 )
854 assert len(stc_from.rh_vertno) == len(stc_to_sparse.rh_vertno)
855 assert len(stc_from.lh_vertno) == len(stc_to_sparse.lh_vertno)
856 assert stc_to_sparse.subject == subject_to
857 assert stc_from.tmin == stc_from.tmin
858 assert stc_from.tstep == stc_from.tstep
859
860 stc_from.vertices[0] = np.array([], dtype=np.int64)
861 stc_from._data = stc_from._data[:1]
862
863 stc_to_sparse = compute_source_morph(
864 stc_from,
865 subject_from,
866 subject_to,
867 spacing=None,
868 sparse=True,
869 subjects_dir=subjects_dir,
870 ).apply(stc_from)
871
872 assert_allclose(
873 np.sort(stc_from.data.sum(axis=1)), np.sort(stc_to_sparse.data.sum(axis=1))
874 )
875 assert len(stc_from.rh_vertno) == len(stc_to_sparse.rh_vertno)
876 assert len(stc_from.lh_vertno) == len(stc_to_sparse.lh_vertno)
877 assert stc_to_sparse.subject == subject_to
878 assert stc_from.tmin == stc_from.tmin
879 assert stc_from.tstep == stc_from.tstep
880
881 # Degenerate cases
882 with pytest.raises(ValueError, match="spacing must be set to None"):
883 compute_source_morph(
884 stc_from,
885 subject_from=subject_from,
886 subject_to=subject_to,
887 spacing=5,
888 sparse=True,

Callers

nothing calls this directly

Calls 4

read_source_estimateFunction · 0.90
compute_source_morphFunction · 0.90
applyMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected