05. BIDS conversion for group studies

Here, we show how to do BIDS conversion for group studies. We will use the EEG Motor Movement/Imagery Dataset available on the PhysioBank database. We recommend that you go through the more basic BIDS conversion example before checking out this group conversion example: 02. Convert MNE sample data to BIDS format

# Authors: Mainak Jas <mainak.jas@telecom-paristech.fr>
#          Teon Brooks <teon.brooks@gmail.com>
#          Stefan Appelhoff <stefan.appelhoff@mailbox.org>
#
# License: BSD (3-clause)

Let us import mne_bids

import os.path as op

import mne
from mne.datasets import eegbci

from mne_bids import (write_raw_bids, BIDSPath,
                      get_anonymization_daysback, make_report,
                      print_dir_tree)

And fetch the data for several subjects and runs of a single task.

subject_ids = [1, 2]

# The run numbers in the eegbci are not consecutive ... we follow the online
# documentation to get the 1st, 2nd, and 3rd run of one of the the motor
# imagery task
runs = [
    4,   # This is run #1 of imagining to open/close left or right fist
    8,   # ... run #2
    12,  # ... run #3
]

# map the eegbci run numbers to the number of the run in the motor imagery task
run_map = dict(zip(runs, range(1, 4)))

for subject_id in subject_ids:
    eegbci.load_data(subject=subject_id, runs=runs, update_path=True)

# get path to MNE directory with the downloaded example data
mne_data_dir = mne.get_config('MNE_DATASETS_EEGBCI_PATH')
data_dir = op.join(mne_data_dir, 'MNE-eegbci-data')

Let us loop over the subjects and create BIDS-compatible folder

# Make a path where we can save the data to
bids_root = op.join(mne_data_dir, 'eegmmidb_bids_group_conversion')

# Get a list of the raw objects for this dataset to use their dates
# to determine the number of daysback to use to anonymize.
# While we're looping through the files, also generate the
# BIDS-compatible names that will be used to save the files in BIDS.
raw_list = list()
bids_list = list()
for subject_id in subject_ids:
    for run in runs:
        raw_fname = eegbci.load_data(subject=subject_id, runs=run)[0]
        raw = mne.io.read_raw_edf(raw_fname)
        raw.info['line_freq'] = 50  # specify power line frequency
        raw_list.append(raw)
        bids_path = BIDSPath(subject=f'{subject_id:03}',
                             session='01', task='MotorImagery',
                             run=f'{run_map[run]:02}',
                             root=bids_root)
        bids_list.append(bids_path)

daysback_min, daysback_max = get_anonymization_daysback(raw_list)

for raw, bids_path in zip(raw_list, bids_list):
    # By using the same anonymization `daysback` number we can
    # preserve the longitudinal structure of multiple sessions for a
    # single subject and the relation between subjects. Be sure to
    # change or delete this number before putting code online, you
    # wouldn't want to inadvertently de-anonymize your data.
    #
    # Note that we do not need to pass any events, as teh dataset is already
    # equipped witn annotations, which wll be converted to BIDS events
    # automatically.
    write_raw_bids(raw, bids_path,
                   anonymize=dict(daysback=daysback_min + 2117),
                   overwrite=True)

Out:

Extracting EDF parameters from /Users/hoechenberger/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S001/S001R04.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Extracting EDF parameters from /Users/hoechenberger/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S001/S001R08.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Extracting EDF parameters from /Users/hoechenberger/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S001/S001R12.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Extracting EDF parameters from /Users/hoechenberger/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S002/S002R04.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Extracting EDF parameters from /Users/hoechenberger/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S002/S002R08.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Extracting EDF parameters from /Users/hoechenberger/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S002/S002R12.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Extracting EDF parameters from /Users/hoechenberger/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S001/S001R04.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
/Users/hoechenberger/Development/mne-bids/mne_bids/write.py:1070: RuntimeWarning: Converting to BV for anonymization
  warn('Converting to BV for anonymization')

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/participants.tsv'...

participant_id  age     sex     hand
sub-001 n/a     n/a     n/a
sub-002 n/a     n/a     n/a

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/participants.json'...

{
    "participant_id": {
        "Description": "Unique participant identifier"
    },
    "age": {
        "Description": "Age of the participant at time of testing",
        "Units": "years"
    },
    "sex": {
        "Description": "Biological sex of the participant",
        "Levels": {
            "F": "female",
            "M": "male"
        }
    },
    "hand": {
        "Description": "Handedness of the participant",
        "Levels": {
            "R": "right",
            "L": "left",
            "A": "ambidextrous"
        }
    }
}

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/eeg/sub-001_ses-01_task-MotorImagery_run-01_events.tsv'...

onset   duration        trial_type      value   sample
0.0     0.0     T0      1       0
4.2     0.0     T2      3       672
8.3     0.0     T0      1       1328
12.5    0.0     T1      2       2000
16.6    0.0     T0      1       2656

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/dataset_description.json'...

{
    "Name": " ",
    "BIDSVersion": "1.4.0",
    "DatasetType": "raw",
    "Authors": [
        "Please cite MNE-BIDS in your publication before removing this (citations in README)"
    ]
}
Reading 0 ... 19999  =      0.000 ...   124.994 secs...

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/eeg/sub-001_ses-01_task-MotorImagery_run-01_eeg.json'...

{
    "TaskName": "MotorImagery",
    "Manufacturer": "n/a",
    "PowerLineFrequency": 50,
    "SamplingFrequency": 160.0,
    "SoftwareFilters": "n/a",
    "RecordingDuration": 124.99375,
    "RecordingType": "continuous",
    "EEGReference": "n/a",
    "EEGGround": "n/a",
    "EEGPlacementScheme": "n/a",
    "EEGChannelCount": 64,
    "EOGChannelCount": 0,
    "ECGChannelCount": 0,
    "EMGChannelCount": 0,
    "MiscChannelCount": 0,
    "TriggerChannelCount": 0
}

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/eeg/sub-001_ses-01_task-MotorImagery_run-01_channels.tsv'...

name    type    units   low_cutoff      high_cutoff     description     sampling_frequency      status  status_description
Fc5.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc3.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc1.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fcz.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc2.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
/Users/hoechenberger/Development/mne-bids/mne_bids/write.py:1149: RuntimeWarning: Converting data files to BrainVision format
  warn('Converting data files to BrainVision format')

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/sub-001_ses-01_scans.tsv'...

filename        acq_time
eeg/sub-001_ses-01_task-MotorImagery_run-01_eeg.vhdr    1919-03-16T16:15:00
eeg/sub-001_ses-01_task-MotorImagery_run-02_eeg.vhdr    1919-03-16T16:15:00
eeg/sub-001_ses-01_task-MotorImagery_run-03_eeg.vhdr    1919-03-16T16:15:00
Wrote /Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/sub-001_ses-01_scans.tsv entry with eeg/sub-001_ses-01_task-MotorImagery_run-01_eeg.vhdr.
Extracting EDF parameters from /Users/hoechenberger/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S001/S001R08.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
/Users/hoechenberger/Development/mne-bids/mne_bids/write.py:1070: RuntimeWarning: Converting to BV for anonymization
  warn('Converting to BV for anonymization')

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/participants.tsv'...

participant_id  age     sex     hand
sub-001 n/a     n/a     n/a
sub-002 n/a     n/a     n/a

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/participants.json'...

{
    "participant_id": {
        "Description": "Unique participant identifier"
    },
    "age": {
        "Description": "Age of the participant at time of testing",
        "Units": "years"
    },
    "sex": {
        "Description": "Biological sex of the participant",
        "Levels": {
            "F": "female",
            "M": "male"
        }
    },
    "hand": {
        "Description": "Handedness of the participant",
        "Levels": {
            "R": "right",
            "L": "left",
            "A": "ambidextrous"
        }
    }
}

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/eeg/sub-001_ses-01_task-MotorImagery_run-02_events.tsv'...

onset   duration        trial_type      value   sample
0.0     0.0     T0      1       0
4.2     0.0     T1      2       672
8.3     0.0     T0      1       1328
12.5    0.0     T2      3       2000
16.6    0.0     T0      1       2656

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/dataset_description.json'...

