Skip to content

Commit 8880a1a

Browse files
simkarwineffigies
andauthored
Update nibabel/freesurfer/io.py
Co-authored-by: Chris Markiewicz <[email protected]>
1 parent 84d6e04 commit 8880a1a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

nibabel/freesurfer/io.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -639,13 +639,10 @@ def read_stats_file(file_path):
639639
"""
640640
with open(file_path, 'r') as f:
641641
for line in f:
642-
if re.findall(r'ColHeaders .*', line):
643-
parameters = line.split()
642+
if line.startswith('# ColHeaders '):
643+
columns = line.split()[2:]
644644
break
645-
f.close()
646-
stats = np.loadtxt(file_path, comments='#', dtype=str)
647-
column_names = parameters[2:]
648-
return stats, column_names
645+
return np.genfromtxt(f, dtype=None, names=columns, encoding='utf-8')
649646

650647

651648
def read_stats_file_both_hemispheres(file_path: str):

0 commit comments

Comments
 (0)