Note that this reference documentation is identical to the help that is displayed in MATLAB when you type “help ft_prepare_layout”.

  FT_PREPARE_LAYOUT loads or creates a 2-D layout of the channel locations.
  This layout is required for plotting the topographical distribution of
  the potential or field distribution, or for plotting timecourses in a
  topographical arrangement.
  Use as
    layout = ft_prepare_layout(cfg, data)
  There are several ways in which a 2-D layout can be made: it can be read
  directly from a *.mat file containing a variable 'lay', it can be created
  based on 3-D electrode or gradiometer positions in the configuration or
  in the data, or it can be created based on the specification of an
  electrode or gradiometer file. Layouts can also come from an ASCII *.lay
  file, but this type of layout is no longer recommended.
  You can specify any one of the following configuration options
    cfg.layout      filename containg the layout (.mat or .lay file)
                    can also be a layout structure, which is simply
                    returned as-is (see below for details)
    cfg.rotate      number, rotation around the z-axis in degrees (default = [], which means automatic)
    cfg.projection  string, 2D projection method can be 'stereographic', 'orthographic',
                    'polar', 'gnomic' or 'inverse' (default = 'polar')
    cfg.elec        structure with electrode definition, or
    cfg.elecfile    filename containing electrode definition
    cfg.grad        structure with gradiometer definition, or
    cfg.gradfile    filename containing gradiometer definition
    cfg.opto        structure with optode structure definition, or
    cfg.optofile    filename containing optode structure definition
    cfg.output      filename (ending in .mat or .lay) to which the layout
                    will be written (default = [])
    cfg.montage     'no' or a montage structure (default = 'no')
    cfg.image       filename, use an image to construct a layout (e.g. useful for ECoG grids)          if an image is used and bw = 1 transforms the image in
                    black and white (default = 0, do not transform)
    cfg.overlap     string, how to deal with overlapping channels when
                    layout is constructed from a sensor configuration
                    structure (can be 'shift' (shift the positions in 2D
                    space to remove the overlap (default)), 'keep' (don't
                    shift, retain the overlap), 'no' (throw error when
                    overlap is present))
   cfg.skipscale    'yes' or 'no', whether the scale should be included in the layout or not (default = 'no')
   cfg.skipcomnt    'yes' or 'no', whether the comment should be included in the layout or not (default = 'no')
  Alternatively the layout can be constructed from either
    data.elec     structure with electrode positions
    data.grad     structure with gradiometer definition
    data.opto     structure with optode structure definition
  Alternatively you can specify the following layouts which will be
  generated for all channels present in the data. Note that these layouts
  are suitable for multiplotting, but not for topoplotting.
    cfg.layout = 'ordered'   will give you a NxN ordered layout
    cfg.layout = 'vertical'  will give you a Nx1 ordered layout
    cfg.layout = 'butterfly' will give you a layout with all channels on top of each other
    cfg.layout = 'circular'  will distribute the channels on a circle
  The output layout structure will contain the following fields
    layout.label   = Nx1 cell-array with channel labels
    layout.pos     = Nx2 matrix with channel positions
    layout.width   = Nx1 vector with the width of each box for multiplotting
    layout.height  = Nx1 matrix with the height of each box for multiplotting
    layout.mask    = optional cell-array with line segments that determine the area for topographic interpolation
    layout.outline = optional cell-array with line segments that represent
                   the head, nose, ears, sulci or other anatomical features