def plot_bem(subject=None, subjects_dir=None, orientation='coronal', slices=None, brain_surfaces=None, src=None, show=True, show_indices=True, mri='T1.mgz', show_orientation=True):
    'Plot BEM contours on anatomical slices.\n\n    Parameters\n    ----------\n    subject : str\n        Subject name.\n    subjects_dir : str | None\n        Path to the SUBJECTS_DIR. If None, the path is obtained by using\n        the environment variable SUBJECTS_DIR.\n    orientation : str\n        \'coronal\' or \'axial\' or \'sagittal\'.\n    slices : list of int\n        Slice indices.\n    brain_surfaces : None | str | list of str\n        One or more brain surface to plot (optional). Entries should correspond\n        to files in the subject\'s ``surf`` directory (e.g. ``"white"``).\n    src : None | SourceSpaces | str\n        SourceSpaces instance or path to a source space to plot individual\n        sources as scatter-plot. Sources will be shown on exactly one slice\n        (whichever slice is closest to each source in the given orientation\n        plane). Path can be absolute or relative to the subject\'s ``bem``\n        folder.\n\n        .. versionchanged:: 0.20\n           All sources are shown on the nearest slice rather than some\n           being omitted.\n    show : bool\n        Show figure if True.\n    show_indices : bool\n        Show slice indices if True.\n\n        .. versionadded:: 0.20\n    mri : str\n        The name of the MRI to use. Can be a standard FreeSurfer MRI such as\n        ``\'T1.mgz\'``, or a full path to a custom MRI file.\n\n        .. versionadded:: 0.21\n    show_orientation : str\n        Show the orientation (L/R, P/A, I/S) of the data slices.\n\n        .. versionadded:: 0.21\n\n    Returns\n    -------\n    fig : instance of matplotlib.figure.Figure\n        The figure.\n\n    See Also\n    --------\n    mne.viz.plot_alignment\n\n    Notes\n    -----\n    Images are plotted in MRI voxel coordinates.\n\n    If ``src`` is not None, for a given slice index, all source points are\n    shown that are halfway between the previous slice and the given slice,\n    and halfway between the given slice and the next slice.\n    For large slice decimations, this can\n    make some source points appear outside the BEM contour, which is shown\n    for the given slice index. For example, in the case where the single\n    midpoint slice is used ``slices=[128]``, all source points will be shown\n    on top of the midpoint MRI slice with the BEM boundary drawn for that\n    slice.\n    '
    subjects_dir = get_subjects_dir(subjects_dir, raise_error=True)
    mri_fname = _check_mri(mri, subject, subjects_dir)
    bem_path = op.join(subjects_dir, subject, 'bem')
    if (not op.isdir(bem_path)):
        raise IOError(('Subject bem directory "%s" does not exist' % bem_path))
    surfaces = _get_bem_plotting_surfaces(bem_path)
    if (brain_surfaces is not None):
        if isinstance(brain_surfaces, str):
            brain_surfaces = (brain_surfaces,)
        for surf_name in brain_surfaces:
            for hemi in ('lh', 'rh'):
                surf_fname = op.join(subjects_dir, subject, 'surf', ((hemi + '.') + surf_name))
                if op.exists(surf_fname):
                    surfaces.append((surf_fname, '#00DD00'))
                else:
                    raise IOError(('Surface %s does not exist.' % surf_fname))
    if isinstance(src, str):
        if (not op.exists(src)):
            src_ = op.join(subjects_dir, subject, 'bem', src)
            if op.exists(src_):
                src = src_
            else:
                raise IOError(('%s does not exist' % src))
        src = read_source_spaces(src)
    elif ((src is not None) and (not isinstance(src, SourceSpaces))):
        raise TypeError(('src needs to be None, str or SourceSpaces instance, not %s' % repr(src)))
    if (len(surfaces) == 0):
        raise IOError('No surface files found. Surface files must end with inner_skull.surf, outer_skull.surf or outer_skin.surf')
    return _plot_mri_contours(mri_fname, surfaces, src, orientation, slices, show, show_indices, show_orientation)
Plot BEM contours on anatomical slices.

Parameters
----------
subject : str
    Subject name.
subjects_dir : str | None
    Path to the SUBJECTS_DIR. If None, the path is obtained by using
    the environment variable SUBJECTS_DIR.
orientation : str
    'coronal' or 'axial' or 'sagittal'.
slices : list of int
    Slice indices.
brain_surfaces : None | str | list of str
    One or more brain surface to plot (optional). Entries should correspond
    to files in the subject's ``surf`` directory (e.g. ``"white"``).
src : None | SourceSpaces | str
    SourceSpaces instance or path to a source space to plot individual
    sources as scatter-plot. Sources will be shown on exactly one slice
    (whichever slice is closest to each source in the given orientation
    plane). Path can be absolute or relative to the subject's ``bem``
    folder.

    .. versionchanged:: 0.20
       All sources are shown on the nearest slice rather than some
       being omitted.
show : bool
    Show figure if True.
