Test that feed_avg gives the correct data for tSSS.
(st_fixed, st_only, mc_interp)
| 2051 | @pytest.mark.parametrize("st_only", (True, False)) |
| 2052 | @pytest.mark.filterwarnings("ignore:st_fixed=False is untested.*:RuntimeWarning") |
| 2053 | def test_feed_avg(st_fixed, st_only, mc_interp): |
| 2054 | """Test that feed_avg gives the correct data for tSSS.""" |
| 2055 | if mc_interp is False: |
| 2056 | movecomp = False |
| 2057 | mc_interp = "zero" |
| 2058 | else: |
| 2059 | movecomp = True |
| 2060 | raw = read_crop(raw_fname, (0, 3.0)).load_data() # 0-1, 0.5-1.5, ... |
| 2061 | # Use every third mag just for speed |
| 2062 | raw.pick("mag") |
| 2063 | raw.pick(raw.ch_names[::3]) |
| 2064 | if movecomp: |
| 2065 | head_pos = read_head_pos(pos_fname) |
| 2066 | # Trim just to make debugging easier |
| 2067 | head_pos = head_pos[head_pos[:, 0] < head_pos[0, 0] + 5] |
| 2068 | else: |
| 2069 | head_pos = None |
| 2070 | kwargs = dict( |
| 2071 | int_order=3, st_duration=1, st_fixed=st_fixed, st_only=st_only, verbose="debug" |
| 2072 | ) |
| 2073 | # These were empirically determined -- the importart thing is that they |
| 2074 | # only change under specific (expected) circumstances, e.g., not dependent |
| 2075 | # on st_only at all |
| 2076 | n = 8 if (movecomp and mc_interp == "hann" and not st_fixed) else 4 |
| 2077 | st_0_1 = f"Projecting {n} intersecting tSSS components for 0.000 - 0.999 s" |
| 2078 | if st_fixed: |
| 2079 | n = 4 |
| 2080 | else: |
| 2081 | if movecomp: |
| 2082 | n = 12 if mc_interp == "hann" else 8 |
| 2083 | else: |
| 2084 | n = 4 |
| 2085 | st_0p5_1p5 = ( |
| 2086 | f"Projecting {n:2d} intersecting tSSS components for 0.000 - 0.999 s" |
| 2087 | ) |
| 2088 | if movecomp and st_fixed: |
| 2089 | st_0p5_1p5 += " (across 2 positions)\n" |
| 2090 | n = 8 if (movecomp and mc_interp == "hann" and not st_fixed) else 4 |
| 2091 | log_1_2 = ( |
| 2092 | f"Projecting {n} intersecting tSSS components for 1.000 - 1.999 s\n" |
| 2093 | ) |
| 2094 | with catch_logging() as log: |
| 2095 | _maxwell_filter_ola( |
| 2096 | raw, head_pos=head_pos, st_overlap=False, mc_interp=mc_interp, **kwargs |
| 2097 | ) |
| 2098 | log = log.getvalue() |
| 2099 | # Leave these print statements in because they'll be captured by pytest but |
| 2100 | # are valuable during failures |
| 2101 | print(log) |
| 2102 | assert st_0_1 in log |
| 2103 | assert log_1_2 in log |
| 2104 | assert "Eval @ 0 (0)" in log |
| 2105 | if movecomp: |
| 2106 | assert raw.first_time == 9.0 |
| 2107 | this_head_pos = head_pos[np.where(head_pos[:, 0] >= 9.5)[0][0] - 1 :].copy() |
| 2108 | this_head_pos[0, 0] = 9.5 |
| 2109 | assert this_head_pos[1, 0] > this_head_pos[0, 0] |
| 2110 | else: |
nothing calls this directly
no test coverage detected