fNIRS GLM BIDS App error after read_raw_bids() RuntimeWarning

Hello :slight_smile:

When using Rob Luke’s BIDS GLM app for fNIRS data, I ran into an error for more than half of my subjects, which is a ValueError stating that " support is only available for experiments where all durations are the same ". But in fact, they are the same (8s each). I’ve looked into the events.tsv and channels.tsv and they look no different to the other subjects - except for exact onsets and samples of course. For the same sub, there’s sometimes even one session working while the other is producing the error.

What those subjects all have in common is the read_raw_bids() function throwing the following warning after reading events:

:1: RuntimeWarning: Limited 1 annotation(s) that were expanding outside the data range.

As I am fairly new to mne-bids, my question now is: Can I somehow gain insight into what causes this warning? And what is my “data range” exactly? I’ve already looked for some mne.io.Raw methods to use, but that led me nowhere useful so far and now I’m a little stuck. Where do I have to start digging? I’d appreciate any help!

Below are 1) my specs, 2) execution of the GLM app + error message, as well as 3) how the events.tsv file looks like.



  • MNE version: 1.0.2
  • MNE-bids version: 0.10
  • operating system: Ubuntu 20.04

GLM app execution:

{'ApplicationName': 'fNIRS-Apps: GLM Pipeline',
 'ApplicationVersion': 'v0.3.4',
 'Arguments': {'export_drifts': False,
               'export_shorts': False,
               'input_datasets': '/bids_dataset',
               'output_location': '/bids_dataset/derivatives/fnirs-apps-glm-pipeline',
               'sample_rate': 0.6,
               'session_label': ['01'],
               'short_regression': True,
               'subject_label': ['03'],
               'task_label': None},
 'ExecutionStart': '2022-04-25T10:01:23.527725'}

Extracting subject metadata.
    Subject data provided as input argument.
        Subjects: ['03']
Extracting session metadata.
    Session data provided as input argument.
        Sessions: ['01']
Extracting tasks metadata.
    Session data will be extracted from data.
        Tasks: ['GoNoGo']
Processing: sub-03/ses-01/task-GoNoGo
Loading /bids_dataset/sub-03/ses-01/nirs/sub-03_ses-01_task-GoNoGo_nirs.snirf
Reading events from /bids_dataset/sub-03/ses-01/nirs/sub-03_ses-01_task-GoNoGo_events.tsv.
/run.py:156: RuntimeWarning: Limited 1 annotation(s) that were expanding outside the data range.
  raw_intensity = read_raw_bids(bids_path=bids_path, verbose=True)
Reading channel info from /bids_dataset/sub-03/ses-01/nirs/sub-03_ses-01_task-GoNoGo_channels.tsv.
Not fully anonymizing info - keeping his_id, sex, and hand info
Reading 0 ... 4247  =      0.000 ...   521.956 secs...
    Resampling to 0.6 Hz
Traceback (most recent call last):
  File "/run.py", line 234, in <module>
    raw, cha, roi = individual_analysis(b_path, sub,
  File "/run.py", line 171, in individual_analysis
    raise ValueError("Support is only available for experiments where "
ValueError: Support is only available for experiments where all durations are the same. See https://github.com/rob-luke/fnirs-apps-glm-pipeline/issues/1

How the respective events.tsv looks like:

onset duration trial_type value sample
88.24220000000001 8.0 Go 1 718
96.23070000000001 8.0 Go 1 783
515.6884 8.0 NoGo 2 4196

Hello @dmhohmann, I’ve never used this app before, but I’m tagging @rob-luke, who I believe created this tool. Let’s hope he’ll have time to respond and give you some advice!

Fingers crossed :crossed_fingers:

Best wishes,


Short update (or solution?):

I just found that running the following lines (adapted from fnirsapp_glm.py, L154) …

srate = 0.6
raw_od = optical_density(raw)
raw_haemo = beer_lambert_law(raw_od)
raw_haemo.resample(srate, verbose=True)

… returns to me the following array:

array([8.    , 8.    , 8.    , 8.    , 8.    , 8.    , 8.    , 8.    ,
       8.    , 8.    , 8.    , 8.    , 8.    , 8.    , 8.    , 8.    ,
       8.    , 8.    , 8.    , 8.    , 8.    , 8.    , 8.    , 8.    ,
       8.    , 8.    , 8.    , 8.    , 8.    , 8.    , 8.    , 8.    ,
       8.    , 8.    , 8.    , 8.    , 8.    , 8.    , 8.    , 8.    ,
       8.    , 8.    , 8.    , 8.    , 8.    , 8.    , 8.    , 6.3908])

Could that just be a measurement error from stopping the experiment too early and cutting off the last stimulus? Is it that simple? It would make sense with our set up.

Hi @dmhohmann

You have solved your own problem :smile:

This is a bit of an opinionated app/script, and that’s why its stored on my personal repo rather than under the MNE organisation. But I am still pleased to provide support here and appreciate your feedback.

As the script is opinionated it assumes that the event durations of equal length (actually I have a reminder for myself to make it more generic at Support for experiments with different stimulus durations per condition · Issue #1 · rob-luke/fnirs-apps-glm-pipeline · GitHub). But until I add that feature, all durations must be the same.

So to fix this you can run your experiment for an extra 1.7 seconds to ensure you complete the experiment. Or alternatively, we could find a way to exclude the final trials. But I think its easier to run the experiment a few seconds longer. What do you think?

Hey @rob-luke

I have communicated the issue to my colleagues already. For now though, I prefer excluding the final trials, as I need to have some preliminary results and beautiful pictures (:speak_no_evil:) at hand by end of next week (my first congress :exploding_head:).

Isn’t it just as simple as deleting the last line in the events file? Or am I missing something?

The quickest (but slightly naughty) way would be to edit your raw data (make sure you have a backup) and delete the last trial. Is your raw data in NIRx format? If so, open the HDR file and delete the last marker entry, then regenerate the BIDS dataset. If not, then you will need to use a script rather than the fNIRS-App.
Hope this helps,