Nilearn NiftiLabelsMasker returns less timecourses than labels (by more than 1...)

Hi,
When running niftilabelsmasker.fit- on Harvard Oxford 1mm maxprob, 50 threshold- I get (volumns,93) shaped data instead of 96 (lateralized) . How can one easily extract the labels for the extracted regions? (usually I would just ignore the first- the background, but if it’s less than (labels_length-1)- one can’t match the ROIs with the labels.
It there a way to get the mapping between the labels and the returned matrix? (the best practice would maybe be to return a dataframe with the labels as column names…)
Thanks!

@GaelVaroquaux

Hi, it seems to be because the atlas contains some empty regions (e.g. ‘Superior Temporal Gyrus, posterior division’ contains no voxels). but the masker, once fitted, has a labels_ attribute to tell you to which label corresponds each dimension of the masked data. you can get back the label names with np.asarray(atlas.labels)[masker.labels_]

1 Like

Many many thanks for your great help.

you’re welcome! good luck with your project

1 Like