MCPcopy
hub / github.com/mne-tools/mne-python / read_bem_surfaces

Function read_bem_surfaces

mne/bem.py:1409–1451  ·  view source on GitHub ↗

Read the BEM surfaces from a FIF file. Parameters ---------- fname : path-like The name of the file containing the surfaces. patch_stats : bool, optional (default False) Calculate and add cortical patch statistics to the surfaces. s_id : int | None If int

(
    fname, patch_stats=False, s_id=None, on_defects="raise", verbose=None
)

Source from the content-addressed store, hash-verified

1407
1408@verbose
1409def read_bem_surfaces(
1410 fname, patch_stats=False, s_id=None, on_defects="raise", verbose=None
1411):
1412 """Read the BEM surfaces from a FIF file.
1413
1414 Parameters
1415 ----------
1416 fname : path-like
1417 The name of the file containing the surfaces.
1418 patch_stats : bool, optional (default False)
1419 Calculate and add cortical patch statistics to the surfaces.
1420 s_id : int | None
1421 If int, only read and return the surface with the given ``s_id``.
1422 An error will be raised if it doesn't exist. If None, all
1423 surfaces are read and returned.
1424 %(on_defects)s
1425
1426 .. versionadded:: 0.23
1427 %(verbose)s
1428
1429 Returns
1430 -------
1431 surf: list | dict
1432 A list of dictionaries that each contain a surface. If ``s_id``
1433 is not None, only the requested surface will be returned.
1434
1435 See Also
1436 --------
1437 write_bem_surfaces, write_bem_solution, make_bem_model
1438 """
1439 # Open the file, create directory
1440 _validate_type(s_id, ("int-like", None), "s_id")
1441 fname = _check_fname(fname, "read", True, "fname")
1442 if fname.suffix == ".h5":
1443 surf = _read_bem_surfaces_h5(fname, s_id)
1444 else:
1445 surf = _read_bem_surfaces_fif(fname, s_id)
1446 if s_id is not None and len(surf) != 1:
1447 raise ValueError(f"surface with id {s_id} not found")
1448 for this in surf:
1449 if patch_stats or this["nn"] is None:
1450 _check_complete_surface(this, incomplete=on_defects)
1451 return surf[0] if s_id is not None else surf
1452
1453
1454def _read_bem_surfaces_h5(fname, s_id):

Callers 15

test_volume_source_spaceFunction · 0.90
test_make_scalp_surfacesFunction · 0.90
test_setup_forward_modelFunction · 0.90
test_io_bemFunction · 0.90
test_make_bem_modelFunction · 0.90
test_bem_solutionFunction · 0.90
test_io_head_bemFunction · 0.90
scale_bemFunction · 0.85

Calls 5

_validate_typeFunction · 0.85
_check_fnameFunction · 0.85
_read_bem_surfaces_h5Function · 0.85
_read_bem_surfaces_fifFunction · 0.85
_check_complete_surfaceFunction · 0.85

Tested by 11

test_volume_source_spaceFunction · 0.72
test_make_scalp_surfacesFunction · 0.72
test_setup_forward_modelFunction · 0.72
test_io_bemFunction · 0.72
test_make_bem_modelFunction · 0.72
test_bem_solutionFunction · 0.72
test_io_head_bemFunction · 0.72