def test_ascii():
 raw = read_raw_brainvision(vhdr_path, event_id=event_id)
 tempdir = _TempDir()
 ascii_vhdr_path = op.join(tempdir, op.split(vhdr_path)[(-1)])
 shutil.copy(vhdr_path.replace('.vhdr', '.vmrk'), ascii_vhdr_path.replace('.vhdr', '.vmrk'))
 skipping = False
 with open(ascii_vhdr_path, 'wb') as fout:
  with open(vhdr_path, 'rb') as fin:
   for line in fin:
    if line.startswith('DataFormat'):
     line = 'DataFormat=ASCII\n'
    elif line.startswith('DataFile='):
     line = 'DataFile=test.dat\n'
    elif line.startswith('[Binary Infos]'):
     skipping = True
     fout.write('[ASCII Infos]\nDecimalSymbol=.\nSkipLines=1\nSkipColumns=0\n\n')
    elif (skipping and line.startswith('[')):
     skipping = False
    if (not skipping):
     fout.write(line)
 (data, times) = raw[:]
 with open(ascii_vhdr_path.replace('.vhdr', '.dat'), 'wb') as fid:
  fid.write((' '.join((ch_name.encode('ASCII') for ch_name in raw.ch_names)) + '\n'))
  fid.write('\n'.join((' '.join((('%.3f' % dd) for dd in d)) for d in (data[:(-1)].T / raw._cals[:(-1)]))))
 raw = read_raw_brainvision(ascii_vhdr_path, event_id=event_id)
 (data_new, times_new) = raw[:]
 assert_allclose(data_new, data, atol=1e-15)
 assert_allclose(times_new, times)

def test_ascii ( ) : raw = read_raw_brainvision ( vhdr_path , event_id = event_id ) tempdir = _TempDir ( ) ascii_vhdr_path = op . join ( tempdir , op . split ( vhdr_path ) [ ( - 1 ) ] ) shutil . copy ( vhdr_path . replace ( '.vhdr' , '.vmrk' ) , ascii_vhdr_path . replace ( '.vhdr' , '.vmrk' ) ) skipping = False with open ( ascii_vhdr_path , 'wb' ) as fout : with open ( vhdr_path , 'rb' ) as fin : for line in fin : if line . startswith ( 'DataFormat' ) : line = 'DataFormat=ASCII\n' elif line . startswith ( 'DataFile=' ) : line = 'DataFile=test.dat\n' elif line . startswith ( '[Binary Infos]' ) : skipping = True fout . write ( '[ASCII Infos]\nDecimalSymbol=.\nSkipLines=1\nSkipColumns=0\n\n' ) elif ( skipping and line . startswith ( '[' ) ) : skipping = False if ( not skipping ) : fout . write ( line ) ( data , times ) = raw [ : ] with open ( ascii_vhdr_path . replace ( '.vhdr' , '.dat' ) , 'wb' ) as fid : fid . write ( ( ' ' . join ( ( ch_name . encode ( 'ASCII' ) for ch_name in raw . ch_names ) ) + '\n' ) ) fid . write ( '\n' . join ( ( ' ' . join ( ( ( '%.3f' % dd ) for dd in d ) ) for d in ( data [ : ( - 1 ) ] . T / raw . _cals [ : ( - 1 ) ] ) ) ) ) raw = read_raw_brainvision ( ascii_vhdr_path , event_id = event_id ) ( data_new , times_new ) = raw [ : ] assert_allclose ( data_new , data , atol = 1e-15 ) assert_allclose ( times_new , times )
test an ascii-only string .