Skip to content

Commit

Permalink
FIX: Use genfromtxt to read channel names from .locs (mne-tools#6090) (
Browse files Browse the repository at this point in the history
…mne-tools#6095)

Channel names read from .loc, .locs, and .eloc files were truncated to 4
character strings ("S4" numpy dtype).  Using genfromtxt with "str" as
dtype lets numpy determine the required length and allows for reading
unicode characters as well.
  • Loading branch information
achilleas-k authored and cbrnr committed Mar 30, 2019
1 parent 673573c commit d7cb438
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions mne/channels/montage.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,7 @@ def read_montage(kind, ch_names=None, path=None, unit='m', transform=False):
ch_names_ = data['name'].astype(str).tolist()
pos = np.vstack((data['x'], data['y'], data['z'])).T
elif ext in ('.loc', '.locs', '.eloc'):
ch_names_ = np.loadtxt(fname, dtype='S4',
usecols=[3]).astype(str).tolist()
ch_names_ = np.genfromtxt(fname, dtype=str, usecols=3).tolist()
topo = np.loadtxt(fname, dtype=float, usecols=[1, 2])
sph = _topo_to_sph(topo)
pos = _sph_to_cart(sph)
Expand Down

0 comments on commit d7cb438

Please sign in to comment.