The complete algorithm is published in the following paper: S. S. Ali and L. Zhang, "Maximum entropy based common spatial patterns for motor imagery classification," 2016 38th Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC), Orlando, FL, 2016, pp. 5865-5868. doi: 10.1109/EMBC.2016.7592062