Skip to content

Commit e018adf

Browse files
committed
FIX: Correctly write .annot files with duplicate labels
1 parent 63b7a52 commit e018adf

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

nibabel/freesurfer/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ def write_string(s):
561561
write(-2)
562562

563563
# maxstruc
564-
write(np.max(labels) + 1)
564+
write(max(np.max(labels) + 1, ctab.shape[0]))
565565

566566
# File of LUT is unknown.
567567
write_string('NOFILE')

nibabel/freesurfer/tests/test_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def test_label():
359359

360360

361361
def test_write_annot_maxstruct():
362-
"""Verify we can write files with repeated labels - test by reading"""
362+
"""Test writing ANNOT files with repeated labels"""
363363
with InTemporaryDirectory():
364364
nlabels = 3
365365
names = ['label {}'.format(l) for l in range(1, nlabels + 1)]

0 commit comments

Comments
 (0)