How to import fNIRS data from a local dataset?

Hi, I’m new using MNE resources and am trying to import fNIRS data from a dataset previously downloaded from a repository. I looked at some tutorials from the MNE site but I’m still having problems because the dataset includes several folders and files in TSV, SNIRF and JSON formats.

MNE Version: 1.6.1
Operating system: Windows 11

Brief description:
As I said, I downloaded an fNIRS dataset that contains several folders and inside the folders there are files in TAV, JSON and SNIRF formats.

In the “sub…” folders, the files are like this:

I deduce that each “SUB” folder belongs to each subject’s data.

Inside the “stimuli” folder there are other folders and inside there are MATLAB files in .m format
image

But I’m not sure if those files are necessary.

In summary, I would like to import the data to apply some preprocessing methods for a school project, but I don’t know if I need to work on one file at a time or can use the full set from a “sub” folder.
Again, I’m new to this and basically need help understanding how to import and work with this type of data.
I hope someone can support me and thanks for the interest.
Note: I already installed the mne-nirs module. The dataset was obtained from: Automatic and non-automatic finger and leg movements measured with functional near-infrared spectroscopy (fNIRS)

Best regards.

Hello, this looks like data organized in the BIDS format. You must use MNE-BIDS to read the data.

Best wishes,
Richard

1 Like

Thank you very much for the support.

I have another question. When I import the raw data through MNE-BIDS, I have a problem with the “scanned” file in TSV format. When I run the code it returns this:

Traceback (most recent call last):
File “c:\Users\rodri\Documents\Doctorado\Procesamiento de Bioseñales\Proyecto Bio\prueba_fnirs.py”, line 22, in
raw = read_raw_bids(bids_path=bids_path, verbose=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “”, line 10, in read_raw_bids
File “C:\Users\rodri\anaconda3\Lib\site-packages\mne_bids\read.py”, line 901, in read_raw_bids
raw = _handle_scans_reading(scans_fname, raw, bids_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\rodri\anaconda3\Lib\site-packages\mne_bids\read.py”, line 334, in _handle_scans_reading
acq_time = datetime.strptime(acq_time, “%Y-%m-%dT%H:%M:%S.%fZ”)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\rodri\anaconda3\Lib_strptime.py”, line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\rodri\anaconda3\Lib_strptime.py”, line 349, in _strptime
raise ValueError(“time data %r does not match format %r” %
ValueError: time data ‘1920-01-01T00:38:02.080’ does not match format ‘%Y-%m-%dT%H:%M:%S.%fZ’

but inside the file, the format is correct:

filename acq_time
nirs/sub-06_task-fingerauto_nirs.snirf 1920-01-01T00:38:02.080
nirs/sub-06_task-fingerauto_nirs.snirf 1920-01-01T00:38:02.080
nirs/sub-06_task-fingerauto_nirs.snirf 1920-01-01T00:38:02.080
nirs/sub-06_task-fingerauto_nirs.snirf 1920-01-01T00:38:02.080
nirs/sub-06_task-fingerauto_nirs.snirf 1920-01-01T00:38:02.080

How could I solve it? Could I not use this file or is it necessary for fNIRS data analysis?

Best regards.

Hello, this is a bug in MNE-BIDS. At first I thought the acq_time in your file are invalid, but the BIDS specification states very clearly that this is not the case:

Date time information MUST be expressed in the following format YYYY-MM-DDThh:mm:ss[.000000][Z] (year, month, day, hour (24h), minute, second, optional fractional seconds, and optional UTC time indicator). This is almost equivalent to the RFC3339 “date-time” format, with the exception that UTC indicator Z is optional and non-zero UTC offsets are not indicated. If Z is not indicated, time zone is always assumed to be the local time of the dataset viewer. No specific precision is required for fractional seconds, but the precision SHOULD be consistent across the dataset. For example 2009-06-15T13:45:30.

So a trailing Z is optional, but MNE-BIDS is expecting it in your case, and crashing because it’s not there.

What you can do as a quick workaround for now is simply append a Z to all acq_time values in your scans.tsv files. This will cause the acquisition time to be reported incorrectly, though. Ultimately, this is something that needs to be fixed in MNE-BIDS.

Best wishes,
Richard

cc @sappelhoff

1 Like

I am preparing a fix here: account for optional Z in time strs by sappelhoff · Pull Request #1240 · mne-tools/mne-bids · GitHub

2 Likes

This problem has been resolved and will be fixed in MNE-BIDS 0.15.

Best wishes,
Richard

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.