<s> """<STR_LIT>""" <EOL> import numpy as np <EOL> from ... utils import logger <EOL> from . res4 import _make_ctf_name <EOL> from . constants import CTF <EOL> from . . constants import FIFF <EOL> _kind_dict = { '<STR_LIT>' : CTF . CTFV_COIL_NAS , '<STR_LIT>' : CTF . CTFV_COIL_LPA , <EOL> '<STR_LIT>' : CTF . CTFV_COIL_RPA , '<STR_LIT>' : CTF . CTFV_COIL_SPARE } <EOL> _coord_dict = { '<STR_LIT>' : FIFF . FIFFV_MNE_COORD_CTF_DEVICE , <EOL> '<STR_LIT>' : FIFF . FIFFV_MNE_COORD_CTF_HEAD } <EOL> def _read_one_coil_point ( fid ) : <EOL> """<STR_LIT>""" <EOL> one = '<STR_LIT:#>' <EOL> while len ( one ) > <NUM_LIT:0> and one [ <NUM_LIT:0> ] == '<STR_LIT:#>' : <EOL> one = fid . readline ( ) <EOL> if len ( one ) == <NUM_LIT:0> : <EOL> return None <EOL> one = one . strip ( ) . decode ( '<STR_LIT:utf-8>' ) <EOL> if '<STR_LIT>' in one : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> p = dict ( ) <EOL> p [ '<STR_LIT>' ] = ( '<STR_LIT>' in one ) <EOL> for key , val in _coord_dict . items ( ) : <EOL> if key in one : <EOL> p [ '<STR_LIT>' ] = val <EOL> break <EOL> else : <EOL> p [ '<STR_LIT>' ] = - <NUM_LIT:1> <EOL> for key , val in _kind_dict . items ( ) : <EOL> if key in one : <EOL> p [ '<STR_LIT>' ] = val <EOL> break <EOL> else : <EOL> p [ '<STR_LIT>' ] = - <NUM_LIT:1> <EOL> p [ '<STR_LIT:r>' ] = np . empty ( <NUM_LIT:3> ) <EOL> for ii , coord in enumerate ( '<STR_LIT>' ) : <EOL> sp = fid . readline ( ) . decode ( '<STR_LIT:utf-8>' ) . strip ( ) <EOL> if len ( sp ) == <NUM_LIT:0> : <EOL> continue <EOL> sp = sp . split ( '<STR_LIT:U+0020>' ) <EOL> if len ( sp ) != <NUM_LIT:3> or sp [ <NUM_LIT:0> ] != coord or sp [ <NUM_LIT:1> ] != '<STR_LIT:=>' : <EOL> raise RuntimeError ( '<STR_LIT>' % one ) <EOL> p [ '<STR_LIT:r>' ] [ ii ] = float ( sp [ <NUM_LIT:2> ] ) / <NUM_LIT> <EOL> return p <EOL> def _read_hc ( directory ) : <EOL> """<STR_LIT>""" <EOL> fname = _make_ctf_name ( directory , '<STR_LIT>' , raise_error = False ) <EOL> if fname is None : <EOL> logger . info ( '<STR_LIT>' ) <EOL> return None <EOL> s = list ( ) <EOL> with open ( fname , '<STR_LIT:rb>' ) as fid : <EOL> while ( True ) : <EOL> p = _read_one_coil_point ( fid ) <EOL> if p is None : <EOL> if len ( s ) == <NUM_LIT:0> : <EOL> logger . info ( '<STR_LIT>' ) <EOL> return None <EOL> logger . info ( '<STR_LIT>' ) <EOL> return s <EOL> if p [ '<STR_LIT>' ] : <EOL> s . append ( p ) </s>
