def test_check_info_inv(): """Test checks for common channels across fwd model and cov matrices.""" epochs, data_cov, noise_cov, forward = _get_data() # make sure same channel lists exist in data to make testing life easier assert epochs.info['ch_names'] == data_cov.ch_names assert epochs.info['ch_names'] == noise_cov.ch_names # check whether bad channels get excluded from the channel selection # info info_bads = epochs.info.copy() info_bads['bads'] = info_bads['ch_names'][1:3] # include two bad channels picks = _check_info_inv(info_bads, forward, noise_cov=noise_cov) assert [1, 2] not in picks # covariance matrix data_cov_bads = data_cov.copy() data_cov_bads['bads'] = data_cov_bads.ch_names[0] picks = _check_info_inv(epochs.info, forward, data_cov=data_cov_bads) assert 0 not in picks # noise covariance matrix noise_cov_bads = noise_cov.copy() noise_cov_bads['bads'] = noise_cov_bads.ch_names[1] picks = _check_info_inv(epochs.info, forward, noise_cov=noise_cov_bads) assert 1 not in picks # test whether reference channels get deleted info_ref = epochs.info.copy() info_ref['chs'][0]['kind'] = 301 # pretend to have a ref channel picks = _check_info_inv(info_ref, forward, noise_cov=noise_cov) assert 0 not in picks # pick channels in all inputs and make sure common set is returned epochs.pick_channels([epochs.ch_names[ii] for ii in range(10)]) data_cov = pick_channels_cov( data_cov, include=[data_cov.ch_names[ii] for ii in range(5, 20)]) noise_cov = pick_channels_cov( noise_cov, include=[noise_cov.ch_names[ii] for ii in range(7, 12)]) picks = _check_info_inv(epochs.info, forward, noise_cov=noise_cov, data_cov=data_cov) assert list(range(7, 10)) == picks
def test_check_info_inv(): """Test checks for common channels across fwd model and cov matrices.""" epochs, data_cov, noise_cov, forward = _get_data() # make sure same channel lists exist in data to make testing life easier assert epochs.info['ch_names'] == data_cov.ch_names assert epochs.info['ch_names'] == noise_cov.ch_names # check whether bad channels get excluded from the channel selection # info info_bads = epochs.info.copy() info_bads['bads'] = info_bads['ch_names'][1:3] # include two bad channels picks = _check_info_inv(info_bads, forward, noise_cov=noise_cov) assert [1, 2] not in picks # covariance matrix data_cov_bads = data_cov.copy() data_cov_bads['bads'] = data_cov_bads.ch_names[0] picks = _check_info_inv(epochs.info, forward, data_cov=data_cov_bads) assert 0 not in picks # noise covariance matrix noise_cov_bads = noise_cov.copy() noise_cov_bads['bads'] = noise_cov_bads.ch_names[1] picks = _check_info_inv(epochs.info, forward, noise_cov=noise_cov_bads) assert 1 not in picks # test whether reference channels get deleted info_ref = epochs.info.copy() info_ref['chs'][0]['kind'] = 301 # pretend to have a ref channel picks = _check_info_inv(info_ref, forward, noise_cov=noise_cov) assert 0 not in picks # pick channels in all inputs and make sure common set is returned epochs.pick_channels([epochs.ch_names[ii] for ii in range(10)]) data_cov = pick_channels_cov(data_cov, include=[data_cov.ch_names[ii] for ii in range(5, 20)]) noise_cov = pick_channels_cov(noise_cov, include=[noise_cov.ch_names[ii] for ii in range(7, 12)]) picks = _check_info_inv(epochs.info, forward, noise_cov=noise_cov, data_cov=data_cov) assert list(range(7, 10)) == picks