#NEWLINE# def _write_cov( fid , cov ) : #NEWLINE# #INDENT# 'Write a noise covariance matrix.' #NEWLINE# start_block ( fid , FIFF . FIFFB_MNE_COV ) #NEWLINE# write_int ( fid , FIFF . FIFF_MNE_COV_KIND , cov [ 'kind' ] ) #NEWLINE# write_int ( fid , FIFF . FIFF_MNE_COV_DIM , cov [ 'dim' ] ) #NEWLINE# if ( cov [ 'nfree' ] > 0 ) : #NEWLINE# #INDENT# write_int ( fid , FIFF . FIFF_MNE_COV_NFREE , mask [ 'nfree' ] ) #NEWLINE# #UNINDENT# if ( ( cov [ 'names' ] is not None ) and ( len ( cov [ 'names' ] ) > 0 ) ) : #NEWLINE# #INDENT# write_name_list ( fid , FIFF . FIFF_MNE_ROW_NAMES , cov [ 'names' ] ) #NEWLINE# #UNINDENT# if cov [ 'diag' ] : #NEWLINE# #INDENT# write_double ( fid , FIFF . FIFF_MNE_COV_DIAG , cov [ 'data' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dim = cov [ 'dim' ] #NEWLINE# mask = ( np . tril ( np . ones ( ( dim , dim ) , dtype = np . bool ) ) > 0 ) #NEWLINE# vals = cov [ 'data' ] [ mask ] . ravel ( ) #NEWLINE# write_double ( fid , FIFF . FIFF_MNE_COV , vals ) #NEWLINE# #UNINDENT# if ( ( cov [ 'eig' ] is not None ) and ( cov [ 'eigvec' ] is not None ) ) : #NEWLINE# #INDENT# write_float_matrix ( fid , FIFF . FIFF_MNE_COV_EIGENVECTORS , cov [ 'eigvec' ] ) #NEWLINE# write_double ( fid , FIFF . FIFF_MNE_COV_EIGENVALUES , cov [ 'eig' ] ) #NEWLINE# #UNINDENT# if ( ( cov [ 'projs' ] is not None ) and ( len ( cov [ 'projs' ] ) > 0 ) ) : #NEWLINE# #INDENT# _write_proj ( fid , cov [ 'projs' ] ) #NEWLINE# #UNINDENT# if ( ( cov [ 'bads' ] is not None ) and ( len ( cov [ 'bads' ] ) > 0 ) ) : #NEWLINE# #INDENT# start_block ( fid , FIFF . FIFFB_MNE_BAD_CHANNELS ) #NEWLINE# write_name_list ( fid , FIFF . FIFF_MNE_CH_NAME_LIST , cov [ 'bads' ] ) #NEWLINE# end_block ( fid , FIFF . FIFFB_MNE_BAD_CHANNELS ) #NEWLINE# #UNINDENT# if ( 'method' in cov ) : #NEWLINE# #INDENT# write_string ( fid , FIFF . FIFF_MNE_COV_METHOD , cov [ 'method' ] ) #NEWLINE# #UNINDENT# if ( 'loglik' in cov ) : #NEWLINE# #INDENT# write_double ( fid , FIFF . FIFF_MNE_COV_SCORE , np . array ( cov [ 'loglik' ] ) ) #NEWLINE# #UNINDENT# end_block ( fid , FIFF . FIFFB_MNE_COV )