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

Function test_other_systems

mne/preprocessing/tests/test_maxwell.py:361–485  ·  view source on GitHub ↗

Test Maxwell filtering on KIT, BTI, and CTF files.

()

Source from the content-addressed store, hash-verified

359
360@pytest.mark.slowtest
361def test_other_systems():
362 """Test Maxwell filtering on KIT, BTI, and CTF files."""
363 # KIT
364 kit_dir = io_dir / "kit" / "tests" / "data"
365 sqd_path = kit_dir / "test.sqd"
366 mrk_path = kit_dir / "test_mrk.sqd"
367 elp_path = kit_dir / "test_elp.txt"
368 hsp_path = kit_dir / "test_hsp.txt"
369 raw_kit = read_raw_kit(sqd_path, str(mrk_path), str(elp_path), str(hsp_path))
370 with (
371 pytest.raises(NotImplementedError, match="Cannot create forward solution with"),
372 ):
373 maxwell_filter(raw_kit, verbose=True)
374 with catch_logging() as log:
375 raw_sss = maxwell_filter(
376 raw_kit, origin=(0.0, 0.0, 0.04), ignore_ref=True, verbose=True
377 )
378 assert "12/15 out" in log.getvalue() # homogeneous fields removed
379 _assert_n_free(raw_sss, 65, 65)
380 raw_sss_auto = maxwell_filter(
381 raw_kit, origin=(0.0, 0.0, 0.04), ignore_ref=True, mag_scale="auto"
382 )
383 assert_allclose(raw_sss._data, raw_sss_auto._data)
384 with catch_logging() as log:
385 pytest.raises(
386 RuntimeError, maxwell_filter, raw_kit, ignore_ref=True, regularize=None
387 ) # bad condition
388 raw_sss = maxwell_filter(
389 raw_kit,
390 origin="auto",
391 ignore_ref=True,
392 bad_condition="info",
393 verbose=True,
394 )
395 log = log.getvalue()
396 assert "badly conditioned" not in log
397 assert "more than 20 mm from" not in log
398 _assert_n_free(raw_sss, 67, 67)
399 # Let's set the origin
400 with catch_logging() as log:
401 raw_sss = maxwell_filter(
402 raw_kit,
403 origin=(0.0, 0.0, 0.04),
404 ignore_ref=True,
405 bad_condition="info",
406 regularize=None,
407 verbose=True,
408 )
409 log = log.getvalue()
410 assert "badly conditioned" in log
411 assert "80/80 in, 12/15 out" in log
412 _assert_n_free(raw_sss, 80)
413 # Now with reg
414 with catch_logging() as log:
415 raw_sss = maxwell_filter(
416 raw_kit, origin=(0.0, 0.0, 0.04), ignore_ref=True, verbose=True
417 )
418 log = log.getvalue()

Callers

nothing calls this directly

Calls 13

read_raw_kitFunction · 0.90
catch_loggingClass · 0.90
read_raw_btiFunction · 0.90
pick_typesFunction · 0.90
maxwell_filterFunction · 0.85
_assert_n_freeFunction · 0.85
_assert_shieldingFunction · 0.85
read_cropFunction · 0.85
getvalueMethod · 0.80
sqrtMethod · 0.80
sumMethod · 0.45

Tested by

no test coverage detected