{
    "Name": " ",
    "BIDSVersion": "1.4.0",
    "DatasetType": "raw",
    "Authors": [
        "Please cite MNE-BIDS in your publication before removing this (citations in README)"
    ]
}
Reading 0 ... 19999  =      0.000 ...   124.994 secs...

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/eeg/sub-001_ses-01_task-MotorImagery_run-02_eeg.json'...

{
    "TaskName": "MotorImagery",
    "Manufacturer": "n/a",
    "PowerLineFrequency": 50,
    "SamplingFrequency": 160.0,
    "SoftwareFilters": "n/a",
    "RecordingDuration": 124.99375,
    "RecordingType": "continuous",
    "EEGReference": "n/a",
    "EEGGround": "n/a",
    "EEGPlacementScheme": "n/a",
    "EEGChannelCount": 64,
    "EOGChannelCount": 0,
    "ECGChannelCount": 0,
    "EMGChannelCount": 0,
    "MiscChannelCount": 0,
    "TriggerChannelCount": 0
}

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/eeg/sub-001_ses-01_task-MotorImagery_run-02_channels.tsv'...

name    type    units   low_cutoff      high_cutoff     description     sampling_frequency      status  status_description
Fc5.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc3.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc1.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fcz.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc2.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
/Users/hoechenberger/Development/mne-bids/mne_bids/write.py:1149: RuntimeWarning: Converting data files to BrainVision format
  warn('Converting data files to BrainVision format')

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/sub-001_ses-01_scans.tsv'...

filename        acq_time
eeg/sub-001_ses-01_task-MotorImagery_run-01_eeg.vhdr    1919-03-16T16:15:00
eeg/sub-001_ses-01_task-MotorImagery_run-02_eeg.vhdr    1919-03-16T16:15:00
eeg/sub-001_ses-01_task-MotorImagery_run-03_eeg.vhdr    1919-03-16T16:15:00
Wrote /Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/sub-001_ses-01_scans.tsv entry with eeg/sub-001_ses-01_task-MotorImagery_run-02_eeg.vhdr.
Extracting EDF parameters from /Users/hoechenberger/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S001/S001R12.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
/Users/hoechenberger/Development/mne-bids/mne_bids/write.py:1070: RuntimeWarning: Converting to BV for anonymization
  warn('Converting to BV for anonymization')

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/participants.tsv'...

participant_id  age     sex     hand
sub-001 n/a     n/a     n/a
sub-002 n/a     n/a     n/a

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/participants.json'...

{
    "participant_id": {
        "Description": "Unique participant identifier"
    },
    "age": {
        "Description": "Age of the participant at time of testing",
        "Units": "years"
    },
    "sex": {
        "Description": "Biological sex of the participant",
        "Levels": {
            "F": "female",
            "M": "male"
        }
    },
    "hand": {
        "Description": "Handedness of the participant",
        "Levels": {
            "R": "right",
            "L": "left",
            "A": "ambidextrous"
        }
    }
}

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/eeg/sub-001_ses-01_task-MotorImagery_run-03_events.tsv'...

onset   duration        trial_type      value   sample
0.0     0.0     T0      1       0
4.2     0.0     T2      3       672
8.3     0.0     T0      1       1328
12.5    0.0     T1      2       2000
16.6    0.0     T0      1       2656

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/dataset_description.json'...

{
    "Name": " ",
    "BIDSVersion": "1.4.0",
    "DatasetType": "raw",
    "Authors": [
        "Please cite MNE-BIDS in your publication before removing this (citations in README)"
    ]
}
Reading 0 ... 19999  =      0.000 ...   124.994 secs...

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/eeg/sub-001_ses-01_task-MotorImagery_run-03_eeg.json'...

