fNIRS data and mne_bids

  • MNE version: 1.2
  • operating system: Windows 10
  • mne-bids 0.11
  • mne-nirs 0.4.0

Hi, I have been trying to follow the group level anaysis with my fnirs data.
I have come across several issues, firstly the HITACHI raw is not readable by mne_bids.write_raw_bids also when changing the data to a FIF file issues occur "“channel type not found” and even after setting the channel type by raw.set_channel_types() I still get the same error. When I tried to convert my raw data to a SNIRF file I get a ValueError: No electrophysiological data found.
I don’t really know what’s the Issue here.

I did the following:

def write_bids(participant_list):
    root = "C:/Users/rebec/fNIRS-project/Data/BIDS"
    for part in participant_list:
        raw_snirf_path = 'C:/Users/rebec/fNIRS-project/Data/SNIRF/S'+ str(part) +"raw_coregistered_to_fsaverage.snirf"
        raw_fif_path = 'C:/Users/rebec/fNIRS-project/Data/FIF/S'+str(part)+'_raw.fif'
        raw_obj = mne.io.read_raw_snirf(raw_snirf_path)
        #raw_obj = mne.io.read_raw_fif(raw_fif_path)
        bids_path = BIDSPath(subject=str(part),task='intelligible speech',
                     root=root)
        mne_bids.write_raw_bids(raw_obj,bids_path,overwrite=True)
        
list_par = ['01','04','05','07','08','09',11,12,16,17,18,30,31,32,33,34,35,36,37] #excluded 06,15
write_bids(list_par)
root = "C:/Users/rebec/fNIRS-project/Data/BIDS"
subjects = get_entity_vals(root,'subject')
print(subjects) # gives: ['01', '04', '05', '07', '08', '09', '11', '12', '16', '17', '18', '30', '31', '32', '33', '34', '35', '36', '37']  

however when I try to go further in the tutorial…



def individual_analysis(bids_path, ID):

    raw_intensity = read_raw_bids(bids_path=bids_path, verbose=False)
    # Delete annotation labeled 15, as these just signify the start and end of experiment.
    # raw_intensity.annotations.delete(raw_intensity.annotations.description == '15.0')
    # sanitize event names
    raw_intensity.data_load()
    #raw_intensity.annotations.description[:] = [
    #    d.replace('/', '_') for d in raw_intensity.annotations.description]

    # Convert signal to haemoglobin and resample
    raw_od = optical_density(raw_intensity)
    raw_haemo = beer_lambert_law(raw_od, ppf=0.1)
    raw_haemo.resample(0.3)


    # Create a design matrix
    design_matrix = make_first_level_design_matrix(raw_haemo, stim_dur=20.0)

    # Run GLM
    glm_est = run_glm(raw_haemo, design_matrix)

    # Extract channel metrics
    cha = glm_est.to_dataframe()

    # Compute region of interest results from channel data

    # Define left vs right tapping contrast
    contrast_matrix = np.eye(design_matrix.shape[1])
    basic_conts = dict([(column, contrast_matrix[i])
                        for i, column in enumerate(design_matrix.columns)])
    contrast_4 = basic_conts['Rot-TS'] - basic_conts['Rot-Blesser']

    # Compute defined contrast
    contrast = glm_est.compute_contrast(contrast_4)
    con = contrast.to_dataframe()

    # Add the participant ID to the dataframes
    roi["ID"] = cha["ID"] = con["ID"] = ID

    # Convert to uM for nicer plotting below.
    cha["theta"] = [t * 1.e6 for t in cha["theta"]]
    roi["theta"] = [t * 1.e6 for t in roi["theta"]]
    con["effect"] = [t * 1.e6 for t in con["effect"]]

    return raw_haemo, roi, cha, con

df_roi = pd.DataFrame()  # To store region of interest results
df_cha = pd.DataFrame()  # To store channel level results
df_con = pd.DataFrame()  # To store channel level contrast results



for sub in subjects:  # Loop from first to fifth subject
    bids_path = BIDSPath(subject=sub,task='intelligible speech', root=root)
    
    
    # Analyse data and return both ROI and channel results
    raw_haemo, roi, channel, con = individual_analysis(bids_path, sub)
    
    # Append individual results to all participants
    df_roi = pd.concat([df_roi, roi], ignore_index=True)
    df_cha = pd.concat([df_cha, channel], ignore_index=True)
    df_con = pd.concat([df_con, con], ignore_index=True)

grp_results = df_roi.query("Condition in ['Control', 'Rot-TS', 'Rot-Blesser']")
grp_results = grp_results.query("Chroma in ['hbo']")

sns.catplot(x="Condition", y="theta", col="ID", hue="ROI", data=grp_results, col_wrap=5, ci=None, palette="muted", height=4, s=10)

I get a Traceback:

Traceback (most recent call last):

  File ~\fNIRS-project\untitled4.py:118
    raw_haemo, roi, channel, con = individual_analysis(bids_path, sub)

  File ~\fNIRS-project\untitled4.py:62 in individual_analysis
    raw_intensity = read_raw_bids(bids_path=bids_path, verbose=False)

  File <decorator-gen-615>:10 in read_raw_bids

  File ~\Anaconda3\envs\old_mne\lib\site-packages\mne_bids\read.py:690 in read_raw_bids
    datatype = _infer_datatype(root=bids_root, sub=sub, ses=ses)

  File ~\Anaconda3\envs\old_mne\lib\site-packages\mne_bids\path.py:1849 in _infer_datatype
    raise ValueError('No electrophysiological data found.')

ValueError: No electrophysiological data found.

Hope you can help me and thank you in advance for your time and effort,
Best,
Rebecka