@@ -117,47 +117,6 @@ def test_standard_montages_in_head(kind, tol):
117117from mne .channels .montage import transform_to_head
118118from pytest import approx
119119
120- @pytest .mark .parametrize ('kind, foo' , [
121- # XXX All should be 0.085 but they are not !!
122- ['EGI_256' , 0.08500001 ],
123- ['easycap-M1' , 0.08499999999999999 ],
124- ['easycap-M10' , 0.08499999999999999 ],
125- ['GSN-HydroCel-128' , 9.763325532616348 ],
126- ['GSN-HydroCel-129' , 9.781833508100744 ],
127- ['GSN-HydroCel-256' , 10.53120179308986 ],
128- ['GSN-HydroCel-257' , 10.542564039112401 ],
129- ['GSN-HydroCel-32' , 9.334690825727204 ],
130- ['GSN-HydroCel-64_1.0' , 11.375727506868348 ],
131- ['GSN-HydroCel-65_1.0' , 11.41411195568285 ],
132- ['biosemi128' , 103.13293097944218 ],
133- ['biosemi16' , 102.54836114601703 ],
134- ['biosemi160' , 103.24734353529684 ],
135- ['biosemi256' , 102.31834042785782 ],
136- ['biosemi32' , 102.66433014370907 ],
137- ['biosemi64' , 101.87617188729301 ],
138- ['mgh60' , 0.11734227421583884 ],
139- ['mgh70' , 0.11808759279592418 ],
140- ['standard_1005' , 0.1171808880579489 ],
141- ['standard_1020' , 0.11460403303216726 ],
142- ['standard_alphabetic' , 0.12012639557866846 ],
143- ['standard_postfixed' , 0.11887390168465949 ],
144- ['standard_prefixed' , 0.11675854869450944 ],
145- ['standard_primed' , 0.11887390168465949 ],
146- ])
147- def test_foo (kind , foo ):
148- """Test standard montage properties (ie: they form a head)."""
149- montage = read_standard_montage (kind )
150- # import pdb; pdb.set_trace()
151- montage = transform_to_head (montage ) if montage ._coord_frame != 'head' else montage # noqa
152- eeg_loc = np .array ([ch ['r' ] for ch in _get_dig_eeg (montage .dig )])
153-
154- # assert_allclose(
155- # actual=np.linalg.norm(eeg_loc, axis=1),
156- # desired=np.full((eeg_loc.shape[0], ), EXPECTED_HEAD_SIZE),
157- # atol=1e-2 # Use a high tolerance for now # tol,
158- # )
159- assert np .linalg .norm (eeg_loc , axis = 1 ).mean () == approx (foo )
160-
161120
162121import matplotlib .pyplot as plt
163122from mne .channels ._dig_montage_utils import _get_fid_coords
@@ -195,9 +154,10 @@ def _plot_fid_coord(renderer, data, color):
195154 center = np .array ([0 , 0 , 0 ]),
196155 # color=(100, 100, 100), # XXX: is color (R,G,B) 0-255? doc needs rev.
197156 color = (1.0 , 1.0 , 1.0 ), # XXX: doc don't say [0-1 or 0-255] ??
198- scale = EXPECTED_HEAD_SIZE , # XXX: why I cannot put radius a value in mm?? # noqa
199- opacity = 0.5 ,
200- resolution = 8 , # XXX: why this is not callen n_poligons??
157+ # scale=EXPECTED_HEAD_SIZE, # XXX: why I cannot put radius a value in mm?? # noqa
158+ scale = 0.17 , # XXXX magic number!!
159+ opacity = 0.3 ,
160+ resolution = 20 , # XXX: why this is not callen n_poligons??
201161 backface_culling = False ,
202162 )
203163 N_RAND_PTS = 50
@@ -225,10 +185,10 @@ def _plot_fid_coord(renderer, data, color):
225185 )
226186
227187 _plot_fid_coord (ren , orig_data , (1.0 , 0 , 0 ))
228- ren .sphere (center = orig_data .eeg , color = (1.0 , .0 , .0 ), scale = 0.001 )
188+ ren .sphere (center = orig_data .eeg , color = (1.0 , .0 , .0 ), scale = 0.0022 )
229189
230190 _plot_fid_coord (ren , trans_data , (0 , 0 , 1.0 ))
231- ren .sphere (center = trans_data .eeg , color = (.0 , .0 , 1.0 ), scale = 0.001 )
191+ ren .sphere (center = trans_data .eeg , color = (.0 , .0 , 1.0 ), scale = 0.0022 )
232192
233193
234194 ren .show ()
@@ -252,3 +212,69 @@ def test_bar():
252212 _plot_dig_transformation (trf_montage , montage )
253213
254214 import pdb ; pdb .set_trace ()
215+
216+
217+ @pytest .mark .parametrize ('kind, foo' , [
218+ # XXX All should be 0.085 but they are not !!
219+ # ['EGI_256', 0.08500001],
220+ # ['easycap-M1', 0.08499999999999999],
221+ # ['easycap-M10', 0.08499999999999999],
222+ # ['GSN-HydroCel-128', 9.763325532616348],
223+ # ['GSN-HydroCel-129', 9.781833508100744],
224+ # ['GSN-HydroCel-256', 10.53120179308986],
225+ # ['GSN-HydroCel-257', 10.542564039112401],
226+ # ['GSN-HydroCel-32', 9.334690825727204],
227+ # ['GSN-HydroCel-64_1.0', 11.375727506868348],
228+ # ['GSN-HydroCel-65_1.0', 11.41411195568285],
229+ # ['biosemi128', 103.13293097944218],
230+ # ['biosemi16', 102.54836114601703],
231+ # ['biosemi160', 103.24734353529684],
232+ # ['biosemi256', 102.31834042785782],
233+ # ['biosemi32', 102.66433014370907],
234+ # ['biosemi64', 101.87617188729301],
235+ ['mgh60' , 0.11734227421583884 ],
236+ # ['mgh70', 0.11808759279592418],
237+ # ['standard_1005', 0.1171808880579489],
238+ # ['standard_1020', 0.11460403303216726],
239+ # ['standard_alphabetic', 0.12012639557866846],
240+ # ['standard_postfixed', 0.11887390168465949],
241+ # ['standard_prefixed', 0.11675854869450944],
242+ # ['standard_primed', 0.11887390168465949],
243+ ])
244+ def test_foo (kind , foo ):
245+ """Test standard montage properties (ie: they form a head)."""
246+ import pdb ; pdb .set_trace ()
247+ montage = read_standard_montage (kind )
248+ eeg_loc = np .array ([ch ['r' ] for ch in _get_dig_eeg (montage .dig )])
249+ dist_mean = np .linalg .norm (eeg_loc , axis = 1 ).mean ()
250+ # assert dist_mean == approx(0.085, atol=1e-2)
251+ montage = transform_to_head (montage ) if montage ._coord_frame != 'head' else montage # noqa
252+ eeg_loc = np .array ([ch ['r' ] for ch in _get_dig_eeg (montage .dig )])
253+
254+ # assert_allclose(
255+ # actual=np.linalg.norm(eeg_loc, axis=1),
256+ # desired=np.full((eeg_loc.shape[0], ), EXPECTED_HEAD_SIZE),
257+ # atol=1e-2 # Use a high tolerance for now # tol,
258+ # )
259+ assert np .linalg .norm (eeg_loc , axis = 1 ).mean () == approx (foo )
260+
261+
262+ @pytest .mark .parametrize ('kind, orig_mean, trans_mean' , [
263+ ['mgh60' , 0.09797280213313385 , 0.11734227421583884 ],
264+ ])
265+ def test_foo (kind , orig_mean , trans_mean ):
266+ """Test standard montage properties (ie: they form a head)."""
267+ # import pdb; pdb.set_trace()
268+ montage = read_standard_montage (kind )
269+ eeg_loc = np .array ([ch ['r' ] for ch in _get_dig_eeg (montage .dig )])
270+ assert np .linalg .norm (eeg_loc , axis = 1 ).mean () == approx (orig_mean , abs = 1e-4 )
271+
272+ trans_montage = transform_to_head (montage ) if montage ._coord_frame != 'head' else montage # noqa
273+ trans_eeg_loc = np .array ([ch ['r' ] for ch in _get_dig_eeg (trans_montage .dig )])
274+
275+ # assert_allclose(
276+ # actual=np.linalg.norm(eeg_loc, axis=1),
277+ # desired=np.full((eeg_loc.shape[0], ), EXPECTED_HEAD_SIZE),
278+ # atol=1e-2 # Use a high tolerance for now # tol,
279+ # )
280+ assert np .linalg .norm (trans_eeg_loc , axis = 1 ).mean () == approx (trans_mean , abs = 1e-4 )
0 commit comments