Implementation of algorithms shown in http://imamci.oxfordjournals.org/content/17/1/1.abstract