#NEWLINE# def _find_mri_paths( subject = 'fsaverage' , subjects_dir = None ) : #NEWLINE# #INDENT# "Find all files of an mri relevant for source transformation\n\n    Parameters\n    ----------\n    subject : str\n        Name of the mri subject.\n    subjects_dir : None | str\n        Override the SUBJECTS_DIR environment variable\n        (sys.environ['SUBJECTS_DIR'])\n\n    Returns\n    -------\n    paths | dict\n        Dictionary whose keys are relevant file type names (str), and whose\n        values are lists of paths.\n    " #NEWLINE# subjects_dir = get_subjects_dir ( subjects_dir , raise_error = True ) #NEWLINE# paths = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# paths [ 'dirs' ] = [ bem_dirname , surf_dirname ] #NEWLINE# paths [ 'surf' ] = surf = [ ] #NEWLINE# surf_fname = os . path . join ( surf_dirname , '{name}' ) #NEWLINE# surf_names = ( 'inflated' , 'sphere' , 'sphere.reg' , 'white' ) #NEWLINE# if ( os . getenv ( '_MNE_FEW_SURFACES' , '' ) != 'true' ) : #NEWLINE# #INDENT# surf_names = ( surf_names + ( 'orig' , 'orig_avg' , 'inflated_avg' , 'inflated_pre' , 'pial' , 'pial_avg' , 'smoothwm' , 'white_avg' , 'sphere.reg.avg' ) ) #NEWLINE# #UNINDENT# for name in surf_names : #NEWLINE# #INDENT# for hemi in ( 'lh.' , 'rh.' ) : #NEWLINE# #INDENT# fname = pformat ( surf_fname , name = ( hemi + name ) ) #NEWLINE# surf . append ( fname ) #NEWLINE# #UNINDENT# #UNINDENT# paths [ 'bem' ] = bem = [ ] #NEWLINE# path = head_bem_fname . format ( subjects_dir = subjects_dir , subject = subject ) #NEWLINE# if os . path . exists ( path ) : #NEWLINE# #INDENT# bem . append ( 'head' ) #NEWLINE# #UNINDENT# bem_pattern = pformat ( bem_fname , subjects_dir = subjects_dir , subject = subject , name = '*-bem' ) #NEWLINE# re_pattern = pformat ( bem_fname , subjects_dir = subjects_dir , subject = subject , name = '(.+)' ) #NEWLINE# for path in iglob ( bem_pattern ) : #NEWLINE# #INDENT# match = re . match ( re_pattern , path ) #NEWLINE# name = match . group ( 1 ) #NEWLINE# bem . append ( name ) #NEWLINE# #UNINDENT# paths [ 'fid' ] = [ fid_fname ] #NEWLINE# paths [ 'duplicate' ] = dup = [ ] #NEWLINE# path = os . path . join ( surf_dirname , '{name}' ) #NEWLINE# for name in [ 'lh.curv' , 'rh.curv' ] : #NEWLINE# #INDENT# fname = pformat ( path , name = name ) #NEWLINE# dup . append ( fname ) #NEWLINE# #UNINDENT# for ftype in [ 'surf' , 'fid' , 'duplicate' ] : #NEWLINE# #INDENT# for fname in paths [ ftype ] : #NEWLINE# #INDENT# path = fname . format ( subjects_dir = subjects_dir , subject = subject ) #NEWLINE# path = os . path . realpath ( path ) #NEWLINE# if ( not os . path . exists ( path ) ) : #NEWLINE# #INDENT# raise IOError ( ( 'Required file not found: %r' % path ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# paths [ 'src' ] = src = [ ] #NEWLINE# bem_dir = bem_dirname . format ( subjects_dir = subjects_dir , subject = bem ) #NEWLINE# fnames = fnmatch . filter ( os . listdir ( bem_dir ) , '*-src.fif' ) #NEWLINE# prefix = ( subject + '-' ) #NEWLINE# for fname in fnames : #NEWLINE# #INDENT# if fname . startswith ( prefix ) : #NEWLINE# #INDENT# fname = ( '{subject}-%s' % fname [ len ( prefix ) : ] ) #NEWLINE# #UNINDENT# path = os . path . join ( bem_dirname , fname ) #NEWLINE# src . append ( path ) #NEWLINE# #UNINDENT# return paths