Test inter-subject label morphing.
()
| 919 | @pytest.mark.slowtest |
| 920 | @testing.requires_testing_data |
| 921 | def 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 |
nothing calls this directly
no test coverage detected