NiftiLabelsMasker doesnt apply mask corectly when time series is extracted

Hello NeuroStars Community,

I am encountering an issue in my resting-state fMRI data analysis where I am using the 7 resting-state networks (RSNs) proposed by Yeo et al. My analysis is performed using Nilearn, and I have followed these steps:

  1. I used the clean_img function from Nilearn for denoising and applying a mask for one specific resting-state network to ensure that clean_img only retains data from this targeted network, effectively removing all other network data.

like this:

clean_img = image.clean_img(resampled_img, detrend=True, standardize='zscore_sample', t_r=t_r, confounds=all_regs, high_pass=0.008,low_pass=0.09, mask_img=RSN_mask)
                

and the RSN_mask is really just one network. and when i checked the clean_img the mask was applied correctly and the image looked as it supposed to with just that one RSN.

  1. Following this, I used the NiftiLabelsMasker function to extract the time series for the specific RSN that I am interested in.

like this:

masker = NiftiLabelsMasker(labels_img=yeo, mask_img=RSN_mask, standardize="zscore_sample", t_r=t_r)
time_series = masker.fit_transform(clean_img)

and the labels_img yeo is the fetch atlas yeo from nilearn.

Problem: My expectation in this analysis was to obtain time series for all 7 RSNs defined by Yeo (because of labels_img=yeo), but with a specific characteristic: all the time series corresponding to the 6 RSNs not included in my mask should be zeros, and only the time series for the one RSN that I applied the mask to should show actual data. However, the output showed non-zero time series for all 7 RSNs, not just the one RSN I focused on. This is confusing, as I had used the mask in the clean_img step specifically to isolate the data for only the targeted RSN, anticipating that this would result in zeroed data for the other networks.

I am looking for guidance on where my process might be going wrong or if there are any additional steps or modifications I need to make.

Thank you in advance for your insights and assistance!

Hi @Firu,

That is not what mask_img is doing in this context.
From the documentation:

mask_img Niimg-like object, optional

If provided, signal is only cleaned from voxels inside the mask. If mask is provided, it should have same shape and affine as imgs. If not provided, all voxels are used. See Input and output: neuroimaging data representation.

So, the output will still have data throughout the brain, but only cleaned in certain places.

For this, it would help to see some plots showing what yeo and RSN_mask look like overlaid on the brain you are extracting data from. You do not show how these files are made, so we cannot confirm that they represent what you say they are.

Alternatively, you can do no masking, and just zero out data you are not interested in after applying the NiftiLabelsMasker

Best,
Steven