this should go to `mne/utils.py` and probably deserves some testing.