As described in this tutorial: https://github.com/CrawfordGroup/ProgrammingProjects/tree/master/Project%2313