Skip to content

Commit 909c384

Browse files
committed
BF nibabel.freesurfer.read_label is not equivalent; revert
1 parent 8e2167f commit 909c384

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

surfer/io.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,31 @@ def read_scalar_data(filepath):
100100
return scalar_data
101101

102102

103+
def read_label(filepath, read_scalars=False):
104+
"""Load in a Freesurfer .label file.
105+
106+
Parameters
107+
----------
108+
filepath : str
109+
Path to label file
110+
read_scalars : bool
111+
If true, read and return scalars associated with each vertex
112+
113+
Returns
114+
-------
115+
label_array : numpy array (ints)
116+
Array with indices of vertices included in label
117+
scalar_array : numpy array (floats)
118+
If read_scalars is True, array of scalar data for each vertex
119+
120+
"""
121+
label_array = np.loadtxt(filepath, dtype=np.int, skiprows=2, usecols=[0])
122+
if read_scalars:
123+
scalar_array = np.loadtxt(filepath, skiprows=2, usecols=[-1])
124+
return label_array, scalar_array
125+
return label_array
126+
127+
103128
def read_stc(filepath):
104129
"""Read an STC file from the MNE package
105130

surfer/viz.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,10 +704,9 @@ def add_label(self, label, color="crimson", alpha=1,
704704
% filepath)
705705
# Load the label data and create binary overlay
706706
if scalar_thresh is None:
707-
ids = nib.freesurfer.read_label(filepath)
707+
ids = io.read_label(filepath)
708708
else:
709-
ids, scalars = nib.freesurfer.read_label(filepath,
710-
read_scalars=True)
709+
ids, scalars = io.read_label(filepath, read_scalars=True)
711710
ids = ids[scalars >= scalar_thresh]
712711
else:
713712
# try to extract parameters from label instance

0 commit comments

Comments
 (0)