Preferred method for extracting bold timecourse based on anatomically defined regions?

freesurfer
registration
fmriprep

#1

This is probably pretty simple, but I’ve been banging my head on it for an embarrassingly long time and would like some input. I’m looking for a way to extract voxel-wise timecourses based on anatomically defined ROIs in T1w-space. That is, I have regions that are defined in each participants’ anatomical space (defined using https://hub.docker.com/r/nben/occipital_atlas/), and I would like to down-sample those regions into each participants’ functional space for use as a mask.

The data are being processed with fmriprep, and I was hoping that I could avoid re-registering anything by relying on one of the outputs produced in the /work directory. I assumed there was a .dat I could use with freesurfer’s mri_label2vol, but I’m not sure which .dat I should be using. (also, I haven’t used freesurfer much before and so am not confident about mri_label2vol is necessarily the one I want).

Thanks

Update: The closest that I’ve gotten is using the “uni_masked_bbreg_sub-01.dat” file from one of the bbregister node, and then mri_vol2vol, as in:

mri_vol2vol --s sub-01 --mov "sub-01_task-con_run-01_TR-0-1_bold_space-T1w_preproc.nii.gz" --reg "uni_masked_bbreg_sub-01.dat" --nearest --inv --targ "scanner.template_areas.mgz" --o "T1w.template_areas.nii"

where “sub-01_task-con_run-01_TR-0-1_bold_space-T1w_preproc.nii.gz” is a single TR of a functional run and “scanner.template_areas.mgz” contains the labels (which should be in the same space as the raw anatomical image). The result is close, but the labels are slightly offset and contain voxels outside of the brain.


Create individual brain mask (anatomical ROI) from FMRIPREP Freesurfer outputs?
#2

The atlas you are trying to use seems to be defined on the surface - thus it makes sense to use surface outputs of FMRIPREP. To ensure those are created you should add fsnative to the output spaces. For example --output-space T1w fsnative template fsaverage will produce outputs in the MNI space (the default template), subject native volume T1w space, subject native surface space (fsnative) and fsaverage. Running FMRIPREP with such options will lead to creation of *bold_space-fsnative_preproc.*.gii files which you can load together with [l|r].template_areas.mgz files (created by nben/occipital_atlas) in nibabel to extract the timeseries. Application of any affine matrices or other transformations should not be necessary since the FMRIPREP should be already sampled in the native subject surface.

nilearn migh also support using gifti and mgz files to perform timeseries extraction, but I never tried it.


#3

Regarding your mri_vol2vol command, it looks like you’ve been doing some digging in the work directory, which will save you time. The transform from BOLD to T1w space (which is slightly different from FreeSurfer’s T1 space) is bold_reg_wf/bbreg_wf/transformer/transform.mat, not the .dat file.

The above is relevant if you parcellations are volumetric and not surface-based. If they are surface-based, then you’ll either want to do the analysis in the surface or use mri_surf2vol (probably with --fillribbon) to get a volumetric parcellation, which you can use mri_vol2vol to translate.

For a little more context, see Preprocessing for atlas based connectivity matrices.

mri_label2vol will only be useful if you have a .label file, which a cursory glance at the README you linked to suggests not.


#4

Thanks ChrisGorgolweski and effigies for the replies. It turns out that we’ll probably just stick with a surface-based analysis after all.

Given that, am I correct in thinking that nipype’s interface to freesurfer’s glm_fit is the only option currently available? about using nipype for a first-level, surface-based glm,? Nistats was listed in Simple first-level GLM in Python, but it seems like it doesn’t yet interface with nipype (and, would it do glms on a gifti image?)


#5

I believe mri_glmfit requires data in a binary format like MGH or NIfTI, as opposed to an XML format like GIFTI. I’ve wrangled fmriprep outputs into FSFAST’s structure, and used FSFAST to run a basic GLM, but I have not tried using mri_glmfit through nipype.

Although the capabilities are virtually unadvertised, SPM12 and the most recent FSL also can perform surface-based GLMs. However, I was unsuccessful at using FSL, and did not attempt SPM12.


#6

Oh, I didn’t know that SPM12 was supposed to be able to handle this. That would be super convenient.

@effigies - do you happen to know whether there exists documentation or an example of using func.gii files in an SPM12 GLM? If I just try specifying matlabbatch{1}.spm.stats.fmri_spec.sess.scans = {'[filename].func.gii'}, SPM12 seems unable to recognize the filetype.

Running ‘fMRI model specification’
Warning: Cannot recognise format. Trying Analyze.

In read_hdr_raw (line 50)
In read_hdr (line 30)
In nifti (line 26)
In spm_select>spm_select_get_nbframes (line 268)
In spm_select>spm_select_expand (line 254)
In spm_select (line 130)
In spm_run_fmri_spec (line 125)
In cfg_run_cm (line 29)
In cfg_util>local_runcj (line 1688)
In cfg_util (line 959)
In cfg_ui>MenuFileRun_Callback (line 703)
In gui_mainfcn (line 95)
In cfg_ui (line 53)
Failed ‘fMRI model specification’
Error using read_hdr (line 52)
Unrecognised datatype (30583.000000) for “D:\git\fMRI\ntf\data\derivatives\fmriprep\sub-01\func\sub-01_task-loc_run-01_bold_space-fsnative.L.func.gii”.
In file “D:\documents\MATLAB\toolbox\spm12@nifti\private\read_hdr.m” (v4967), function “read_hdr” at line 52.
In file “D:\documents\MATLAB\toolbox\spm12@nifti\nifti.m” (v4986), function “nifti” at line 26.
In file “D:\documents\MATLAB\toolbox\spm12\spm_select.m” (v6530), function “spm_select_get_nbframes” at line 268.
In file “D:\documents\MATLAB\toolbox\spm12\spm_select.m” (v6530), function “spm_select_expand” at line 254.
In file “D:\documents\MATLAB\toolbox\spm12\spm_select.m” (v6530), function “spm_select” at line 130.
In file “D:\documents\MATLAB\toolbox\spm12\config\spm_run_fmri_spec.m” (v6562), function “spm_run_fmri_spec” at line 125.

No executable modules, but still unresolved dependencies or incomplete module inputs.
The following modules did not run:
Failed: fMRI model specification`


Analyzing func.gii files with SPM12
#7

Unfortunately, no, I don’t have any direct experience that would be useful here, as my own analyses were all in FreeSurfer or PyMVPA. I have some experience using FSL in volumetric analyses through nipype, but next to none in SPM.

It might be worth making a separate thread here asking for people’s experience with surface-based analyses outside of FreeSurfer.


#8

okay, thanks. new thread started at Analyzing func.gii files with SPM12