Test morphing stc.
()
| 727 | @pytest.mark.slowtest |
| 728 | @testing.requires_testing_data |
| 729 | def test_morph_stc_dense(): |
| 730 | """Test morphing stc.""" |
| 731 | subject_from = "sample" |
| 732 | subject_to = "fsaverage" |
| 733 | stc_from = read_source_estimate(fname_smorph, subject="sample") |
| 734 | stc_to = read_source_estimate(fname_fmorph) |
| 735 | # make sure we can specify grade |
| 736 | stc_from.crop(0.09, 0.1) # for faster computation |
| 737 | stc_to.crop(0.09, 0.1) # for faster computation |
| 738 | assert_array_equal( |
| 739 | stc_to.time_as_index([0.09, 0.1], use_rounding=True), [0, len(stc_to.times) - 1] |
| 740 | ) |
| 741 | |
| 742 | # After dep change this to: |
| 743 | morph = compute_source_morph( |
| 744 | subject_to=subject_to, |
| 745 | spacing=3, |
| 746 | smooth=12, |
| 747 | src=stc_from, |
| 748 | subjects_dir=subjects_dir, |
| 749 | precompute=True, |
| 750 | ) |
| 751 | assert morph.vol_morph_mat is None # a no-op for surface |
| 752 | stc_to1 = morph.apply(stc_from) |
| 753 | assert_allclose(stc_to.data, stc_to1.data, atol=1e-5) |
| 754 | |
| 755 | mean_from = stc_from.data.mean(axis=0) |
| 756 | mean_to = stc_to1.data.mean(axis=0) |
| 757 | assert np.corrcoef(mean_to, mean_from).min() > 0.999 |
| 758 | |
| 759 | vertices_to = grade_to_vertices(subject_to, grade=3, subjects_dir=subjects_dir) |
| 760 | |
| 761 | # make sure we can fill by morphing |
| 762 | with pytest.warns(RuntimeWarning, match="consider increasing"): |
| 763 | morph = compute_source_morph( |
| 764 | stc_from, |
| 765 | subject_from, |
| 766 | subject_to, |
| 767 | spacing=None, |
| 768 | smooth=1, |
| 769 | subjects_dir=subjects_dir, |
| 770 | ) |
| 771 | stc_to5 = morph.apply(stc_from) |
| 772 | assert stc_to5.data.shape[0] == 163842 + 163842 |
| 773 | |
| 774 | # Morph vector data |
| 775 | stc_vec = _real_vec_stc() |
| 776 | stc_vec_to1 = compute_source_morph( |
| 777 | stc_vec, |
| 778 | subject_from, |
| 779 | subject_to, |
| 780 | subjects_dir=subjects_dir, |
| 781 | spacing=vertices_to, |
| 782 | smooth=1, |
| 783 | warn=False, |
| 784 | ).apply(stc_vec) |
| 785 | assert stc_vec_to1.subject == subject_to |
| 786 | assert stc_vec_to1.tmin == stc_vec.tmin |
nothing calls this directly
no test coverage detected