{
    "TaskName": "MotorImagery",
    "Manufacturer": "n/a",
    "PowerLineFrequency": 50,
    "SamplingFrequency": 160.0,
    "SoftwareFilters": "n/a",
    "RecordingDuration": 124.99375,
    "RecordingType": "continuous",
    "EEGReference": "n/a",
    "EEGGround": "n/a",
    "EEGPlacementScheme": "n/a",
    "EEGChannelCount": 64,
    "EOGChannelCount": 0,
    "ECGChannelCount": 0,
    "EMGChannelCount": 0,
    "MiscChannelCount": 0,
    "TriggerChannelCount": 0
}

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/eeg/sub-001_ses-01_task-MotorImagery_run-03_channels.tsv'...

name    type    units   low_cutoff      high_cutoff     description     sampling_frequency      status  status_description
Fc5.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc3.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc1.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fcz.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc2.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
/Users/hoechenberger/Development/mne-bids/mne_bids/write.py:1149: RuntimeWarning: Converting data files to BrainVision format
  warn('Converting data files to BrainVision format')

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/sub-001_ses-01_scans.tsv'...

filename        acq_time
eeg/sub-001_ses-01_task-MotorImagery_run-01_eeg.vhdr    1919-03-16T16:15:00
eeg/sub-001_ses-01_task-MotorImagery_run-02_eeg.vhdr    1919-03-16T16:15:00
eeg/sub-001_ses-01_task-MotorImagery_run-03_eeg.vhdr    1919-03-16T16:15:00
Wrote /Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/sub-001_ses-01_scans.tsv entry with eeg/sub-001_ses-01_task-MotorImagery_run-03_eeg.vhdr.
Extracting EDF parameters from /Users/hoechenberger/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S002/S002R04.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
/Users/hoechenberger/Development/mne-bids/mne_bids/write.py:1070: RuntimeWarning: Converting to BV for anonymization
  warn('Converting to BV for anonymization')

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/participants.tsv'...

participant_id  age     sex     hand
sub-001 n/a     n/a     n/a
sub-002 n/a     n/a     n/a

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/participants.json'...

{
    "participant_id": {
        "Description": "Unique participant identifier"
    },
    "age": {
        "Description": "Age of the participant at time of testing",
        "Units": "years"
    },
    "sex": {
        "Description": "Biological sex of the participant",
        "Levels": {
            "F": "female",
            "M": "male"
        }
    },
    "hand": {
        "Description": "Handedness of the participant",
        "Levels": {
            "R": "right",
            "L": "left",
            "A": "ambidextrous"
        }
    }
}

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/eeg/sub-002_ses-01_task-MotorImagery_run-01_events.tsv'...

onset   duration        trial_type      value   sample
0.0     0.0     T0      1       0
4.1     0.0     T1      2       656
8.2     0.0     T0      1       1312
12.3    0.0     T2      3       1968
16.4    0.0     T0      1       2624

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/dataset_description.json'...

{
    "Name": " ",
    "BIDSVersion": "1.4.0",
    "DatasetType": "raw",
    "Authors": [
        "Please cite MNE-BIDS in your publication before removing this (citations in README)"
    ]
}
Reading 0 ... 19679  =      0.000 ...   122.994 secs...

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/eeg/sub-002_ses-01_task-MotorImagery_run-01_eeg.json'...

{
    "TaskName": "MotorImagery",
    "Manufacturer": "n/a",
    "PowerLineFrequency": 50,
    "SamplingFrequency": 160.0,
    "SoftwareFilters": "n/a",
    "RecordingDuration": 122.99375,
    "RecordingType": "continuous",
    "EEGReference": "n/a",
    "EEGGround": "n/a",
    "EEGPlacementScheme": "n/a",
    "EEGChannelCount": 64,
    "EOGChannelCount": 0,
    "ECGChannelCount": 0,
    "EMGChannelCount": 0,
    "MiscChannelCount": 0,
    "TriggerChannelCount": 0
}

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/eeg/sub-002_ses-01_task-MotorImagery_run-01_channels.tsv'...

name    type    units   low_cutoff      high_cutoff     description     sampling_frequency      status  status_description
Fc5.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc3.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc1.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fcz.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc2.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
/Users/hoechenberger/Development/mne-bids/mne_bids/write.py:1149: RuntimeWarning: Converting data files to BrainVision format
  warn('Converting data files to BrainVision format')

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/sub-002_ses-01_scans.tsv'...

