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

Function test_make_dics

mne/beamformer/tests/test_dics.py:167–427  ·  view source on GitHub ↗

Test making DICS beamformer filters.

(tmp_path, _load_forward, idx, whiten)

Source from the content-addressed store, hash-verified

165 ],
166)
167def test_make_dics(tmp_path, _load_forward, idx, whiten):
168 """Test making DICS beamformer filters."""
169 pytest.importorskip("h5io")
170 # We only test proper handling of parameters here. Testing the results is
171 # done in test_apply_dics_timeseries and test_apply_dics_csd.
172
173 fwd_free, fwd_surf, fwd_fixed, fwd_vol = _load_forward
174 epochs, _, csd, _, label, vertices, source_ind = _simulate_data(fwd_fixed, idx)
175 with pytest.raises(ValueError, match="several sensor types"):
176 make_dics(epochs.info, fwd_surf, csd, label=label, pick_ori=None)
177 if whiten:
178 noise_csd, rank = _make_rand_csd(epochs.info, csd)
179 assert rank == len(epochs.info["ch_names"]) == 62
180 else:
181 noise_csd = None
182 epochs.pick(picks="grad")
183
184 with pytest.raises(ValueError, match="Invalid value for the 'pick_ori'"):
185 make_dics(
186 epochs.info, fwd_fixed, csd, pick_ori="notexistent", noise_csd=noise_csd
187 )
188 with pytest.raises(ValueError, match="rank, if str"):
189 make_dics(epochs.info, fwd_fixed, csd, rank="foo", noise_csd=noise_csd)
190 with pytest.raises(TypeError, match="rank must be"):
191 make_dics(epochs.info, fwd_fixed, csd, rank=1.0, noise_csd=noise_csd)
192
193 # Test if fixed forward operator is detected when picking normal
194 # orientation
195 with pytest.raises(ValueError, match="forward operator with free ori"):
196 make_dics(epochs.info, fwd_fixed, csd, pick_ori="normal", noise_csd=noise_csd)
197
198 # Test if non-surface oriented forward operator is detected when picking
199 # normal orientation
200 with pytest.raises(ValueError, match="oriented in surface coordinates"):
201 make_dics(epochs.info, fwd_free, csd, pick_ori="normal", noise_csd=noise_csd)
202
203 # Test if volume forward operator is detected when picking normal
204 # orientation
205 with pytest.raises(ValueError, match="oriented in surface coordinates"):
206 make_dics(epochs.info, fwd_vol, csd, pick_ori="normal", noise_csd=noise_csd)
207
208 # Test invalid combinations of parameters
209 with pytest.raises(ValueError, match="reduce_rank cannot be used with"):
210 make_dics(
211 epochs.info,
212 fwd_free,
213 csd,
214 inversion="single",
215 reduce_rank=True,
216 noise_csd=noise_csd,
217 )
218 # TODO: Restore this?
219 # with pytest.raises(ValueError, match='not stable with depth'):
220 # make_dics(epochs.info, fwd_free, csd, weight_norm='unit-noise-gain',
221 # inversion='single', depth=None)
222
223 # Sanity checks on the returned filters
224 n_freq = len(csd.frequencies)

Callers

nothing calls this directly

Calls 12

make_dicsFunction · 0.90
_prepare_noise_csdFunction · 0.90
_reshape_viewFunction · 0.90
_assert_weight_normFunction · 0.90
read_beamformerFunction · 0.90
object_diffFunction · 0.90
_simulate_dataFunction · 0.85
_make_rand_csdFunction · 0.85
pickMethod · 0.45
copyMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected