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

Function read_surface

mne/surface.py:953–1029  ·  view source on GitHub ↗

Load a Freesurfer surface mesh in triangular format. Parameters ---------- fname : path-like The name of the file containing the surface. read_metadata : bool Read metadata as key-value pairs. Only works when reading a FreeSurfer surface file. For .obj files

(
    fname, read_metadata=False, return_dict=False, file_format="auto", verbose=None
)

Source from the content-addressed store, hash-verified

951
952@verbose
953def read_surface(
954 fname, read_metadata=False, return_dict=False, file_format="auto", verbose=None
955):
956 """Load a Freesurfer surface mesh in triangular format.
957
958 Parameters
959 ----------
960 fname : path-like
961 The name of the file containing the surface.
962 read_metadata : bool
963 Read metadata as key-value pairs. Only works when reading a FreeSurfer
964 surface file. For .obj files this dictionary will be empty.
965
966 Valid keys:
967
968 * 'head' : array of int
969 * 'valid' : str
970 * 'filename' : str
971 * 'volume' : array of int, shape (3,)
972 * 'voxelsize' : array of float, shape (3,)
973 * 'xras' : array of float, shape (3,)
974 * 'yras' : array of float, shape (3,)
975 * 'zras' : array of float, shape (3,)
976 * 'cras' : array of float, shape (3,)
977
978 .. versionadded:: 0.13.0
979
980 return_dict : bool
981 If True, a dictionary with surface parameters is returned.
982 file_format : 'auto' | 'freesurfer' | 'obj'
983 File format to use. Can be 'freesurfer' to read a FreeSurfer surface
984 file, or 'obj' to read a Wavefront .obj file (common format for
985 importing in other software), or 'auto' to attempt to infer from the
986 file name. Defaults to 'auto'.
987
988 .. versionadded:: 0.21.0
989 %(verbose)s
990
991 Returns
992 -------
993 rr : array, shape=(n_vertices, 3)
994 Coordinate points.
995 tris : int array, shape=(n_faces, 3)
996 Triangulation (each line contains indices for three points which
997 together form a face).
998 volume_info : dict-like
999 If read_metadata is true, key-value pairs found in the geometry file.
1000 surf : dict
1001 The surface parameters. Only returned if ``return_dict`` is True.
1002
1003 See Also
1004 --------
1005 write_surface
1006 read_tri
1007 """
1008 fname = _check_fname(fname, "read", True)
1009 _check_option("file_format", file_format, ["auto", "freesurfer", "obj"])
1010

Callers 15

test_watershed_bemFunction · 0.90
test_flash_bemFunction · 0.90
test_io_surfaceFunction · 0.90
test_read_curvFunction · 0.90
_stc_to_labelFunction · 0.90
test_annot_ioFunction · 0.90
test_random_parcellationFunction · 0.90
test_label_geometryFunction · 0.90
test_bem_model_topologyFunction · 0.90
scale_mriFunction · 0.85
_read_surfaceFunction · 0.85
_load_surfaceMethod · 0.85

Calls 5

_check_fnameFunction · 0.85
_check_optionFunction · 0.85
_import_nibabelFunction · 0.85
_read_wavefront_objFunction · 0.85
_rr_tris_dictFunction · 0.85

Tested by 9

test_watershed_bemFunction · 0.72
test_flash_bemFunction · 0.72
test_io_surfaceFunction · 0.72
test_read_curvFunction · 0.72
_stc_to_labelFunction · 0.72
test_annot_ioFunction · 0.72
test_random_parcellationFunction · 0.72
test_label_geometryFunction · 0.72
test_bem_model_topologyFunction · 0.72