Various stuff about neuroimaging and statistical analysis...
I realised I like to help people. Or at least, I like writing code-notebooks that try to explain concepts in statistics and neuroimaging. This is possibly because I like the feeling of authority. But if you can live with that, read on...
Notebooks
Some of below are Jupyter (python) notebooks, some are R Markdown and some are Matlab Livescripts (if anyone manages to create alternative versions of any the notebooks below, eg convert Matlab ones to R/Python, that would be fantastic - please let me know! Likewise, let me know if you find any bugs/errors...)
- Statistics for Neuroimaging: https://github.com/RikHenson/Stats4Imaging
- A simulation-based introduction to the basic statistical concepts used in univariate fMRI and M/EEG analyses
- Above contains Jupyter, Matlab Livescript and (non-interactive) HTML versions (no Rmd yet)
- Topics covered: Sampling theory, Central Limit Theorem, Randomisation testing, Null hypothesis testing (error rate and power), Bayes Factors, Smoothing, Height/Cluster/Mass Family-wise Error rate, False Discovery Rate, General Linear Model, T-tests, ANOVAs, F-tests, Error Nonsphericity, Error Partitioning, Multiple Regression, Timeseries analysis (HRF basis functions, filtering and autocorrelation), Linear Mixed Effects models.
- Efficient fMRI experiments: https://github.com/RikHenson/fMRIefficiency
- How to design an fMRI experiment, as a function of trial modelling, HRF modelling, trial interval and trial order, that is efficient (sensitive) to a specific contrast (hypothesis)?
- Above contains Matlab Livescript and HTML (no Python or Rmd yet)
- Topics covered: Effects of SOA, Signal variance, Power Spectra, Filtering, Effective HRF, Detection Power vs Estimation Efficiency, Effects of Trial Order, Null Events, Correlated Predictors, Working Memory trials, State/Item effects, Single-trial estimation (LSA), Regularised LSA (eg for Beta-Series Regression), LSS, effects of Trial:Scan variability, effects of Spatial Covariance of Trial/Scan variability (eg for MVPA), General Advice, Common Questions
- How to relate Age, Brain and Cognition (ABC): https://github.com/RikHenson/AgeBrainCognition
- How should you model the relationship between 3 or more variables?
- Above contains Rmd and HTML (no Python or Matlab yet)
- Topics covered: Multiple Regression versus Path Models, Mediation, Moderation, Structural Equation Models, Measurement Invariance, Longitudinal designs, Mixed Effects models, Practice effects, Attrition, Cross-Lagged Panel Models, Latent Curve Models, Parallel Process Models.
- Statistical Power for Interactions: https://github.com/RikHenson/Power4Interactions
- Is it true that interactions are always harder to detect than main effects? Not always...
- Above contains Rmd and HTML (no Python or Matlab yet)
- Topics covered: Experimental vs Field Designs, Multiple Regression, Correlated Predictors, Range effects, Measurement noise, Sequential Orthogonalisation (Type II vs Type III sum of squares)
- Complete Python-based course for fMRI analysis: https://github.com/RikHenson/PythonNeuroimagingCourse
- A 3-day course (can be given on request) on how to conduct open, transparent and reproducible fMRI analyses (uses the OpenNeuro Wakeman & Henson dataset)
- Above contains Python Jupyter notebooks (built on BIDS apps, Nilearn, dockers etc).
- Topics covered: Statistics for Neuroimaging (see first GitHub above), Data Organisation, Image manipulation, Quality Control, Preprocessing (fMRIPrep), Single-subject analysis, Group analysis, ROI analysis, MVPA, Functional Connectivity, Network analysis
- (Plans to extend to M/EEG in future)
Other stuff
- Comparing a single patient vs a Group (in SPM): PDF
- WIKI on How to design efficient fMRI experiments
- Matlab functions for demonstrating multi-dimensional connectivity https://github.com/RikHenson/MultivarCon
SPM-related functions
-
-
- PDF on ANOVAs in SPM
- Matlab function for generic GLM: https://github.com/MRC-CBU/riksneurotools/blob/master/GLM/glm.m
- Matlab function for N-way repeated measures ANOVAs: https://github.com/MRC-CBU/riksneurotools/blob/master/GLM/repanova.m
- Matlab script for simulating pooled versus partitioned errors: https://github.com/MRC-CBU/riksneurotools/blob/master/GLM/check_pooled_error.m
- Comprehensive walk-through on M/EEG source reconstruction in SPM12: paper available here: PDF; code and data available here: https://figshare.com/collections/Multimodal_integration_of_M_EEG_and_f_MRI_data_in_SPM12/4367120
- Matlab scripts for demonstration of DCM for fMRI (not well documented): https://github.com/RikHenson/DCMdemo
- Matlab function for N-way mixed ANOVAs in SPM: https://github.com/MRC-CBU/riksneurotools/blob/master/SPM/batch_spm_anova.m
- Extract data for multiple ROIs from multiple datafiles: https://github.com/MRC-CBU/riksneurotools/blob/master/Util/roi_extract.m
- SPM Course Slides from 2008
- Source Localisation of EEG and MEG data in SPM5: Manual and Data (~80MB)
- PDF for single-subject (1st-level) event-related fMRI analysis in SPM Manual and Data
- PDF for group-based (2nd-level) event-related fMRI analysis in SPM Manual and Data
- Reading FIF MEG files into SPM5: click here for more info
- Matlab function for calculating NxN functional connectivity between all pairs of fMRI timeseries for N ROIs: https://github.com/MRC-CBU/riksneurotools/blob/master/Conn/rsfMRI_GLM.m
- Matlab function for detecting artefacts in EEG/MEG data using ICA and temporal correlations with EOG/ECG and/or spatial correlations with standard template topographies: https://github.com/MRC-CBU/riksneurotools/tree/master/MEEG
- Matlab function for computing single-trial fMRI estimates https://github.com/MRC-CBU/riksneurotools/blob/master/GLM/fMRI_multitrial_GLMs.m using LSA or LSS (see Abdulrahman & Henson (2016)).
-
Use at own risk!
MRC Cognition and Brain Sciences Unit

