I’m trying to use nilearn’s NiftiMasker function to extract gray matter.
I’ve run into variable degrees of compatibility with a probabilistic mask. Masking to generate reports seems fine. But when I try to save the masked data, I get an error stating that the mask isn’t binary:
nii_masker = NiftiMasker(mask_img=graymatter_mask, memory="nilearn_cache", memory_level=2, reports=1, t_r=TR) nii_masker.fit(epi) # this is fine report = nii_masker.generate_report() # no problems with reports, masking appears reasonable epi_masked_2d = nii_masker.transform(epi) # here, nilearn complains that the mask isn't binary
Does anyone know of any workarounds, short of just binarizing the probabilistic mask?
As always, thanks for your help.