#NEWLINE# @ verbose #NEWLINE# def make_forward_solution( info , trans , src , bem , fname = None , meg = True , eeg = True , mindist = 0.0 , ignore_ref = False , overwrite = False , n_jobs = 1 , verbose = None ) : #NEWLINE# #INDENT# 'Calculate a forward solution for a subject\n\n    Parameters\n    ----------\n    info : instance of mne.Info | str\n        If str, then it should be a filename to a Raw, Epochs, or Evoked\n        file with measurement information. If dict, should be an info\n        dict (such as one from Raw, Epochs, or Evoked).\n    trans : dict | str | None\n        Either a transformation filename (usually made using mne_analyze)\n        or an info dict (usually opened using read_trans()).\n        If string, an ending of `.fif` or `.fif.gz` will be assumed to\n        be in FIF format, any other ending will be assumed to be a text\n        file with a 4x4 transformation matrix (like the `--trans` MNE-C\n        option). Can be None to use the identity transform.\n    src : str | instance of SourceSpaces\n        If string, should be a source space filename. Can also be an\n        instance of loaded or generated SourceSpaces.\n    bem : dict | str\n        Filename of the BEM (e.g., "sample-5120-5120-5120-bem-sol.fif") to\n        use, or a loaded sphere model (dict).\n    fname : str | None\n        Destination forward solution filename. If None, the solution\n        will not be saved.\n    meg : bool\n        If True (Default), include MEG computations.\n    eeg : bool\n        If True (Default), include EEG computations.\n    mindist : float\n        Minimum distance of sources from inner skull surface (in mm).\n    ignore_ref : bool\n        If True, do not include reference channels in compensation. This\n        option should be True for KIT files, since forward computation\n        with reference channels is not currently supported.\n    overwrite : bool\n        If True, the destination file (if it exists) will be overwritten.\n        If False (default), an error will be raised if the file exists.\n    n_jobs : int\n        Number of jobs to run in parallel.\n    verbose : bool, str, int, or None\n        If not None, override default verbose level (see mne.verbose).\n\n    Returns\n    -------\n    fwd : instance of Forward\n        The forward solution.\n\n    Notes\n    -----\n    Some of the forward solution calculation options from the C code\n    (e.g., `--grad`, `--fixed`) are not implemented here. For those,\n    consider using the C command line tools, or request that they\n    be added to the MNE-Python.\n    ' #NEWLINE# ( mri_head_t , trans ) = _get_trans ( trans ) #NEWLINE# bem_extra = ( 'dict' if isinstance ( bem , dict ) else bem ) #NEWLINE# if ( ( fname is not None ) and op . isfile ( fname ) and ( not overwrite ) ) : #NEWLINE# #INDENT# raise IOError ( ( 'file "%s" exists, consider using overwrite=True' % fname ) ) #NEWLINE# #UNINDENT# if ( not isinstance ( info , ( Info , string_types ) ) ) : #NEWLINE# #INDENT# raise TypeError ( 'info should be an instance of Info or string' ) #NEWLINE# #UNINDENT# if isinstance ( info , string_types ) : #NEWLINE# #INDENT# info_extra = op . split ( info ) [ 1 ] #NEWLINE# info = read_info ( info , verbose = False ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# info_extra = 'instance of Info' #NEWLINE# #UNINDENT# logger . info ( ( 'Source space                 : %s' % src ) ) #NEWLINE# logger . info ( ( 'MRI -> head transform source : %s' % trans ) ) #NEWLINE# logger . info ( ( 'Measurement data             : %s' % info_extra ) ) #NEWLINE# if ( isinstance ( bem , dict ) and bem [ 'is_sphere' ] ) : #NEWLINE# #INDENT# logger . info ( ( 'Sphere model                 : origin at %s mm' % ( bem [ 'r0' ] , ) ) ) #NEWLINE# logger . info ( 'Standard field computations' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logger . info ( ( 'BEM model                    : %s' % bem_extra ) ) #NEWLINE# logger . info ( 'Accurate field computations' ) #NEWLINE# #UNINDENT# logger . info ( 'Do computations in %s coordinates' , _coord_frame_name ( FIFF . FIFFV_COORD_HEAD ) ) #NEWLINE# logger . info ( 'Free source orientations' ) #NEWLINE# logger . info ( ( 'Destination for the solution : %s' % fname ) ) #NEWLINE# ( megcoils , meg_info , compcoils , megnames , eegels , eegnames , rr , info , update_kwargs , bem ) = _prepare_for_forward ( src , mri_head_t , info , bem , mindist , n_jobs , bem_extra , trans , info_extra , meg , eeg , ignore_ref , fname , overwrite ) #NEWLINE# del ( src , mri_head_t , trans , info_extra , bem_extra , mindist , meg , eeg , ignore_ref ) #NEWLINE# coil_types = [ 'meg' , 'eeg' ] #NEWLINE# coils = [ megcoils , eegels ] #NEWLINE# ccoils = [ compcoils , None ] #NEWLINE# infos = [ meg_info , None ] #NEWLINE# ( megfwd , eegfwd ) = _compute_forwards ( rr , bem , coils , ccoils , infos , coil_types , n_jobs ) #NEWLINE# fwd = _merge_meg_eeg_fwds ( _to_forward_dict ( megfwd , megnames ) , _to_forward_dict ( eegfwd , eegnames ) , verbose = False ) #NEWLINE# logger . info ( '' ) #NEWLINE# fwd . update ( ** update_kwargs ) #NEWLINE# if ( fname is not None ) : #NEWLINE# #INDENT# logger . info ( 'writing %s...' , fname ) #NEWLINE# write_forward_solution ( fname , fwd , overwrite , verbose = False ) #NEWLINE# #UNINDENT# logger . info ( 'Finished.' ) #NEWLINE# return fwd