FIR in nipype - is there a single good, well-documented way?

90 views
Skip to first unread message

Ben

unread,
Aug 21, 2013, 3:33:10 PM8/21/13
to nipy...@googlegroups.com
Hi folks.

I've been trying to implement a workflow that does a simple FIR analysis using FitGLM, but have been running into a lot of issues.

There does not seem to be any documentation on how to specify which TRs to include in the design matrix, or later in your contrast estimate. Obviously changing the onsets and durations of the events I provide in subject_info (of SpecifySPMModel) has an effect - but it is unclear how to, say, include 10 TRs per event in the design matrix, then only use TRs 2-6 when I estimate the contrast.

Is there a combination of interfaces that make this more or less straightforward? Failing that, is there a more hacky way to get it done? 

Is there documentation of even a single successful FIR analysis workflow using nipype?

Anyone who has gotten this to work, I'd love to get in touch with you to ask a few questions. I'll be happy to share my code in a gist. Heck, I'll even buy you a coffee if it works out.

Thanks for your time.

Ben

Eveline Geiser

unread,
Aug 21, 2013, 4:00:37 PM8/21/13
to nipy...@googlegroups.com, bena...@gmail.com
Hi Ben

As for a successful FIR analysisi workflow:
# Node: SpecifyModel - Generate SPM-specific design information
modelspec = engine.Node(interface=model.SpecifySPMModel(), name=
"modelspec")
modelspec.inputs.concatenate_runs = False
modelspec.inputs.input_units = 'secs'
modelspec.inputs.output_units = 'secs'
modelspec.inputs.time_repetition = 2.
modelspec.inputs.high_pass_filter_cutoff = 128

# Node: Level1Design - Generate a first level SPM.mat file for analysis
level1design = engine.Node(interface=spm.Level1Design(), name=
"level1design")
level1design.inputs.bases = {'fir':{'derivs': [0,0]}}
level1design.inputs.timing_units = 'secs'
level1design.inputs.interscan_interval = modelspec.inputs.time_repetition
level1design.inputs.model_serial_correlations = 'AR(1)'


Can you be more specific what you mean by including 10 TRs per event and
only using 206 in the contrast? is 10 TRs your trial duration?
You could specify a covariate comprising onsets of the trial and a
second one comprising TRs 2-6 for every condition for example.

Working with a design-matrix comprising information in seconds instead
of TRs might already solve the problems you run into...

Let me know if that helps or if you have more questions

Eveline
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "NiPy Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to nipy-user+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


--
---------------------
Dr. Eveline Geiser

Massachusetts Institute of Technology
McGovern Institute for Brain Research

Phone: + 617-324-6371
e-mail: ege...@mit.edu

http://web.mit.edu/gabrieli-lab

Ben

unread,
Aug 22, 2013, 2:35:20 PM8/22/13
to nipy...@googlegroups.com, bena...@gmail.com
Thanks for getting back to me!

Starting to make some sense. But say I have a TR of 2.5, and I want to include 10 TR, wouldn't I want something more like:

level1design.inputs.bases = {'fir':{'length': 25, 'order': 10}} 

It looks like 'derivs' is only for use with hrf. The above corresponds with what I'd do in the "Specify 1st-level" UI of SPM. I'd sed Basis Functions to Finite Impulse Response, then specify the window length and order as above. Length is in seconds, order is the number of TRs that occur over 'length' seconds.

I think I have this step down. Now, as for contrast estimation here's what I'd do in the GUI:

Batch
Top Menu -> SPM -> Stats -> Contrast Manager
Specify my SPM.mat
Add a new T-Contrast Contrast Session
Define my T contrast vector.

It's that last step, defining the T contrast vector, wherein I would normally write a zero for every TR except the ones I'm interested in. So, in the example below, I would find the first onset of each event A, move one index forward, then mark the next five indices 1.

So I guess what I'm not seeing is a way to define the T contrast vector. Perhaps it's not implemented yet?

Thanks again for your time!

Ben
Reply all
Reply to author
Forward
0 new messages