@@ -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' ]),
0 commit comments