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

Function test_csd_degenerate

mne/preprocessing/tests/test_csd.py:84–161  ·  view source on GitHub ↗

Test degenerate conditions.

(evoked_csd_sphere)

Source from the content-addressed store, hash-verified

82
83
84def test_csd_degenerate(evoked_csd_sphere):
85 """Test degenerate conditions."""
86 evoked, csd, sphere = evoked_csd_sphere
87 warn_evoked = evoked.copy()
88 warn_evoked.info["bads"].append(warn_evoked.ch_names[3])
89 with pytest.raises(ValueError, match="Either drop.*or interpolate"):
90 compute_current_source_density(warn_evoked)
91
92 with pytest.raises(TypeError, match="must be an instance of"):
93 compute_current_source_density(None)
94
95 fail_evoked = evoked.copy()
96 with pytest.raises(ValueError, match="Zero or infinite position"):
97 for ch in fail_evoked.info["chs"]:
98 ch["loc"][:3] = np.array([0, 0, 0])
99 compute_current_source_density(fail_evoked, sphere=sphere)
100
101 with pytest.raises(ValueError, match="Zero or infinite position"):
102 fail_evoked.info["chs"][3]["loc"][:3] = np.inf
103 compute_current_source_density(fail_evoked, sphere=sphere)
104
105 with pytest.raises(ValueError, match="No EEG channels found."):
106 fail_evoked = evoked.copy()
107 fail_evoked.set_channel_types(
108 {ch_name: "ecog" for ch_name in fail_evoked.ch_names}
109 )
110 compute_current_source_density(fail_evoked, sphere=sphere)
111
112 with pytest.raises(TypeError, match="lambda2"):
113 compute_current_source_density(evoked, lambda2="0", sphere=sphere)
114
115 with pytest.raises(ValueError, match="lambda2 must be between 0 and 1"):
116 compute_current_source_density(evoked, lambda2=2, sphere=sphere)
117
118 with pytest.raises(TypeError, match="stiffness must be"):
119 compute_current_source_density(evoked, stiffness="0", sphere=sphere)
120
121 with pytest.raises(ValueError, match="stiffness must be non-negative"):
122 compute_current_source_density(evoked, stiffness=-2, sphere=sphere)
123
124 with pytest.raises(TypeError, match="n_legendre_terms must be"):
125 compute_current_source_density(evoked, n_legendre_terms=0.1, sphere=sphere)
126
127 with pytest.raises(ValueError, match=("n_legendre_terms must be greater than 0")):
128 compute_current_source_density(evoked, n_legendre_terms=0, sphere=sphere)
129
130 with pytest.raises(ValueError, match="sphere must be"):
131 compute_current_source_density(evoked, sphere=-0.1)
132
133 with pytest.raises(ValueError, match=("sphere radius must be greater than 0")):
134 compute_current_source_density(evoked, sphere=(-0.1, 0.0, 0.0, -1.0))
135
136 with pytest.raises(TypeError):
137 compute_current_source_density(evoked, copy=2, sphere=sphere)
138
139 # gh-7859
140 raw = RawArray(evoked.data, evoked.info)
141 epochs = Epochs(

Callers

nothing calls this directly

Calls 9

RawArrayClass · 0.90
EpochsClass · 0.90
set_channel_typesMethod · 0.80
drop_badMethod · 0.80
copyMethod · 0.45
appendMethod · 0.45
get_dataMethod · 0.45
load_dataMethod · 0.45

Tested by

no test coverage detected