FIR model basis function with Nipype

Hi everyone,

I’m new to the imaging and Nipype world and I’m encountering some problems while trying to do the level 1 stats. Would really appreciate any helps! Thanks in advance!

I’m currently trying to run a FIR model on my data, which has been preprocessed using fMRIprep and smoothed and highpassed using Nipype. I’m using fsl.level1Design to generate my FEAT models. My question is, how should I specify that I do not want any convolution to my design matrix when specifying the basis function?

The help page for fsl.level1Design says the following:
bases: (a dictionary with keys which are ‘dgamma’ and with values
which are a dictionary with keys which are ‘derivs’ and with values
which are a boolean or a dictionary with keys which are ‘gamma’ and
with values which are a dictionary with keys which are ‘derivs’ or
‘gammasigma’ or ‘gammadelay’ and with values which are any value or
a dictionary with keys which are ‘custom’ and with values which are
a dictionary with keys which are ‘bfcustompath’ and with values
which are a unicode string or a dictionary with keys which are
‘none’ and with values which are a dictionary with keys which are
any value and with values which are any value or a dictionary with
keys which are ‘none’ and with values which are None)
name of basis function and options e.g., {‘dgamma’: {‘derivs’:
True}}
I tried to input {‘none’:None}, which is last type of input mentioned above but got a TypeError: ‘NoneType’ object is not iterable. To be sure that the error i got was caused by my basis function input, I changed the input to {‘dgamma’: {‘derivs’:False}} and the workflow started to work. However, I do not want to have any hrf convolved with my design matrix.

Just to sum up, the question is how should i specify the basis function, which should be impulse only, for a FIR model using fsl.level1Design? Thanks in advance!

2 Likes

Well, I’m still not crystal clear on this question, but I did figure out a work around. First I want to be clear that there is no need to do FIR on Nipype or even through any neuroimaging software like FSL as clarified in Cole et al., 2019 (https://github.com/ColeLab/TaskFCRemoveMeanActivity). Simply running two GLMs, with the first one regressing out the nuisance and then use the residual for the second FIR GLM. I sticked with Nipype mostly b/c I got paranoid.

In level1_design, if you set the basis function to be {‘none’:{None:None}} it would do the work. Meaning in the fsf files it writes, it would assume your input is a 1 column format design matrix and the convolution is ‘None’. A problem with this is that you need to input a list of 1 column format design matrix, ideally. But in the SpecifyModel() node, I just cannot figure out how to do this (maybe I’m just dumb). In that node, there are 3 ways to specify your design matrix, using 1) subject_info 2) event_files and 3) bids_event_files input fields. These 3 are mutual exclusive. Based on my understanding, subject_info input field takes in the normal 3 columns format design, while the event_files input field takes in a list of 1 column format design. But I keep getting this error: ValueError: not enough values to unpack (expected 2, got 1) I feel like it must be something dumb that I did, but i just cannot figure out. If anyone has any insight, please please leave a comment. I’ll really appreciate!

Anyway, the procedure mentioned above should be the ‘right’ way to do. But there are work arounds given that i cannot make the ‘right’ way to work. The way I did it was that in SpecifyModel() node, I used the ‘subject_info’ input field and input a trash EV (0,0,0). Then I input all of my FIR one column format design matrices to the fields ‘regressor_names’ and ‘regressors’. Would look something like the following:

subject_info = Bunch(
            conditions=['trash_ev'],
            onsets=[[0]],
            durations=[[0]],
            amplitudes=[[0]],
            regressor_names=[FIR regressor names],
            regressors=[The 1 column matrices for each FIR regressor]
            tmod=None,
            pmod=None)

The rationale is that subject_info treats these two fields as confound variables, automatically creating EVs for these in the fsf file with 1 column format design and ‘None’ convolution. As for the level1Design node, I used basis function of {‘dgamma’: {‘derivs’: False}}. But it should not matter b/c we used a trash EV. I’m pretty sure in this way, you can still apply highpass filtering to your fir design matrix (check the fsf file that Nipype generates, but i’m positive that hp was applied to ‘confounds’). But might lose the chance to do prewhitening. Another work around is that if you really don’t care about highpass filter. Just go use the fsl_glm interface.
Again, these are just workarounds… if anyone have insight on how to make the ‘right’ way work like I described before, please leave a comments. Otherwise, hope the workarounds make sense.

1 Like