Skip to content

Commit 1b9ff53

Browse files
committed
bad solution: breaks 3 topo tests [ci skip]
1 parent de3237c commit 1b9ff53

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

mne/channels/channels.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,8 @@ def _get_ch_info(info):
14481448

14491449
has_any_meg = any([has_vv_mag, has_vv_grad, has_4D_mag, has_CTF_grad,
14501450
n_kit_grads])
1451-
has_eeg_coils = (FIFF.FIFFV_COIL_EEG in coil_types and
1451+
has_eeg_coils = ((FIFF.FIFFV_COIL_EEG in coil_types or
1452+
FIFF.FIFFV_COIL_EEG_CSD in coil_types) and
14521453
FIFF.FIFFV_EEG_CH in channel_types)
14531454
has_eeg_coils_and_meg = has_eeg_coils and has_any_meg
14541455
has_eeg_coils_only = has_eeg_coils and not has_any_meg

mne/channels/layout.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ def read_layout(kind, path=None, scale=True):
214214
return Layout(box=box, pos=pos, names=names, kind=kind, ids=ids)
215215

216216

217-
def make_eeg_layout(info, radius=0.5, width=None, height=None, exclude='bads'):
217+
def make_eeg_layout(info, radius=0.5, width=None, height=None, exclude='bads',
218+
ch_types=['eeg']):
218219
"""Create .lout file from EEG electrode digitization.
219220
220221
Parameters
@@ -232,6 +233,9 @@ def make_eeg_layout(info, radius=0.5, width=None, height=None, exclude='bads'):
232233
exclude : list of str | str
233234
List of channels to exclude. If empty do not exclude any.
234235
If 'bads', exclude channels in info['bads'] (default).
236+
ch_types : list of str
237+
Which channel types will be included. Currently the only supported
238+
options are ``'eeg'`` and ``'csd'``.
235239
236240
Returns
237241
-------
@@ -249,8 +253,14 @@ def make_eeg_layout(info, radius=0.5, width=None, height=None, exclude='bads'):
249253
if height is not None and not (0 <= height <= 1.0):
250254
raise ValueError('The height parameter should be between 0 and 1.')
251255

252-
picks = pick_types(info, meg=False, eeg=True, ref_meg=False,
253-
exclude=exclude)
256+
# check for CSD
257+
kwargs = dict(meg=False, ref_meg=False, exclude=exclude)
258+
ch_types = [ch_types] if isinstance(ch_types, str) else ch_types
259+
for ch_type in ch_types:
260+
if ch_type is not None:
261+
kwargs.update({ch_type: True})
262+
263+
picks = pick_types(info, **kwargs)
254264
loc2d = _find_topomap_coords(info, picks)
255265
names = [info['chs'][i]['ch_name'] for i in picks]
256266

@@ -383,7 +393,8 @@ def find_layout(info, ch_type=None, exclude='bads'):
383393
layout : Layout instance | None
384394
None if layout not found.
385395
"""
386-
_check_option('ch_type', ch_type, [None, 'mag', 'grad', 'meg', 'eeg'])
396+
_check_option('ch_type', ch_type, [None, 'mag', 'grad', 'meg', 'eeg',
397+
'csd'])
387398

388399
(has_vv_mag, has_vv_grad, is_old_vv, has_4D_mag, ctf_other_types,
389400
has_CTF_grad, n_kit_grads, has_any_meg, has_eeg_coils,
@@ -411,19 +422,18 @@ def find_layout(info, ch_type=None, exclude='bads'):
411422
layout_name = 'Vectorview-grad'
412423
elif has_neuromag_122_grad:
413424
layout_name = 'Neuromag_122'
414-
elif ((has_eeg_coils_only and ch_type in [None, 'eeg']) or
425+
elif ((has_eeg_coils_only and ch_type in [None, 'eeg', 'csd']) or
415426
(has_eeg_coils_and_meg and ch_type == 'eeg')):
416427
if not isinstance(info, (dict, Info)):
417428
raise RuntimeError('Cannot make EEG layout, no measurement info '
418429
'was passed to `find_layout`')
419-
return make_eeg_layout(info, exclude=exclude)
430+
return make_eeg_layout(info, exclude=exclude, ch_types=[ch_type])
420431
elif has_4D_mag:
421432
layout_name = 'magnesWH3600'
422433
elif has_CTF_grad:
423434
layout_name = 'CTF-275'
424435
elif n_kit_grads > 0:
425436
layout_name = _find_kit_layout(info, n_kit_grads)
426-
427437
# If no known layout is found, fall back on automatic layout
428438
if layout_name is None:
429439
xy = _find_topomap_coords(info, picks=range(info['nchan']),

mne/viz/evoked.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2250,7 +2250,7 @@ def click_func(
22502250
picks=picks[pick_], combine=combine, axes=ax_, show=True,
22512251
sphere=sphere)
22522252

2253-
layout = find_layout(info)
2253+
layout = find_layout(info, ch_type=ch_type)
22542254
# shift everything to the right by 15% of one axes width
22552255
layout.pos[:, 0] += layout.pos[0, 2] * .15
22562256
layout.pos[:, 1] += layout.pos[0, 3] * .15

0 commit comments

Comments
 (0)