show_indices : bool
    Show slice indices if True.

    .. versionadded:: 0.20
mri : str
    The name of the MRI to use. Can be a standard FreeSurfer MRI such as
    ``'T1.mgz'``, or a full path to a custom MRI file.

    .. versionadded:: 0.21
show_orientation : str
    Show the orientation (L/R, P/A, I/S) of the data slices.

    .. versionadded:: 0.21

Returns
-------
fig : instance of matplotlib.figure.Figure
    The figure.

See Also
--------
mne.viz.plot_alignment

Notes
-----
Images are plotted in MRI voxel coordinates.

If ``src`` is not None, for a given slice index, all source points are
shown that are halfway between the previous slice and the given slice,
and halfway between the given slice and the next slice.
For large slice decimations, this can
make some source points appear outside the BEM contour, which is shown
for the given slice index. For example, in the case where the single
midpoint slice is used ``slices=[128]``, all source points will be shown
on top of the midpoint MRI slice with the BEM boundary drawn for that
slice.
def plot_bem(subject=None, subjects_dir=None, orientation='coronal', slices=None, brain_surfaces=None, src=None, show=True, show_indices=True, mri='T1.mgz', show_orientation=True):
    'Plot BEM contours on anatomical slices.\n\n    Parameters\n    ----------\n    subject : str\n        Subject name.\n    subjects_dir : str | None\n        Path to the SUBJECTS_DIR. If None, the path is obtained by using\n        the environment variable SUBJECTS_DIR.\n    orientation : str\n        \'coronal\' or \'axial\' or \'sagittal\'.\n    slices : list of int\n        Slice indices.\n    brain_surfaces : None | str | list of str\n        One or more brain surface to plot (optional). Entries should correspond\n        to files in the subject\'s ``surf`` directory (e.g. ``"white"``).\n    src : None | SourceSpaces | str\n        SourceSpaces instance or path to a source space to plot individual\n        sources as scatter-plot. Sources will be shown on exactly one slice\n        (whichever slice is closest to each source in the given orientation\n        plane). Path can be absolute or relative to the subject\'s ``bem``\n        folder.\n\n        .. versionchanged:: 0.20\n           All sources are shown on the nearest slice rather than some\n           being omitted.\n    show : bool\n        Show figure if True.\n    show_indices : bool\n        Show slice indices if True.\n\n        .. versionadded:: 0.20\n    mri : str\n        The name of the MRI to use. Can be a standard FreeSurfer MRI such as\n        ``\'T1.mgz\'``, or a full path to a custom MRI file.\n\n        .. versionadded:: 0.21\n    show_orientation : str\n        Show the orientation (L/R, P/A, I/S) of the data slices.\n\n        .. versionadded:: 0.21\n\n    Returns\n    -------\n    fig : instance of matplotlib.figure.Figure\n        The figure.\n\n    See Also\n    --------\n    mne.viz.plot_alignment\n\n    Notes\n    -----\n    Images are plotted in MRI voxel coordinates.\n\n    If ``src`` is not None, for a given slice index, all source points are\n    shown that are halfway between the previous slice and the given slice,\n    and halfway between the given slice and the next slice.\n    For large slice decimations, this can\n    make some source points appear outside the BEM contour, which is shown\n    for the given slice index. For example, in the case where the single\n    midpoint slice is used ``slices=[128]``, all source points will be shown\n    on top of the midpoint MRI slice with the BEM boundary drawn for that\n    slice.\n    '
    subjects_dir = get_subjects_dir(subjects_dir, raise_error=True)
    mri_fname = _check_mri(mri, subject, subjects_dir)
    bem_path = op.join(subjects_dir, subject, 'bem')
    if (not op.isdir(bem_path)):
        raise IOError(('Subject bem directory "%s" does not exist' % bem_path))
    surfaces = _get_bem_plotting_surfaces(bem_path)
    if (brain_surfaces is not None):
        if isinstance(brain_surfaces, str):
            brain_surfaces = (brain_surfaces,)
        for surf_name in brain_surfaces:
            for hemi in ('lh', 'rh'):
                surf_fname = op.join(subjects_dir, subject, 'surf', ((hemi + '.') + surf_name))
                if op.exists(surf_fname):
                    surfaces.append((surf_fname, '#00DD00'))
                else:
                    raise IOError(('Surface %s does not exist.' % surf_fname))
    if isinstance(src, str):
        if (not op.exists(src)):
            src_ = op.join(subjects_dir, subject, 'bem', src)
            if op.exists(src_):
                src = src_
            else:
                raise IOError(('%s does not exist' % src))
        src = read_source_spaces(src)
    elif ((src is not None) and (not isinstance(src, SourceSpaces))):
        raise TypeError(('src needs to be None, str or SourceSpaces instance, not %s' % repr(src)))
    if (len(surfaces) == 0):
        raise IOError('No surface files found. Surface files must end with inner_skull.surf, outer_skull.surf or outer_skin.surf')
    return _plot_mri_contours(mri_fname, surfaces, src, orientation, slices, show, show_indices, show_orientation)