def read_fiducials(fname):
 (fid, tree, _) = fiff_open(fname)
 with fid:
  isotrak = dir_tree_find(tree, FIFF.FIFFB_ISOTRAK)
  isotrak = isotrak[0]
  pts = []
  coord_frame = FIFF.FIFFV_COORD_UNKNOWN
  for k in range(isotrak['nent']):
   kind = isotrak['directory'][k].kind
   pos = isotrak['directory'][k].pos
   if (kind == FIFF.FIFF_DIG_POINT):
    tag = read_tag(fid, pos)
    pts.append(tag.data)
   elif (kind == FIFF.FIFF_MNE_COORD_FRAME):
    tag = read_tag(fid, pos)
    coord_frame = tag.data[0]
 if (coord_frame == FIFF.FIFFV_COORD_UNKNOWN):
  err = ('No coordinate frame was found in the file %r, it is probably not a valid fiducials file.' % fname)
  raise ValueError(err)
 for pt in pts:
  pt['coord_frame'] = coord_frame
 return (pts, coord_frame)

def read_fiducials ( fname ) : ( fid , tree , _ ) = fiff_open ( fname ) with fid : isotrak = dir_tree_find ( tree , FIFF . FIFFB_ISOTRAK ) isotrak = isotrak [ 0 ] pts = [ ] coord_frame = FIFF . FIFFV_COORD_UNKNOWN for k in range ( isotrak [ 'nent' ] ) : kind = isotrak [ 'directory' ] [ k ] . kind pos = isotrak [ 'directory' ] [ k ] . pos if ( kind == FIFF . FIFF_DIG_POINT ) : tag = read_tag ( fid , pos ) pts . append ( tag . data ) elif ( kind == FIFF . FIFF_MNE_COORD_FRAME ) : tag = read_tag ( fid , pos ) coord_frame = tag . data [ 0 ] if ( coord_frame == FIFF . FIFFV_COORD_UNKNOWN ) : err = ( 'No coordinate frame was found in the file %r, it is probably not a valid fiducials file.' % fname ) raise ValueError ( err ) for pt in pts : pt [ 'coord_frame' ] = coord_frame return ( pts , coord_frame )
read fiducials from a fiff file .