Skip to content

In MATLAB, I use write_annotation(fname, v, L, ct) to save an annotation file where: v is a 40962x1 matrix. L is a 40962x1 matrix. ct.table is a 113x5 array. This MATLAB code runs without problems. #1376

@SuperLuckyKris

Description

@SuperLuckyKris

In MATLAB, I use write_annotation(fname, v, L, ct) to save an annotation file where:
v is a 40962x1 matrix.
L is a 40962x1 matrix.
ct.table is a 113x5 array.
This MATLAB code runs without problems.
However, in Python, I encountered an error when using FreeSurfer's nibabel.freesurfer.write_annot function. Here is my Python code:
nib.freesurfer.write_annot(fname, labels, ct_table, names)
where:
labels is a 40962x1 array.
ct_table is a 113x5 array.
names is a list of structure names.
File ‘F:\Desktop\Individualising PythonCoder\func_WriteParcellation_to_annotation_fs6_113LUT.py’, line 64, in func_WriteParcellation_to_annotation_ fs6_113LUT
nib.freesurfer.write_annot(fname,labels, ct_table,names)
File ‘C:\Users\kris\AppData\Local\Programs\Python\Python311\Lib\site-packages\nibabel\freesurfer\io.py’, line 541, in write_annot
clut_labels = ctab[:, -1][labels]
~~~~~~~~~~~^^^^^^^^
IndexError: index 11403468 is out of bounds for axis 0 with size 113

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions