[Neuroimaging] Resetting gifti labeltable
Michiel Cottaar
michiel.cottaar at ndcn.ox.ac.uk
Tue Jul 23 08:06:42 EDT 2019
Hi Emma,
It's a bit awkward, but the way I do this is to create an empty GiftiLabelTable and then append individual GiftiLabels to it. Note that the constructor of the GiftiLabel only expects the integer index and the RGBA colour, but you should also set a label (when serialising the GiftiLabelTable expects all labels to have such a label).
So my code looks like:
labeltable = gifti.GiftiLabelTable()
for value, (text, rgba) in color_map.items():
labeltable.labels.append(gifti.GiftiLabel(value, *rgba))
labeltable.labels[-1].label = str(text)
where color_map is a dictonary mapping from the indices to a tuple with the label and the RGBA value.
Cheers,
Michiel
On 23 Jul 2019, at 12:30, Emma Robinson <emma.robinson01 at gmail.com<mailto:emma.robinson01 at gmail.com>> wrote:
Hi
I am trying to create a new gifti label file using an existing one as template. How do I change the label table? I've create a new label dictionary as variable 'labeldict' but I cannot create a GiftiLabelTable instance from this see:
nibabel.gifti.GiftiLabelTable(labeldict)
Traceback (most recent call last):
File "<ipython-input-34-d948ed166e6e>", line 1, in <module>
nibabel.gifti.GiftiLabelTable(labeldict)
TypeError: __init__() takes 1 positional argument but 2 were given
Could someone tell me how it is supposed to be done?
Thanks
Emma
_______________________________________________
Neuroimaging mailing list
Neuroimaging at python.org<mailto:Neuroimaging at python.org>
https://mail.python.org/mailman/listinfo/neuroimaging
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20190723/b0070228/attachment.html>
More information about the Neuroimaging
mailing list