#NEWLINE# @ slow_test #NEWLINE# @ testing . requires_testing_data #NEWLINE# def test_setup_source_space( ) : #NEWLINE# #INDENT# 'Test setting up ico, oct, and all source spaces\n    ' #NEWLINE# tempdir = _TempDir ( ) #NEWLINE# fname_ico = op . join ( data_path , 'subjects' , 'fsaverage' , 'bem' , 'fsaverage-ico-5-src.fif' ) #NEWLINE# assert_raises ( ValueError , setup_source_space , 'sample' , spacing = 'oct' , add_dist = False ) #NEWLINE# assert_raises ( ValueError , setup_source_space , 'sample' , spacing = 'octo' , add_dist = False ) #NEWLINE# assert_raises ( ValueError , setup_source_space , 'sample' , spacing = 'oct6e' , add_dist = False ) #NEWLINE# assert_raises ( ValueError , setup_source_space , 'sample' , spacing = '7emm' , add_dist = False ) #NEWLINE# assert_raises ( ValueError , setup_source_space , 'sample' , spacing = 'alls' , add_dist = False ) #NEWLINE# assert_raises ( IOError , setup_source_space , 'sample' , spacing = 'oct6' , subjects_dir = subjects_dir , add_dist = False ) #NEWLINE# src = read_source_spaces ( fname_ico ) #NEWLINE# temp_name = op . join ( tempdir , 'temp-src.fif' ) #NEWLINE# with warnings . catch_warnings ( record = True ) : #NEWLINE# #INDENT# warnings . simplefilter ( 'always' ) #NEWLINE# src_new = setup_source_space ( 'fsaverage' , temp_name , spacing = 'ico5' , subjects_dir = subjects_dir , add_dist = False , overwrite = True ) #NEWLINE# #UNINDENT# _compare_source_spaces ( src , src_new , mode = 'approx' ) #NEWLINE# assert_array_equal ( src [ 0 ] [ 'vertno' ] , np . arange ( 10242 ) ) #NEWLINE# assert_array_equal ( src [ 1 ] [ 'vertno' ] , np . arange ( 10242 ) ) #NEWLINE# src = read_source_spaces ( fname ) #NEWLINE# temp_name = op . join ( tempdir , 'temp-src.fif' ) #NEWLINE# with warnings . catch_warnings ( record = True ) : #NEWLINE# #INDENT# warnings . simplefilter ( 'always' ) #NEWLINE# src_new = setup_source_space ( 'sample' , temp_name , spacing = 'oct6' , subjects_dir = subjects_dir , overwrite = True , add_dist = False ) #NEWLINE# #UNINDENT# _compare_source_spaces ( src , src_new , mode = 'approx' , nearest = False ) #NEWLINE# src_new = read_source_spaces ( temp_name ) #NEWLINE# _compare_source_spaces ( src , src_new , mode = 'approx' , nearest = False ) #NEWLINE# src_new = setup_source_space ( 'sample' , None , spacing = 'all' , subjects_dir = subjects_dir , add_dist = False ) #NEWLINE# assert_true ( ( src_new [ 0 ] [ 'nuse' ] == len ( src_new [ 0 ] [ 'rr' ] ) ) ) #NEWLINE# assert_true ( ( src_new [ 1 ] [ 'nuse' ] == len ( src_new [ 1 ] [ 'rr' ] ) ) ) #NEWLINE# assert_raises ( RuntimeError , setup_source_space , 'sample' , None , spacing = 'ico6' , subjects_dir = subjects_dir , add_dist = False )