Use your own forward leadfield model in an inverse beamformer computation

You can use externally precomputed leadfield matrices for each dipole location on which you want to compute the beamformer solution. That is usually done using the ft_prepare_leadfield function, and the main purpose is to speed up the source reconstruction. The output of ft_prepare_leadfield can be used as input in ft_sourceanalysis, and you should construct a matlab structure that resembles the output of ft_prepare_leadfield. The best way of getting to know the format of the precomputed leadfields is by computing the leadfield for a spherical model and look at it.

Using the geometrical description of the sensor locations and the geometrical description of the volume conductor model, you now can compute the leadfield for the locations of interest. By default we scan with the beamformer on a regularly spaced 3D grid of approximately 1 cm resolution. Here is an example for computing the leadfields.

The idea now is that, using your own forward model, you construct a “grid” structure with the same elements. Note that the channel numbering should correspond with the channels in the data, and that the EEG leadfields should be averaged referenced.