MHD stability analysis of ELMs in MAST