<s> import os . path as op <EOL> import numpy as np <EOL> from numpy . testing import assert_almost_equal <EOL> from nose . tools import assert_true , assert_raises <EOL> import warnings <EOL> from mne import read_source_spaces <EOL> from mne . datasets import testing <EOL> from mne . simulation import simulate_sparse_stc , source_estimate_quantification <EOL> from mne . utils import run_tests_if_main <EOL> warnings . simplefilter ( '<STR_LIT>' ) <EOL> data_path = testing . data_path ( download = False ) <EOL> src_fname = op . join ( data_path , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> @ testing . requires_testing_data <EOL> def test_metrics ( ) : <EOL> """<STR_LIT>""" <EOL> src = read_source_spaces ( src_fname ) <EOL> times = np . arange ( <NUM_LIT> ) / <NUM_LIT> <EOL> rng = np . random . RandomState ( <NUM_LIT> ) <EOL> stc1 = simulate_sparse_stc ( src , n_dipoles = <NUM_LIT:2> , times = times , random_state = rng ) <EOL> stc2 = simulate_sparse_stc ( src , n_dipoles = <NUM_LIT:2> , times = times , random_state = rng ) <EOL> E1_rms = source_estimate_quantification ( stc1 , stc1 , metric = '<STR_LIT>' ) <EOL> E2_rms = source_estimate_quantification ( stc2 , stc2 , metric = '<STR_LIT>' ) <EOL> E1_cos = source_estimate_quantification ( stc1 , stc1 , metric = '<STR_LIT>' ) <EOL> E2_cos = source_estimate_quantification ( stc2 , stc2 , metric = '<STR_LIT>' ) <EOL> assert_true ( E1_rms == <NUM_LIT:0.> ) <EOL> assert_true ( E2_rms == <NUM_LIT:0.> ) <EOL> assert_almost_equal ( E1_cos , <NUM_LIT:0.> ) <EOL> assert_almost_equal ( E2_cos , <NUM_LIT:0.> ) <EOL> stc_bad = stc2 . copy ( ) . crop ( <NUM_LIT:0> , <NUM_LIT:0.5> ) <EOL> assert_raises ( ValueError , source_estimate_quantification , stc1 , stc_bad ) <EOL> stc_bad = stc2 . copy ( ) <EOL> stc_bad . times -= <NUM_LIT:0.1> <EOL> assert_raises ( ValueError , source_estimate_quantification , stc1 , stc_bad ) <EOL> assert_raises ( ValueError , source_estimate_quantification , stc1 , stc2 , <EOL> metric = '<STR_LIT:foo>' ) <EOL> run_tests_if_main ( ) </s>
