Test tSSS-only processing.
()
| 778 | @pytest.mark.slowtest |
| 779 | @testing.requires_testing_data |
| 780 | def test_spatiotemporal_only(): |
| 781 | """Test tSSS-only processing.""" |
| 782 | # Load raw testing data |
| 783 | tmax = 0.5 |
| 784 | raw = read_crop(raw_fname, (0, tmax)).load_data() |
| 785 | picks = pick_types(raw.info, meg=True, exclude="bads")[::2] |
| 786 | raw.pick([raw.ch_names[pick] for pick in picks]) |
| 787 | mag_picks = pick_types(raw.info, meg="mag", exclude=()) |
| 788 | power = np.sqrt(np.sum(raw[mag_picks][0] ** 2)) |
| 789 | # basics |
| 790 | raw_tsss = maxwell_filter(raw, st_duration=tmax / 2.0, st_only=True) |
| 791 | assert len(raw.info["projs"]) == len(raw_tsss.info["projs"]) |
| 792 | assert _compute_rank_int(raw_tsss, proj=False) == len(picks) |
| 793 | _assert_shielding(raw_tsss, power, 9.2) |
| 794 | # with movement |
| 795 | head_pos = read_head_pos(pos_fname) |
| 796 | raw_tsss = maxwell_filter( |
| 797 | raw, st_duration=tmax / 2.0, st_only=True, head_pos=head_pos |
| 798 | ) |
| 799 | assert _compute_rank_int(raw_tsss, proj=False) == len(picks) |
| 800 | _assert_shielding(raw_tsss, power, 9.2) |
| 801 | with pytest.warns(RuntimeWarning, match="st_fixed"): |
| 802 | raw_tsss = maxwell_filter( |
| 803 | raw, st_duration=tmax / 2.0, st_only=True, head_pos=head_pos, st_fixed=False |
| 804 | ) |
| 805 | assert _compute_rank_int(raw_tsss, proj=False) == len(picks) |
| 806 | _assert_shielding(raw_tsss, power, 9.2, max_factor=9.4) |
| 807 | # COLA |
| 808 | raw_tsss = maxwell_filter( |
| 809 | raw, |
| 810 | st_duration=tmax / 2.0, |
| 811 | st_only=True, |
| 812 | head_pos=head_pos, |
| 813 | st_overlap=True, |
| 814 | mc_interp="hann", |
| 815 | ) |
| 816 | assert _compute_rank_int(raw_tsss, proj=False) == len(picks) |
| 817 | _assert_shielding(raw_tsss, power, 9.5, max_factor=9.6) |
| 818 | # should do nothing |
| 819 | raw_tsss = maxwell_filter(raw, st_duration=tmax, st_correlation=1.0, st_only=True) |
| 820 | assert_allclose(raw[:][0], raw_tsss[:][0]) |
| 821 | # degenerate |
| 822 | with pytest.raises(ValueError, match="must not be None if st_only"): |
| 823 | maxwell_filter(raw, st_only=True) |
| 824 | # two-step process equivalent to single-step process |
| 825 | raw_tsss = maxwell_filter(raw, st_duration=tmax, st_only=True) |
| 826 | raw_tsss = maxwell_filter(raw_tsss) |
| 827 | raw_tsss_2 = maxwell_filter(raw, st_duration=tmax) |
| 828 | assert_meg_snr(raw_tsss, raw_tsss_2, 1e5) |
| 829 | # now also with head movement, and a bad MEG channel |
| 830 | assert len(raw.info["bads"]) == 0 |
| 831 | bads = [raw.ch_names[0]] |
| 832 | raw.info["bads"] = list(bads) |
| 833 | raw_tsss = maxwell_filter(raw, st_duration=tmax, st_only=True, head_pos=head_pos) |
| 834 | assert raw.info["bads"] == bads |
| 835 | assert raw_tsss.info["bads"] == bads # don't reset |
| 836 | raw_tsss = maxwell_filter(raw_tsss, head_pos=head_pos) |
| 837 | assert raw_tsss.info["bads"] == [] # do reset MEG bads |
nothing calls this directly
no test coverage detected