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

Function test_io_surface

mne/tests/test_surface.py:127–155  ·  view source on GitHub ↗

Test reading and writing of Freesurfer surface mesh files.

(tmp_path)

Source from the content-addressed store, hash-verified

125
126@testing.requires_testing_data
127def test_io_surface(tmp_path):
128 """Test reading and writing of Freesurfer surface mesh files."""
129 pytest.importorskip("nibabel")
130 fname_quad = data_path / "subjects" / "bert" / "surf" / "lh.inflated.nofix"
131 fname_tri = data_path / "subjects" / "sample" / "bem" / "inner_skull.surf"
132 for fname in (fname_quad, fname_tri):
133 with _record_warnings(): # no volume info
134 pts, tri, vol_info = read_surface(fname, read_metadata=True)
135 write_surface(tmp_path / "tmp", pts, tri, volume_info=vol_info, overwrite=True)
136 with _record_warnings(): # no volume info
137 c_pts, c_tri, c_vol_info = read_surface(
138 tmp_path / "tmp", read_metadata=True
139 )
140 assert_array_equal(pts, c_pts)
141 assert_array_equal(tri, c_tri)
142 assert_equal(object_diff(vol_info, c_vol_info), "")
143 if fname != fname_tri: # don't bother testing wavefront for the bigger
144 continue
145
146 # Test writing/reading a Wavefront .obj file
147 write_surface(tmp_path / "tmp.obj", pts, tri, volume_info=None, overwrite=True)
148 c_pts, c_tri = read_surface(tmp_path / "tmp.obj", read_metadata=False)
149 assert_array_equal(pts, c_pts)
150 assert_array_equal(tri, c_tri)
151
152 # reading patches (just a smoke test, let the flatmap viz tests be more
153 # complete)
154 fname_patch = data_path / "subjects" / "fsaverage" / "surf" / "rh.cortex.patch.flat"
155 _read_patch(fname_patch)
156
157
158@testing.requires_testing_data

Callers

nothing calls this directly

Calls 5

_record_warningsFunction · 0.90
read_surfaceFunction · 0.90
write_surfaceFunction · 0.90
object_diffFunction · 0.90
_read_patchFunction · 0.90

Tested by

no test coverage detected