Oh, I love English language. In this case it is how it sounds when spoken, so it's AN. Often the easy way to work it out is to say the phrase to oneself and understand how it would sound to a listener.
That's my take on it, too..
A MRI sounds kinda clunky..

