@testing.requires_testing_data
@requires_mne
def test_average_forward_solution():
 temp_dir = _TempDir()
 fwd = read_forward_solution(fname_meeg)
 assert_raises(TypeError, average_forward_solutions, 1)
 assert_raises(ValueError, average_forward_solutions, [])
 assert_raises(ValueError, average_forward_solutions, [fwd, fwd], [(-1), 0])
 assert_raises(ValueError, average_forward_solutions, [fwd, fwd], [0, 0])
 assert_raises(ValueError, average_forward_solutions, [fwd, fwd], [0, 0, 0])
 assert_raises(TypeError, average_forward_solutions, [1, fwd])
 fwd_copy = average_forward_solutions([fwd])
 assert_true(isinstance(fwd_copy, Forward))
 assert_array_equal(fwd['sol']['data'], fwd_copy['sol']['data'])
 fwd_copy['sol']['data'] *= 0.5
 fname_copy = op.join(temp_dir, 'copy-fwd.fif')
 write_forward_solution(fname_copy, fwd_copy, overwrite=True)
 cmd = ('mne_average_forward_solutions', '--fwd', fname_meeg, '--fwd', fname_copy, '--out', fname_copy)
 run_subprocess(cmd)
 fwd_ave = average_forward_solutions([fwd, fwd_copy])
 assert_array_equal((0.75 * fwd['sol']['data']), fwd_ave['sol']['data'])
 fwd = read_forward_solution(fname_meeg_grad)
 fwd_ave = average_forward_solutions([fwd, fwd])
 compare_forwards(fwd, fwd_ave)

@ testing . requires_testing_data @ requires_mne def test_average_forward_solution ( ) : temp_dir = _TempDir ( ) fwd = read_forward_solution ( fname_meeg ) assert_raises ( TypeError , average_forward_solutions , 1 ) assert_raises ( ValueError , average_forward_solutions , [ ] ) assert_raises ( ValueError , average_forward_solutions , [ fwd , fwd ] , [ ( - 1 ) , 0 ] ) assert_raises ( ValueError , average_forward_solutions , [ fwd , fwd ] , [ 0 , 0 ] ) assert_raises ( ValueError , average_forward_solutions , [ fwd , fwd ] , [ 0 , 0 , 0 ] ) assert_raises ( TypeError , average_forward_solutions , [ 1 , fwd ] ) fwd_copy = average_forward_solutions ( [ fwd ] ) assert_true ( isinstance ( fwd_copy , Forward ) ) assert_array_equal ( fwd [ 'sol' ] [ 'data' ] , fwd_copy [ 'sol' ] [ 'data' ] ) fwd_copy [ 'sol' ] [ 'data' ] *= 0.5 fname_copy = op . join ( temp_dir , 'copy-fwd.fif' ) write_forward_solution ( fname_copy , fwd_copy , overwrite = True ) cmd = ( 'mne_average_forward_solutions' , '--fwd' , fname_meeg , '--fwd' , fname_copy , '--out' , fname_copy ) run_subprocess ( cmd ) fwd_ave = average_forward_solutions ( [ fwd , fwd_copy ] ) assert_array_equal ( ( 0.75 * fwd [ 'sol' ] [ 'data' ] ) , fwd_ave [ 'sol' ] [ 'data' ] ) fwd = read_forward_solution ( fname_meeg_grad ) fwd_ave = average_forward_solutions ( [ fwd , fwd ] ) compare_forwards ( fwd , fwd_ave )
test averaging forward solutions .