How to determine labels for each time series returned from Nilearn's NiftiLabelsMasker?

I am using the Nilearn NiftiLabelsMasker to extract time series from various deterministic atlases. I need to label the regions associated with each time series to provide as files to a colleague.

The examples in Nilearn’s documentation appear to assume that the time series will be returned in the same order as the labels that are provided in standard atlases.

Is this always the case? What about for atlases like AAL in which the integer assigned to each label are not related to the label index?

In general, how do I determine which region label is associated with each column in the returned time series matrix?

Hi @heuristicwondering and welcome to Neurostars!

When you fetch the AAL atlas, you not only get the brain map but also a lookup table, that maps the intensity of the brain maps to the label name. The nth row of the time series you get from the masker should correspond to the nth row of that lookup table.

Best,
Steven

1 Like

Thank you for the prompt reply, @Steven! This is exactly the information I needed!

1 Like

in general, if the atlas gives you a list of labels containing the region names, the label associated with column j is given by the masker’s labels_ attribute by taking labels[masker.labels_[j]] – there is ongoing work to make this more straightforward, see this issue for details

2 Likes

@jeromedockes, thanks for the added context. I’m modifying atlas regions and removing others, so knowing how to confirm the timeseries label without ambiguity is really helpful.

1 Like