Extracting time series for a certain MNI position

Dear all,
Sorry for the newbie question-
I’ve executed fmriprep for the first time.
How do I manually extract timeserie(s) for a certain (x,y,z) MNI position(s)?
(i.e.- how to I manually slice, or- how do I transform between MNI outputs of fmriprep and the nifti’s indexes)


This might be useful http://blog.chrisgorgolewski.org/2014/12/how-to-convert-between-voxel-and-mm.html

1 Like

Thank you, though I’ve asked now someone from my lab, and he told me that the (x,y,z) mni usually refers to mm, so I’m a bit puzzled…

There is a broken link in the page-
“The requested URL /pipermail/nipy-devel/2013-October/009515.html was not found on this server.”
Can you please add another word about this-
So- the “sub-001_task-mytask_bold_space-MNI152NLin2009cAsym_preproc.nii” output of fmriprep is in 1 over 1 over 1 mm space?

Many thanks!

Yes that is correct. Please mind that voxel coordinates are also three dimensional. Sometimes they are referred to as (i, j, k).

It is in the MNI space, but the resolution will match the resolution of the input data. Mind that data in one space can be expressed in different resolutions via resampling/reslicing. More at BIDS -> fmriprep transforms to (3.5 x 3.75 x 3.75) MNI space?

Many thanks for your answers!

So, in order to slice to the (i,j,k) mm- I only need to do something similar to:
template = load_mni152_template()
mmnmi=nilearn.image.resample_to_img(my nii image, template)

and then I may slice the NMI (i,j,k) directly from mmnmi?

BTW- if we are already talking about spatial interpolation-
what is the best practice for temporal upsampling of bold signals?
Does fmriprep offers such functionality, or some other python-neuro package?

Thanks a lot!

Yes this would reslice your image to the resolution of the template. However, judging from the nomenclature you use I still feel there is some confusion. Maybe reading this will help: http://nipy.org/nibabel/coordinate_systems.html

I’m sure there are functions in scipy that can do this. Out of curiosity - why would you want to do this?

1 Like

Thanks a lot.

Regarding the interpolation-
I might want to play with some regression models (with frequency higher than 1/3 Hz…).

Thank again- Chris- the reference helped me, indeed!

BTW- I believe that a better solution would be to run fmriprep with:
–template-resampling-grid 1mm

Am I correct?

IMHO the best option is to use nilearn to extract timeseries from images in their native resolution instead of upsampling or rerunning FMRIPREP. More details here http://nilearn.github.io/connectivity/functional_connectomes.html

1 Like


Regarding the confounds- these should be added to the calls although fmriprep “cleans them” (corrects motion etc.)?

I should add a code to switch NaNs in the confounds file.
Do you happen to know about the best way to handle the NANs in the confounds file?

Many thanks

Not sure what you refer to when saying “them” - confounds themselves? Input NiFTIs?

Replacing nans with zero or mean seems reasonable.

Well, it would have been quite problematic to call these without the nifti’s :slight_smile:
I meant- why is it crucial to add the confounds file if fmriprep already “cleaned them” (or- cleaned some of them?)

And another question-
The tutorial is great- thanks (I’ll also read the paper soon), though I’m still not sure why using the nilearn instead of upsampling in fmriprep makes a difference- the difference is that fmriprep does “hard parcellation” and in nilearn offers more options?

Many thanks for your help!