[Neuroimaging] Resetting gifti labeltable

Emma Robinson emma.robinson01 at gmail.com
Fri Jul 26 03:56:36 EDT 2019


Thanks!

Could you possibly show me how you create your colour_map dictionary? What
I've tried so far has not been working.

Emma



On Tue, 23 Jul 2019 at 13:50, Michiel Cottaar <michiel.cottaar at ndcn.ox.ac.uk>
wrote:

> 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> 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
> https://mail.python.org/mailman/listinfo/neuroimaging
>
>
> _______________________________________________
> Neuroimaging mailing list
> 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/20190726/72f8bd90/attachment.html>


More information about the Neuroimaging mailing list