parsing mat files