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

Function test_read_write_head_pos

mne/tests/test_chpi.py:143–159  ·  view source on GitHub ↗

Test reading and writing head position quaternion parameters.

(tmp_path)

Source from the content-addressed store, hash-verified

141
142@testing.requires_testing_data
143def test_read_write_head_pos(tmp_path):
144 """Test reading and writing head position quaternion parameters."""
145 temp_name = tmp_path / "temp.pos"
146 # This isn't a 100% valid quat matrix but it should be okay for tests
147 head_pos_rand = np.random.RandomState(0).randn(20, 10)
148 # This one is valid
149 head_pos_read = read_head_pos(pos_fname)
150 for head_pos_orig in (head_pos_rand, head_pos_read):
151 write_head_pos(temp_name, head_pos_orig)
152 head_pos = read_head_pos(temp_name)
153 assert_allclose(head_pos_orig, head_pos, atol=1e-3)
154 # Degenerate cases
155 pytest.raises(TypeError, write_head_pos, 0, head_pos_read) # not filename
156 pytest.raises(ValueError, write_head_pos, temp_name, "foo") # not array
157 pytest.raises(ValueError, write_head_pos, temp_name, head_pos_read[:, :9])
158 pytest.raises(TypeError, read_head_pos, 0)
159 pytest.raises(OSError, read_head_pos, "101")
160
161
162@testing.requires_testing_data

Callers

nothing calls this directly

Calls 2

read_head_posFunction · 0.90
write_head_posFunction · 0.90

Tested by

no test coverage detected