[Neuroimaging] Are the values returned by nilearn NiftiMapsMasker.fit() averages, sums, weigthed or not?

Christophe Pallier christophe at pallier.org
Wed Jan 22 06:35:15 EST 2020


Dear all,

I am using a NiftiMapsMasker object to extract data from stats maps.

I expected it to compute the average values of the voxels defined by
the non-null voxels in the masks.

It seems that I am wrong:
1. when the mask are not binarized, the  returned values are different
than if the mask is not binarized. I suspect the niftimapsmasker is
weighting by the voxel values from the masks.
2. It seems to be computing the sum rather than the average of the
values within the masks, as the following code shows:

Can anyone confirm or disconfirm?

---
import numpy as np

import nibabel as nib
from nilearn.input_data import NiftiMapsMasker

ROIs = ['bin_entire-roi.nii', 'bin_part1-roi.nii',  'bin_part2-roi.nii']

# get the size of masks (in voxels)
imgs = [nib.load(f) for f in ROIs]
data = [i.get_data() for i in imgs ]
sizes = [np.count_nonzero(d) for d in data]

# extract contrast values inside the ROIs
images =  ['contrast.nii.gz']
masker = NiftiMapsMasker(ROIs)
values = masker.fit_transform(images)

print("values (whole, part1, part2)", end=':')
print(values[0])

print("sum of part1 and part2", end=':')
print(np.sum(values[0][1:]))

print("weighted mean of part 1 and part2:", end=':')
print((values[0][1]*sizes[1] + values[0][2]*sizes[2])/(sizes[1] + sizes[2]))
---

values (whole, part1, part2):[ -6.95688541  32.0976529  -39.05453831]
sum of part1 and part2:-6.956885409069663
weighted mean of part 1 and part2::-30.661250335048116


--
Christophe Pallier <christophe at pallier.org>
PS: I have a cat who loves to walk on my keybxxxxxxxxxxxxxxxxxxxxxxx
and she often presses the send key before I am finished writing the
email.


More information about the Neuroimaging mailing list