osl_ephys.source_recon.rhino.surfaces#
Calculation of surfaces in RHINO.
Functions#
|
Generates a dict of files generated and used by rhino.compute_surfaces. |
|
Checks if surfaces have already been computed. |
|
Compute surfaces. |
|
Display surfaces. |
|
Plot a structural MRI and extracted surfaces. |
Module Contents#
- osl_ephys.source_recon.rhino.surfaces.get_surfaces_filenames(subjects_dir, subject)[source]#
Generates a dict of files generated and used by rhino.compute_surfaces.
Files will be in subjects_dir/subject/rhino/surfaces.
- Parameters:
subjects_dir (string) – Directory containing the subject directories.
subject (string) – Subject directory name to put the surfaces in.
- Returns:
filenames – A dict of files generated and used by rhino.compute_surfaces. Note that due to the unusal naming conventions used by BET: - bet_inskull_*_file is actually the brain surface - bet_outskull_*_file is actually the inner skull surface - bet_outskin_*_file is the outer skin/scalp surface
- Return type:
dict
- osl_ephys.source_recon.rhino.surfaces.check_if_already_computed(subjects_dir, subject, include_nose)[source]#
Checks if surfaces have already been computed.
- Parameters:
subjects_dir (string) – Directory to put RHINO subject directories in. Files will be in subjects_dir/subject/surfaces.
subject (string) – Subject name directory to put RHINO files in. Files will be in subjects_dir/subject/surfaces.
include_nose (bool) – Specifies whether to add the nose to the outer skin (scalp) surface.
- Returns:
already_computed – Flag indicating if surfaces have been computed.
- Return type:
bool
- osl_ephys.source_recon.rhino.surfaces.compute_surfaces(smri_file, subjects_dir, subject, include_nose=True, cleanup_files=True, recompute_surfaces=False, do_mri2mniaxes_xform=True, use_qform=False)[source]#
Compute surfaces.
Extracts inner skull, outer skin (scalp) and brain surfaces from passed in smri_file, which is assumed to be a T1, using FSL. Assumes that the sMRI file has a valid sform.
Call get_surfaces_filenames(subjects_dir, subject) to get a file list of generated files.
In more detail: 1) Transform sMRI to be aligned with the MNI axes so that BET works well 2) Use bet to skull strip sMRI so that flirt works well 3) Use flirt to register skull stripped sMRI to MNI space 4) Use BET/BETSURF to get: a) The scalp surface (excluding nose), this gives the sMRI-derived headshape points in native sMRI space, which can be used in the headshape points registration later. b) The scalp surface (outer skin), inner skull and brain surface, these can be used for forward modelling later. Note that due to the unusal naming conventions used by BET:
bet_inskull_mesh_file is actually the brain surface
bet_outskull_mesh_file is actually the inner skull surface
bet_outskin_mesh_file is the outer skin/scalp surface
Refine scalp outline, adding nose to scalp surface (optional)
Output the transform from sMRI space to MNI
Output surfaces in sMRI space
- Parameters:
smri_file (str) – Full path to structural MRI in niftii format (with .nii.gz extension). This is assumed to have a valid sform, i.e. the sform code needs to be 4 or 1, and the sform should transform from voxel indices to voxel coords in mm. The axis sform used to do this will be the native/sMRI axis used throughout rhino. The qform will be ignored.
subjects_dir (str) – Directory to put RHINO subject directories in. Files will be in subjects_dir/subject/surfaces.
subject (str) – Subject name directory to put RHINO files in. Files will be in subjects_dir/subject/surfaces.
include_nose (bool, optional) – Specifies whether to add the nose to the outer skin (scalp) surface. This can help rhino’s coreg to work better, assuming that there are headshape points that also include the nose. Requires the smri_file to have a FOV that includes the nose!
cleanup_files (bool, optional) – Specifies whether to cleanup intermediate files in the surfaces directory.
recompute_surfaces (bool, optional) – Specifies whether or not to run compute_surfaces if the passed in options have already been run.
do_mri2mniaxes_xform (bool, optional) – Specifies whether to do step 1) above, i.e. transform sMRI to be aligned with the MNI axes. Sometimes needed when the sMRI goes out of the MNI FOV after step 1).
use_qform (bool, optional) – Should we replace the sform with the qform? Useful if the sform code is incompatible with osl-ephys, but the qform is compatible.
- Returns:
already_computed – Flag indicating if we’re using previously computed surfaces.
- Return type:
bool
- osl_ephys.source_recon.rhino.surfaces.surfaces_display(subjects_dir, subject)[source]#
Display surfaces.
Displays the surfaces extracted from the sMRI using rhino.compute_surfaces.
Display is shown in sMRI (native) space.
- Parameters:
subjects_dir (string) – Directory to put RHINO subject directories in. Files will be in subjects_dir/subject/surfaces.
subject (string) – Subject name directory to put RHINO files in. Files will be in subjects_dir/subject/surfaces.
Notes
bet_inskull_mesh_file is actually the brain surface and bet_outskull_mesh_file is the inner skull surface, due to the naming conventions used by BET.
- osl_ephys.source_recon.rhino.surfaces.plot_surfaces(subjects_dir, subject, include_nose, already_computed=False)[source]#
Plot a structural MRI and extracted surfaces.
- Parameters:
subjects_dir (str) – Directory to put RHINO subject directories in. Files will be in subjects_dir/subject/surfaces.
subject (str) – Subject name directory to put RHINO files in. Files will be in subjects_dir/subject/surfaces.
include_nose (bool) – Specifies whether to add the nose to the outer skin (scalp) surface.
already_computed (bool, optional) – Have the surfaces (and plots) already been computed?
- Returns:
output_files – Paths to image files saved by this function.
- Return type:
list of str