filename        acq_time
eeg/sub-002_ses-01_task-MotorImagery_run-01_eeg.vhdr    1919-03-16T16:15:00
eeg/sub-002_ses-01_task-MotorImagery_run-02_eeg.vhdr    1919-03-16T16:15:00
eeg/sub-002_ses-01_task-MotorImagery_run-03_eeg.vhdr    1919-03-16T16:15:00
Wrote /Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/sub-002_ses-01_scans.tsv entry with eeg/sub-002_ses-01_task-MotorImagery_run-01_eeg.vhdr.
Extracting EDF parameters from /Users/hoechenberger/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S002/S002R08.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
/Users/hoechenberger/Development/mne-bids/mne_bids/write.py:1070: RuntimeWarning: Converting to BV for anonymization
  warn('Converting to BV for anonymization')

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/participants.tsv'...

participant_id  age     sex     hand
sub-001 n/a     n/a     n/a
sub-002 n/a     n/a     n/a

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/participants.json'...

{
    "participant_id": {
        "Description": "Unique participant identifier"
    },
    "age": {
        "Description": "Age of the participant at time of testing",
        "Units": "years"
    },
    "sex": {
        "Description": "Biological sex of the participant",
        "Levels": {
            "F": "female",
            "M": "male"
        }
    },
    "hand": {
        "Description": "Handedness of the participant",
        "Levels": {
            "R": "right",
            "L": "left",
            "A": "ambidextrous"
        }
    }
}

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/eeg/sub-002_ses-01_task-MotorImagery_run-02_events.tsv'...

onset   duration        trial_type      value   sample
0.0     0.0     T0      1       0
4.1     0.0     T1      2       656
8.2     0.0     T0      1       1312
12.3    0.0     T2      3       1968
16.4    0.0     T0      1       2624

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/dataset_description.json'...

{
    "Name": " ",
    "BIDSVersion": "1.4.0",
    "DatasetType": "raw",
    "Authors": [
        "Please cite MNE-BIDS in your publication before removing this (citations in README)"
    ]
}
Reading 0 ... 19679  =      0.000 ...   122.994 secs...

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/eeg/sub-002_ses-01_task-MotorImagery_run-02_eeg.json'...

{
    "TaskName": "MotorImagery",
    "Manufacturer": "n/a",
    "PowerLineFrequency": 50,
    "SamplingFrequency": 160.0,
    "SoftwareFilters": "n/a",
    "RecordingDuration": 122.99375,
    "RecordingType": "continuous",
    "EEGReference": "n/a",
    "EEGGround": "n/a",
    "EEGPlacementScheme": "n/a",
    "EEGChannelCount": 64,
    "EOGChannelCount": 0,
    "ECGChannelCount": 0,
    "EMGChannelCount": 0,
    "MiscChannelCount": 0,
    "TriggerChannelCount": 0
}

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/eeg/sub-002_ses-01_task-MotorImagery_run-02_channels.tsv'...

name    type    units   low_cutoff      high_cutoff     description     sampling_frequency      status  status_description
Fc5.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc3.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc1.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fcz.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc2.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
/Users/hoechenberger/Development/mne-bids/mne_bids/write.py:1149: RuntimeWarning: Converting data files to BrainVision format
  warn('Converting data files to BrainVision format')

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/sub-002_ses-01_scans.tsv'...

filename        acq_time
eeg/sub-002_ses-01_task-MotorImagery_run-01_eeg.vhdr    1919-03-16T16:15:00
eeg/sub-002_ses-01_task-MotorImagery_run-02_eeg.vhdr    1919-03-16T16:15:00
eeg/sub-002_ses-01_task-MotorImagery_run-03_eeg.vhdr    1919-03-16T16:15:00
Wrote /Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/sub-002_ses-01_scans.tsv entry with eeg/sub-002_ses-01_task-MotorImagery_run-02_eeg.vhdr.
Extracting EDF parameters from /Users/hoechenberger/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S002/S002R12.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
/Users/hoechenberger/Development/mne-bids/mne_bids/write.py:1070: RuntimeWarning: Converting to BV for anonymization
  warn('Converting to BV for anonymization')

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/participants.tsv'...

