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

Function _ensure_bem_surfaces

mne/bem.py:2304–2330  ·  view source on GitHub ↗
(bem, extra_allow=(), name="bem")

Source from the content-addressed store, hash-verified

2302
2303
2304def _ensure_bem_surfaces(bem, extra_allow=(), name="bem"):
2305 # by default only allow path-like and list, but handle None and
2306 # ConductorModel properly if need be. Always return a ConductorModel
2307 # even though it's incomplete (and might have is_sphere=True).
2308 assert all(extra in (None, ConductorModel) for extra in extra_allow)
2309 allowed = ("path-like", list) + extra_allow
2310 _validate_type(bem, allowed, name)
2311 if isinstance(bem, path_like):
2312 # Load the surfaces
2313 logger.info(f"Loading BEM surfaces from {bem}...")
2314 bem = read_bem_surfaces(bem)
2315 bem = ConductorModel(is_sphere=False, surfs=bem)
2316 elif isinstance(bem, list):
2317 for ii, this_surf in enumerate(bem):
2318 _validate_type(this_surf, dict, f"{name}[{ii}]")
2319 if isinstance(bem, list):
2320 bem = ConductorModel(is_sphere=False, surfs=bem)
2321 # add surfaces in the spherical case
2322 if isinstance(bem, ConductorModel) and bem["is_sphere"]:
2323 bem = bem.copy()
2324 bem["surfs"] = []
2325 if len(bem["layers"]) == 4:
2326 for idx, id_ in enumerate(_sm_surf_dict.values()):
2327 bem["surfs"].append(_complete_sphere_surf(bem, idx, 4, complete=False))
2328 bem["surfs"][-1]["id"] = id_
2329
2330 return bem
2331
2332
2333def _check_file(fname, overwrite):

Callers 2

make_bem_solutionFunction · 0.85
plot_alignmentFunction · 0.85

Calls 7

copyMethod · 0.95
_validate_typeFunction · 0.85
read_bem_surfacesFunction · 0.85
ConductorModelClass · 0.85
_complete_sphere_surfFunction · 0.85
infoMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected