MATLAB and Python code for MTB stuff