How to extract a timeseries from fmriPrep output with Neurosynth ROI?

Summary of what happened:

I’m trying to use an specific ROI file to mask a functional image (output from fmriprep) to get the average timeseries for that ROI (vmPFC). I’ve generated a NiftiMasker image, but am unsure how to apply it to the functional image.

Command used (and if a helper script was used, a link to the helper script or the command generated):

# Load mask
mask_file = 'vmpfc_association-test_z_FDR_0.01.nii.gz'
mask_file = nilearn.image.math_img("a>=7", a=mask_file)
%matplotlib inline
nilearn.plotting.plot_roi(mask_file)
plt.savefig('vmPFCMask.eps',format='eps')

# Create a masker
fwhm = 4
masker = nilearn.input_data.NiftiMasker(mask_img=mask_file,
                                        smoothing_fwhm=fwhm, standardize=False,
                                        detrend=False, verbose=5)

When trying to do the following, I get an error: ‘NiftiMasker’ object has no attribute 'maps’

ts = roi.extract_timecourse_from_nii(masker,
                                     func_file,
                                     confounds=confounds.values,
                                     t_r=1.0,
                                     high_pass=1./128,
                                    )

Would appreciate any help on this! Thanks.

Hi @cyx203, try the following:

masker = nilearn.input_data.NiftiMasker(mask_img=mask_file,
                                        smoothing_fwhm=fwhm, standardize=False,
                                        detrend=False, verbose=5, high_pass = 1/128, t_r = 1.0)

masker.fit_transform(func_file, confounds=confounds.values)

Best,
Steven Meisler