NiftiLabelsMasker fit_transform gives only a single array per image

this is quite confusing as I was using the atlas provided in conn toolbox, which has 132 regions
However when extracting data, I was expecting a
roi * voxels map of sort.

At least what I’m trying to get is the signals in each ROI
but the result seems to averaged value of given ROI

is there a way to get the raw value of rois based on atlas in nilearn?

Hi,
You could use NiftiMasker providing each time a ROI mask as an input. NiftiMasker gives you raw values unlike NiftiLabelsMasker or NiftiMapsMasker.

Best,
Kamalakar

1 Like

Thanks for the tips kamalakar!

hi Kamalaker,

I ended up using input_data.NiftiMasker as you suggested. The way I handled this is I have decompsed atlas image into independent roi masks.

then in the NiftiMasker, I resample the mask to the data shape and affine…
The resulting signals lengths seems a bit off tho (vs the expected number of voxels I computed.)

sample code:

    img = nb.load(data)
    print ('roi shape', img.shape)
    masker = input_data.NiftiMasker(
        mask_img=roi_mask,
        target_affine=img.affine,
        target_shape=img.shape[:3],
    )
   masker.fit(data)
   makser.transform(data)

Is this the correct way of handling roi masks? thanks!

I don’t see any issue in the code provided that the data you are fitting on is a functional data.
Best,
Kamalakar