meegpype.workflows.anat.bem moduleπŸ”—

BEM surface workflows.

All workflows write their surfaces to subjects_dir/subject_id/bem (brain.surf, inner_skull.surf, outer_skull.surf and outer_skin.surf), the location MNE reads them from. Since this folder is shared between methods, the surfaces of the current workflow are reinstalled on every run, even when nodes are cached: the content of the bem folder always matches the workflow that ran last.

meegpype.workflows.anat.bem.generate_basic_bem_workflow(subject_id=None, subjects_dir=None, name='basic_bem_workflow')πŸ”—

Build the basic BEM workflow, using the watershed algorithm.

All BEM surfaces (brain, inner skull, outer skull and outer skin) are computed with mne.bem.make_watershed_bem() and installed in subjects_dir/subject_id/bem.

Workflow Graph
../_images/meegpype-workflows-anat-bem-1.png

(Source code, png, svg, pdf)

Parameters:
  • subject_id (str, optional) – FreeSurfer subject ID. Can also be connected to inputnode.subject_id.

  • subjects_dir (str, optional) – FreeSurfer subjects directory. Can also be connected to inputnode.subjects_dir.

  • name (str) – Name of the workflow.

Notes

The outputnode provides subject_id, subjects_dir and the paths of the installed surfaces: brain_surf, inner_skull_surf, outer_skull_surf and outer_skin_surf.

meegpype.workflows.anat.bem.generate_bem_workflow(subject_id=None, subjects_dir=None, name='freesurfer_bem_surfaces', method='basic')πŸ”—

Build a BEM workflow.

Parameters:
  • subject_id (str, optional) – FreeSurfer subject ID. Can also be connected to inputnode.subject_id.

  • subjects_dir (str, optional) – FreeSurfer subjects directory. Can also be connected to inputnode.subjects_dir.

  • name (str) – Name of the workflow.

  • method ("basic" | "refined") – The method used to compute the BEM surfaces, see generate_basic_bem_workflow() and generate_refined_bem_workflow().

meegpype.workflows.anat.bem.generate_refined_bem_workflow(subject_id=None, subjects_dir=None, name='refined_bem_workflow')πŸ”—

Build the refined BEM workflow, using the FreeSurfer brain mask.

The brain and inner skull surfaces are computed from the FreeSurfer brainmask.mgz. In the forward pipeline, it holds the ANTs brain extraction computed by sMRIPrep (FreeSurfer’s own skull stripping is skipped), which includes the CSF surrounding the brain:

  1. the mask is binarized;

  2. a surface is extracted with marching cubes (mri_mc), smoothed and decimated to 5120 triangles;

  3. the brain surface is obtained by expanding it by 1 mm, and the inner skull surface by expanding the brain surface by a further 2 mm.

The outer skull and outer skin surfaces are computed with mne.bem.make_watershed_bem(). All surfaces are installed in subjects_dir/subject_id/bem.

Workflow Graph
../_images/meegpype-workflows-anat-bem-2.png

(Source code, png, svg, pdf)

Parameters:
  • subject_id (str, optional) – FreeSurfer subject ID. Can also be connected to inputnode.subject_id.

  • subjects_dir (str, optional) – FreeSurfer subjects directory. Can also be connected to inputnode.subjects_dir.

  • name (str) – Name of the workflow.

Notes

The outputnode provides subject_id, subjects_dir and the paths of the installed surfaces: brain_surf, inner_skull_surf, outer_skull_surf and outer_skin_surf.

meegpype.workflows.anat.bem.install_bem_surfaces(subjects_dir, subject, brain, inner_skull, outer_skull, outer_skin)πŸ”—

Install the BEM surfaces in subjects_dir/subject/bem.

Existing files are only replaced when their content differs, so that unchanged surfaces keep their timestamps (and nipype caches).