'Render mri+bem (only PNG).'

def _render_bem(self, subject, subjects_dir, decim, n_jobs, section='mri', caption='BEM'):

    import nibabel as nib
    subjects_dir = get_subjects_dir(subjects_dir, raise_error=True)
    mri_fname = op.join(subjects_dir, subject, 'mri', 'T1.mgz')
    if (not op.isfile(mri_fname)):
        warn(('MRI    file    "%s"    does    not    exist' % mri_fname))
    bem_path = op.join(subjects_dir, subject, 'bem')
    if (not op.isdir(bem_path)):
        warn(('Subject    bem    directory    "%s"    does    not    exist' % bem_path))
        return self._render_image_png(mri_fname, cmap='gray', n_jobs=n_jobs)
    surf_fnames = []
    for surf_name in ['*inner_skull', '*outer_skull', '*outer_skin']:
        surf_fname = glob(op.join(bem_path, (surf_name + '.surf')))
        if (len(surf_fname) > 0):
            surf_fnames.append(surf_fname[0])
        else:
            warn(('No    surface    found    for    %s.' % surf_name))
            continue
    if (len(surf_fnames) == 0):
        warn('No    surfaces    found    at    all,    rendering    empty    MRI')
        return self._render_image_png(mri_fname, cmap='gray')
    nim = nib.load(mri_fname)
    data = nim.get_data()
    shape = data.shape
    del data
    html = []
    global_id = self._get_id()
    if ((section == 'mri') and ('mri' not in self.sections)):
        self.sections.append('mri')
        self._sectionvars['mri'] = 'mri'
    name = caption
    html += (u'<li    class="mri"    id="%d">\n' % global_id)
    html += (u'<h2>%s</h2>\n' % name)
    html += u'<div    class="row">'
    html += self._render_one_bem_axis(mri_fname, surf_fnames, global_id, shape, 'axial', decim, n_jobs)
    html += self._render_one_bem_axis(mri_fname, surf_fnames, global_id, shape, 'sagittal', decim, n_jobs)
    html += u'</div><div    class="row">'
    html += self._render_one_bem_axis(mri_fname, surf_fnames, global_id, shape, 'coronal', decim, n_jobs)
    html += u'</div>'
    html += u'</li>\n'
    return ''.join(html)
