Note
Go to the end to download the full example code. or to run this example in your browser via Binder
Migrating from nirs-toolbox to MNE#
This tutorial will demonstrate how to do convert a nirs-toolbox script to MNE and highlight differences and common issues you may encounter.
nirs-toolbox is a MATLAB based software analysis package. huppertt/nirs-toolbox
Basic nirs-toolbox script to be reproduced in MNE#
Below is a common example analysis performed in nirs-toolbox. The NIRx data is loaded and trigger names are modified. Then the intensity signal is convert to optical density then converted to haemoglobin concentration. After which, a GLM analysis is performed with iteratively reweighted autoregressive noise model. Finally a mixed effects model is run on the group level dat.
# Load data
raw = nirs.io.loadDirectory()
# Preprocess data
pipeline_preprocess = nirs.modules.RenameStims(pipeline_preprocess);
pipeline_preprocess.listOfChanges = {
'channel_1', 'Control';
'channel_2', 'Condition1';
'channel_3', 'Condition2'};
pipeline_preprocess = nirs.modules.DiscardStims(pipeline_preprocess);
raw = pipeline_preprocess.run(raw);
# Analyse data
pipeline = nirs.modules.Resample(); pipeline.Fs = 3;
pipeline = nirs.modules.OpticalDensity(pipeline);
pipeline = nirs.modules.BeerLambertLaw(pipeline);
pipeline = nirs.modules.AR_IRLS(pipeline);
subj_stats = pipeline.run(raw);
# Group level analysis
pipeline = nirs.modules.MixedEffects();
pipeline.formula = 'beta ~ -1 + cond + (1|Name)';
group_stats = pipeline.run(subj_stats);
MNE equivalent of nirs-toolbox script#
The MNE equivalent of this analysis is well described in the group level tutorial.
So this page will focus on the differences between the two approaches.
Differences between toolboxes#
MNE does not have iterative reweighting of the noise estimate in the GLM analysis.
Further analysis details#
If there is useful processing in the nirs-toolbox that is not available in MNE please let us know by creating an issue at mne-tools/mne-nirs#issues
Total running time of the script: (0 minutes 0.000 seconds)
Estimated memory usage: 431 MB