mne.write_surface(fname, coords, faces, create_stamp='', volume_info=None, file_format='auto', overwrite=False)[source]

Write a triangular Freesurfer surface mesh.

Accepts the same data format as is returned by read_surface().


File to write.

coordsarray, shape=(n_vertices, 3)

Coordinate points.

facesint array, shape=(n_faces, 3)

Triangulation (each line contains indices for three points which together form a face).


Comment that is written to the beginning of the file. Can not contain line breaks.

volume_infodict-like or None

Key-value pairs to encode at the end of the file. Valid keys:

  • ‘head’ : array of int

  • ‘valid’ : str

  • ‘filename’ : str

  • ‘volume’ : array of int, shape (3,)

  • ‘voxelsize’ : array of float, shape (3,)

  • ‘xras’ : array of float, shape (3,)

  • ‘yras’ : array of float, shape (3,)

  • ‘zras’ : array of float, shape (3,)

  • ‘cras’ : array of float, shape (3,)

New in version 0.13.0.

file_format‘auto’ | ‘freesurfer’ | ‘obj’

File format to use. Can be ‘freesurfer’ to write a FreeSurfer surface file, or ‘obj’ to write a Wavefront .obj file (common format for importing in other software), or ‘auto’ to attempt to infer from the file name. Defaults to ‘auto’.

New in version 0.21.0.


If True, overwrite the file if it exists.

Examples using mne.write_surface