This matlab code and example signal reproduces the figures that are shown in the following lecture that was part of the MEG@McGill Comprehensive training:
https://www.mcgill.ca/bic/training-events/training-programs/meg-comprehensive-training
The code uses some functions from the Brainstorm M/EEG toolbox