updated to work for beamforming and MNE data which has only 1 averaged trial.
previous version didn't work properly, changes made, and order of input arguments changed