Test reading and writing of Freesurfer surface mesh files.
(tmp_path)
| 125 | |
| 126 | @testing.requires_testing_data |
| 127 | def 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 |
nothing calls this directly
no test coverage detected