Skip to content

Commit

Permalink
Error out if we get to Positions before UnitPosition.
Browse files Browse the repository at this point in the history
Cleanup: replace conditionals with a lookup into a dict.
  • Loading branch information
chrismullins committed Aug 17, 2016
1 parent 1a9f1e8 commit 51c35ce
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions mne/channels/montage.py
Expand Up @@ -207,15 +207,13 @@ def read_montage(kind, ch_names=None, path=None, unit='m', transform=False):
pos = []
with open(fname) as fid:
# Default units are meters
scale_factor = 1.
for line in fid:
if 'UnitPosition' in line:
units = line.split()[1]
if units == 'm':
break
elif units == 'mm':
scale_factor = 1. / 1000.
break
scale_factor=dict(m=1., mm=1e-3)[units]
break
elif 'Positions\n' in line:
raise RuntimeError('Could not detect units in file %s' % fname)
for line in fid:
if 'Positions\n' in line:
break
Expand Down

0 comments on commit 51c35ce

Please sign in to comment.