participant_id  age     sex     hand
sub-001 n/a     n/a     n/a
sub-002 n/a     n/a     n/a

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/participants.json'...

{
    "participant_id": {
        "Description": "Unique participant identifier"
    },
    "age": {
        "Description": "Age of the participant at time of testing",
        "Units": "years"
    },
    "sex": {
        "Description": "Biological sex of the participant",
        "Levels": {
            "F": "female",
            "M": "male"
        }
    },
    "hand": {
        "Description": "Handedness of the participant",
        "Levels": {
            "R": "right",
            "L": "left",
            "A": "ambidextrous"
        }
    }
}

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/eeg/sub-002_ses-01_task-MotorImagery_run-03_events.tsv'...

onset   duration        trial_type      value   sample
0.0     0.0     T0      1       0
4.1     0.0     T1      2       656
8.2     0.0     T0      1       1312
12.3    0.0     T2      3       1968
16.4    0.0     T0      1       2624

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/dataset_description.json'...

{
    "Name": " ",
    "BIDSVersion": "1.4.0",
    "DatasetType": "raw",
    "Authors": [
        "Please cite MNE-BIDS in your publication before removing this (citations in README)"
    ]
}
Reading 0 ... 19679  =      0.000 ...   122.994 secs...

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/eeg/sub-002_ses-01_task-MotorImagery_run-03_eeg.json'...

{
    "TaskName": "MotorImagery",
    "Manufacturer": "n/a",
    "PowerLineFrequency": 50,
    "SamplingFrequency": 160.0,
    "SoftwareFilters": "n/a",
    "RecordingDuration": 122.99375,
    "RecordingType": "continuous",
    "EEGReference": "n/a",
    "EEGGround": "n/a",
    "EEGPlacementScheme": "n/a",
    "EEGChannelCount": 64,
    "EOGChannelCount": 0,
    "ECGChannelCount": 0,
    "EMGChannelCount": 0,
    "MiscChannelCount": 0,
    "TriggerChannelCount": 0
}

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/eeg/sub-002_ses-01_task-MotorImagery_run-03_channels.tsv'...

name    type    units   low_cutoff      high_cutoff     description     sampling_frequency      status  status_description
Fc5.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc3.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc1.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fcz.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
Fc2.    EEG     µV      0.0     80.0    ElectroEncephaloGram    160.0   good    n/a
/Users/hoechenberger/Development/mne-bids/mne_bids/write.py:1149: RuntimeWarning: Converting data files to BrainVision format
  warn('Converting data files to BrainVision format')

Writing '/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/sub-002_ses-01_scans.tsv'...

filename        acq_time
eeg/sub-002_ses-01_task-MotorImagery_run-01_eeg.vhdr    1919-03-16T16:15:00
eeg/sub-002_ses-01_task-MotorImagery_run-02_eeg.vhdr    1919-03-16T16:15:00
eeg/sub-002_ses-01_task-MotorImagery_run-03_eeg.vhdr    1919-03-16T16:15:00
Wrote /Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/sub-002_ses-01_scans.tsv entry with eeg/sub-002_ses-01_task-MotorImagery_run-03_eeg.vhdr.

Now let’s see the structure of the BIDS folder we created.

Out:

