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
)
| 951 | |
| 952 | @verbose |
| 953 | def 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 |