NIRs data with varying trial length

Hello,
I am trying to use MNE-NIRS for my experiment which has two blocks of trials. Each block has trials of varying length because the participant must push a button to respond when they have solved the problem in the trial.

After answering the question, a fixation cross is presented for a variable amount of time (jittered). In the tutorials, it seems that all trials must have the same duration, and mine do not. I’ve seen some threads on similar issues on this forum, but I wanted to check and make sure that it seems MNE-NIRS doesn’t support this?

Thank you!

MNE-Python (and by extension MNE-NIRS) does not support variable-length epochs. This is a fundamental limitation of how we’ve chosen to represent epoched data (as NumPy arrays, which makes many computations much faster than if we stored epochs in, e.g., a list instead of an array).

That doesn’t mean it’s impossible: you can manually do this by, e.g., repeatedly copying and cropping a continuous Raw file, and appending each “epoch” to a list. A lot of the speed and convenience of the Epochs data structure will be unavailable, but depending on how complicated your analysis plan is, it might be a OK. You can also consider a subsequent step of padding the beginning and/or end of all the shorter trials with np.nan and then stacking the padded trials into a NumPy array; you can even then use mne.EpochsArray() to get it back into an Epochs data structure.

cross-references to similar questions: