#NEWLINE# def read_tfrs( fname , condition = None ) : #NEWLINE# #INDENT# '\n    Read TFR datasets from hdf5 file.\n\n    Parameters\n    ----------\n    fname : string\n        The file name, which should end with -tfr.h5 .\n    condition : int or str | list of int or str | None\n        The condition to load. If None, all conditions will be returned.\n        Defaults to None.\n\n    See Also\n    --------\n    write_tfrs\n\n    Returns\n    -------\n    tfrs : list of instances of AverageTFR | instance of AverageTFR\n        Depending on `condition` either the TFR object or a list of multiple\n        TFR objects.\n\n    Notes\n    -----\n    .. versionadded:: 0.9.0\n    ' #NEWLINE# check_fname ( fname , 'tfr' , ( '-tfr.h5' , ) ) #NEWLINE# logger . info ( ( 'Reading %s ...' % fname ) ) #NEWLINE# tfr_data = read_hdf5 ( fname , title = 'mnepython' ) #NEWLINE# for ( k , tfr ) in tfr_data : #NEWLINE# #INDENT# tfr [ 'info' ] = Info ( tfr [ 'info' ] ) #NEWLINE# #UNINDENT# if ( condition is not None ) : #NEWLINE# #INDENT# tfr_dict = dict ( tfr_data ) #NEWLINE# if ( condition not in tfr_dict ) : #NEWLINE# #INDENT# keys = [ ( '%s' % k ) for k in tfr_dict ] #NEWLINE# raise ValueError ( 'Cannot find condition ("{0}") in this file. I can give you "{1}""' . format ( condition , ' or ' . join ( keys ) ) ) #NEWLINE# #UNINDENT# out = AverageTFR ( ** tfr_dict [ condition ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# out = [ AverageTFR ( ** d ) for d in list ( zip ( * tfr_data ) ) [ 1 ] ] #NEWLINE# #UNINDENT# return out