#NEWLINE# @ verbose #NEWLINE# def read_ctf_comp( fid , node , chs , verbose = None ) : #NEWLINE# #INDENT# "Read the CTF software compensation data from the given node\n\n    Parameters\n    ----------\n    fid : file\n        The file descriptor.\n    node : dict\n        The node in the FIF tree.\n    chs : list\n        The list of channels from info['chs'] to match with\n        compensators that are read.\n    verbose : bool, str, int, or None\n        If not None, override default verbose level (see mne.verbose).\n\n    Returns\n    -------\n    compdata : list\n        The compensation data\n    " #NEWLINE# compdata = [ ] #NEWLINE# comps = dir_tree_find ( node , FIFF . FIFFB_MNE_CTF_COMP_DATA ) #NEWLINE# for node in comps : #NEWLINE# #INDENT# mat = _read_named_matrix ( fid , node , FIFF . FIFF_MNE_CTF_COMP_DATA ) #NEWLINE# for p in range ( node [ 'nent' ] ) : #NEWLINE# #INDENT# kind = node [ 'directory' ] [ p ] . kind #NEWLINE# pos = node [ 'directory' ] [ p ] . pos #NEWLINE# if ( kind == FIFF . FIFF_MNE_CTF_COMP_KIND ) : #NEWLINE# #INDENT# tag = read_tag ( fid , pos ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( 'Compensation type not found' ) #NEWLINE# #UNINDENT# one = dict ( ctfkind = tag . data ) #NEWLINE# del tag #NEWLINE# _add_kind ( one ) #NEWLINE# for p in range ( node [ 'nent' ] ) : #NEWLINE# #INDENT# kind = node [ 'directory' ] [ p ] . kind #NEWLINE# pos = node [ 'directory' ] [ p ] . pos #NEWLINE# if ( kind == FIFF . FIFF_MNE_CTF_COMP_CALIBRATED ) : #NEWLINE# #INDENT# tag = read_tag ( fid , pos ) #NEWLINE# calibrated = tag . data #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# calibrated = False #NEWLINE# #UNINDENT# one [ 'save_calibrated' ] = bool ( calibrated ) #NEWLINE# one [ 'data' ] = mat #NEWLINE# if ( not calibrated ) : #NEWLINE# #INDENT# _calibrate_comp ( one , chs , mat [ 'row_names' ] , mat [ 'col_names' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# one [ 'rowcals' ] = np . ones ( mat [ 'data' ] . shape [ 0 ] , dtype = np . float ) #NEWLINE# one [ 'colcals' ] = np . ones ( mat [ 'data' ] . shape [ 1 ] , dtype = np . float ) #NEWLINE# #UNINDENT# compdata . append ( one ) #NEWLINE# #UNINDENT# if ( len ( compdata ) > 0 ) : #NEWLINE# #INDENT# logger . info ( ( '    Read %d compensation matrices' % len ( compdata ) ) ) #NEWLINE# #UNINDENT# return compdata