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

Function test_morph

mne/tests/test_label.py:921–952  ·  view source on GitHub ↗

Test inter-subject label morphing.

()

Source from the content-addressed store, hash-verified

919@pytest.mark.slowtest
920@testing.requires_testing_data
921def test_morph():
922 """Test inter-subject label morphing."""
923 pytest.importorskip("nibabel")
924 label_orig = read_label(real_label_fname)
925 label_orig.subject = "sample"
926 # should work for specifying vertices for both hemis, or just the
927 # hemi of the given label
928 vals = list()
929 for grade in [5, [np.arange(10242), np.arange(10242)], np.arange(10242)]:
930 label = label_orig.copy()
931 # this should throw an error because the label has all zero values
932 pytest.raises(ValueError, label.morph, "sample", "fsaverage")
933 label.values.fill(1)
934 label = label.morph(None, "fsaverage", 5, grade, subjects_dir, 1)
935 label = label.morph("fsaverage", "sample", 5, None, subjects_dir, 2)
936 assert np.isin(label_orig.vertices, label.vertices).all()
937 assert len(label.vertices) < 3 * len(label_orig.vertices)
938 vals.append(label.vertices)
939 assert_array_equal(vals[0], vals[1])
940 # make sure label smoothing can run
941 assert_equal(label.subject, "sample")
942 verts = [np.arange(10242), np.arange(10242)]
943 for hemi in ["lh", "rh"]:
944 label.hemi = hemi
945 with _record_warnings(): # morph map maybe missing
946 label.morph(None, "fsaverage", 5, verts, subjects_dir, 2)
947 pytest.raises(TypeError, label.morph, None, 1, 5, verts, subjects_dir, 2)
948 pytest.raises(
949 TypeError, label.morph, None, "fsaverage", 5.5, verts, subjects_dir, 2
950 )
951 with _record_warnings(): # morph map maybe missing
952 label.smooth(subjects_dir=subjects_dir) # make sure this runs
953
954
955@testing.requires_testing_data

Callers

nothing calls this directly

Calls 7

read_labelFunction · 0.90
_record_warningsFunction · 0.90
fillMethod · 0.80
morphMethod · 0.80
smoothMethod · 0.80
copyMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected