function senstype2layout=cosmo_meeg_senstype2layout_mapping(varargin)
% return mapping from MEEG sensor types to sensor layouts
%
% senstype2layout=cosmo_meeg_senstype2layout_mapping()
%
% Output:
% senstype2layout struct where the fieldnames (keys) are senstypes
% (acquisition systems with a possible suffix
% indicating a type of channel)
% If a senstype does not have an associated layout
% then the corresponding value is set to [].
% Otherwise each value has fields:
% .pos Nx2 x and y coordinates (for N channels)
% .width Nx1 channel widths
% .height Nx1 channel heights
% .label Nx1 cell with channel labels
% .name string with name of layout
%
% Examples:
% % (This example requires FieldTrip)
% cosmo_skip_test_if_no_external('fieldtrip');
% %
% senstype2layout=cosmo_meeg_senstype2layout_mapping();
% % get layout for neuromag306 MEG planar (gradiometers)
% layout=senstype2layout.neuromag306alt_planar;
% cosmo_disp(layout.label)
% %|| { 'MEG0113'
% %|| 'MEG0112'
% %|| 'MEG0122'
% %|| :
% %|| 'MEG2643'
% %|| 'COMNT'
% %|| 'SCALE' }@206x1
% cosmo_disp([layout.pos layout.width layout.height])
% %|| [ -0.408 0.253 0.0358 0.0369
% %|| -0.408 0.284 0.0358 0.0369
% %|| -0.328 0.285 0.0358 0.0369
% %|| : : : :
% %|| 0.373 -0.0821 0.0358 0.0369
% %|| -0.547 -0.5 0.0358 0.0369
% %|| 0.547 -0.5 0.0358 0.0369 ]@206x4
% layout.name
% %|| 'neuromag306planar.lay'
%
% % (This example requires FieldTrip)
% cosmo_skip_test_if_no_external('fieldtrip');
% %
% senstype2layout=cosmo_meeg_senstype2layout_mapping();
% % get layout for neuromag306 MEG combined planar
% % (combined gradiometers)
% layout=senstype2layout.neuromag306alt_planar_combined;
% cosmo_disp(layout.label)
% %|| { 'MEG0112+0113'
% %|| 'MEG0122+0123'
% %|| 'MEG0132+0133'
% %|| :
% %|| 'MEG2642+2643'
% %|| 'COMNT'
% %|| 'SCALE' }@104x1
% cosmo_disp([layout.pos layout.width layout.height])
% %|| [ -0.408 0.273 0.0717 0.0791
% %|| -0.328 0.306 0.0717 0.0791
% %|| -0.377 0.179 0.0717 0.0791
% %|| : : : :
% %|| 0.373 -0.104 0.0717 0.0791
% %|| -0.547 -0.5 0.0717 0.0791
% %|| 0.547 -0.5 0.0717 0.0791 ]@104x4
% layout.name
% %|| 'neuromag306cmb.lay'
%
% % (This example requires FieldTrip)
% cosmo_skip_test_if_no_external('fieldtrip');
% %
% senstype2layout=cosmo_meeg_senstype2layout_mapping();
% % get layout for EEG elec1020
% layout=senstype2layout.eeg1020;
% cosmo_disp(layout.label)
% %|| { 'Fp1'
% %|| 'Fpz'
% %|| 'Fp2'
% %|| :
% %|| 'O2'
% %|| 'COMNT'
% %|| 'SCALE' }@23x1
% cosmo_disp([layout.pos layout.width layout.height])
% %|| [ -0.139 0.428 0.139 0.104
% %|| 0 0.45 0.139 0.104
% %|| 0.139 0.428 0.139 0.104
% %|| : : : :
% %|| 0.139 -0.428 0.139 0.104
% %|| -0.547 -0.5 0.139 0.104
% %|| 0.547 -0.5 0.139 0.104 ]@23x4
% layout.name
% %|| 'EEG1020.lay'
%
% Notes:
% - this function requires FieldTrip, as it uses its collection of
% layouts
% - the output from this function is similar to FieldTrip's
% ft_prepare_layout, but positions are not scaled as in FieldTrip
% - this function caches previously read layouts, for optimization
% reasons. run "clear functions" to reset the cache.
% - this function uses cosmo_meeg_layout_collection and
% cosmo_meeg_senstype_collection to match sensor types with layouts
% - this function does not provide layouts for all sensor types; if you
% find a layout of interest is missing, please get in touch with the
% developers
%
% See also: cosmo_meeg_layout_collection, cosmo_meeg_senstype_collection
%
% # For CoSMoMVPA's copyright information and license terms, #
% # see the COPYING file distributed with CoSMoMVPA. #