Fmriprep covariates (motion, etc) to SPM multiple regressors

Hi there! I’m interested in using the covariates put out during fmriprep as a multiple regressor in SPM. SPM requires the multiple regressor to be in a specific format (.txt or .mat). From the SPM12 manual: You will first need to create a *.mat file containing a matrix R or a *.txt file containing the covariates. Each column of R will contain a different covariate. Unless the covariates names are given in a cell array called ’names’ in the MAT-file containing variable R, the covariates will be named R1, R2, R3, …etc.

Has anyone translated the covariate txt output from fmriprep to this SPM multiple covariate format? Would love insight!

I write a script to loop through my subjects to pull out regressors of interest from the XXXXXXX_desc-confounds_regressors.tsv output from fmriprep and write it into a .txt file for SPM. I’m not sure if that’s what your trying to do?

For example, to pull the data from columns 1, 3 and 5 of the .tsv file I use something like:

awk ‘{if(NR>1)print $1, $3, $5}’ /path/to/your/fmriprep/output/file/“your_data_name”_desc-confounds_regressors.tsv > /path/to/save/your/file/“my_regressors”.txt

Hi Tim. When I do this I’m getting the following error in my terminal:

syntax error near unexpected token `(’

I"m running:
awk ‘{if(NR>1)print $1, $3, $5}’ /Users/…/sub-RC1_ses-01_task-semanticmatching_run-01_desc-confounds_regressors.tsv > /Users/…/RC1_regressors.txt

Sorry, I’m no expert in this. I happened to find something that worked.
Are you typing this as command line or running as a script?
The only similar thing I can find says you need to use #!/bin/bash and not #!/bin/sh if you’re running a script.

I made a lil’ bash script to get specific columns from the fmriprep output. check it out here: https://gist.github.com/faskowit/29f79d3149469779cbff71eebc49340a

Hi Brielle,

I’m using Python to extract information from the confounds file that I can then use for further analyses in SPM. You can find the sript here:

MANAGED BY INCF