|eegmmidb_bids_group_conversion/
|--- README
|--- dataset_description.json
|--- participants.json
|--- participants.tsv
|--- sub-001/
|------ ses-01/
|--------- sub-001_ses-01_scans.tsv
|--------- eeg/
|------------ sub-001_ses-01_task-MotorImagery_run-01_channels.tsv
|------------ sub-001_ses-01_task-MotorImagery_run-01_eeg.eeg
|------------ sub-001_ses-01_task-MotorImagery_run-01_eeg.json
|------------ sub-001_ses-01_task-MotorImagery_run-01_eeg.vhdr
|------------ sub-001_ses-01_task-MotorImagery_run-01_eeg.vmrk
|------------ sub-001_ses-01_task-MotorImagery_run-01_events.tsv
|------------ sub-001_ses-01_task-MotorImagery_run-02_channels.tsv
|------------ sub-001_ses-01_task-MotorImagery_run-02_eeg.eeg
|------------ sub-001_ses-01_task-MotorImagery_run-02_eeg.json
|------------ sub-001_ses-01_task-MotorImagery_run-02_eeg.vhdr
|------------ sub-001_ses-01_task-MotorImagery_run-02_eeg.vmrk
|------------ sub-001_ses-01_task-MotorImagery_run-02_events.tsv
|------------ sub-001_ses-01_task-MotorImagery_run-03_channels.tsv
|------------ sub-001_ses-01_task-MotorImagery_run-03_eeg.eeg
|------------ sub-001_ses-01_task-MotorImagery_run-03_eeg.json
|------------ sub-001_ses-01_task-MotorImagery_run-03_eeg.vhdr
|------------ sub-001_ses-01_task-MotorImagery_run-03_eeg.vmrk
|------------ sub-001_ses-01_task-MotorImagery_run-03_events.tsv
|--- sub-002/
|------ ses-01/
|--------- sub-002_ses-01_scans.tsv
|--------- eeg/
|------------ sub-002_ses-01_task-MotorImagery_run-01_channels.tsv
|------------ sub-002_ses-01_task-MotorImagery_run-01_eeg.eeg
|------------ sub-002_ses-01_task-MotorImagery_run-01_eeg.json
|------------ sub-002_ses-01_task-MotorImagery_run-01_eeg.vhdr
|------------ sub-002_ses-01_task-MotorImagery_run-01_eeg.vmrk
|------------ sub-002_ses-01_task-MotorImagery_run-01_events.tsv
|------------ sub-002_ses-01_task-MotorImagery_run-02_channels.tsv
|------------ sub-002_ses-01_task-MotorImagery_run-02_eeg.eeg
|------------ sub-002_ses-01_task-MotorImagery_run-02_eeg.json
|------------ sub-002_ses-01_task-MotorImagery_run-02_eeg.vhdr
|------------ sub-002_ses-01_task-MotorImagery_run-02_eeg.vmrk
|------------ sub-002_ses-01_task-MotorImagery_run-02_events.tsv
|------------ sub-002_ses-01_task-MotorImagery_run-03_channels.tsv
|------------ sub-002_ses-01_task-MotorImagery_run-03_eeg.eeg
|------------ sub-002_ses-01_task-MotorImagery_run-03_eeg.json
|------------ sub-002_ses-01_task-MotorImagery_run-03_eeg.vhdr
|------------ sub-002_ses-01_task-MotorImagery_run-03_eeg.vmrk
|------------ sub-002_ses-01_task-MotorImagery_run-03_events.tsv

Now let’s generate a report on the dataset.

Out:

Summarizing participants.tsv /Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/participants.tsv...
Summarizing scans.tsv files [PosixPath('/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-002/ses-01/sub-002_ses-01_scans.tsv'), PosixPath('/Users/hoechenberger/mne_data/eegmmidb_bids_group_conversion/sub-001/ses-01/sub-001_ses-01_scans.tsv')]...
The participant template found: sex were all unknown;
handedness were all unknown; ages all unknown
This dataset was created with BIDS version 1.4.0 by Please cite MNE-BIDS in your
publication before removing this (citations in README). This report was
generated with MNE-BIDS (https://doi.org/10.21105/joss.01896). The dataset
consists of 2 participants (sex were all unknown; handedness were all unknown;
ages all unknown)and 1 recording sessions: 01. Data was recorded using a EEG
system sampled at 160.0 Hz with line noise at 50 Hz. There were 6 scans in
total. Recording durations ranged from 122.99 to 124.99 seconds (mean = 123.99,
std = 1.0), for a total of 743.96 seconds of data recorded over all scans. For
each dataset, there were on average 64.0 (std = 0.0) recording channels per
scan, out of which 64.0 (std = 0.0) were used in analysis (0.0 +/- 0.0 were
removed from analysis).

Total running time of the script: ( 0 minutes 0.394 seconds)

Gallery generated by Sphinx-Gallery