Simple first-level GLM in Python

I’m looking for something like FSL’s GLM (fsl_glm) function from one of the many neuroimaging python packages. Basically I want to input one 4D NIfTI file, and one timeseries (be it as a numpy array or from a file) and get a 3D NIfTI with t-statistic values back.

  • Nilearn’s permuted_ols sounds like it might be able to do the job, but I find the documentation and examples very unclear. It sounds like it is very specifically written for group analysis purposes? Am I misunderstanding anything?
  • Nipy has an entire page dedicated to this, but no function I could find for actually running the analysis.
  • Nistats is still pre-release. Is there any stable function with a stable API for this already?
1 Like

Nilearn: yes, the example is quite specifi and restricted to second-level. Probably does not fit your needs
Nipy: deprecated
Nistats: is the best candidate (documentation is OK, pur Python code reasonable dependences etc.). The reason whuy it’s not released yet is that we’ve been hesitating to merge it into Nilearn. I think that the API is pretty stable though.

1 Like

Good to know that the API is stable. Ideally, though, I would wait for a pre-release at least.

I think this issue about merging into nilearn was discussed before in the nistats issues. Nilearn is already growing too big for its stated purpose. It’s doing so many (great) things which are entirely unrelated to machine learning. If anything I believe nilearn needs splitting up rather than having more stuff merged into it. Ideally bits of nilearn would be moving to nistats…

Is there an easy way to create a single trial GLM with nistats?
I have preprocessed my dataset with fMRIprep and would now like to use nistats because I have been told it works well in combination with data in the BIDS format. However, the design matrix creation for single trial design is quite confusing to me and I was wondering whether someone else had solved it already?

Hi @Sebastian. Have you looked at @jdkent’s NiBetaSeries? I think that might be what you mean by “single trial GLM”.