View on GitHub

BIDS workshop

resources for a BIDS workshop

Preparing a BIDS dataset by hand and from scratch

Adapted from the BIDS cookbook.

⚠️ Note that this is purely for learning purposes and it is NOT recommended to BIDSify real datasets by hand . ⚠️

Table of content

CLICK ME
... to see what I hide !!!


Ingredients and tools

Get them fresh from your local market:

🧠 some source data to be converted into BIDS

For this workshop you can choose to work with several datasets that are adapted from some of the SPM12 tutorials. You can download them from OSF by using one of the following links:

In the example below I will work with the multimodal face dataset.

Very often MRI source data will be in a DICOM format and will require to be converted to nifti. here the MRI data is already in "4D" Nifti format .nii format. It is also gziped (.nii.gz) to save space.

The dataset contains both structural data: should start with the letter s and functional data: should start with the letter f. It should also contain excel files that contain when each stimulus was presented to the subject.

This dataset originally contains EEG, MEG and fMRI data on the same subject within the same paradigm. Here we are only working with the MRI data. We also extracted some of the information about the data from the SPM manual and put it into the README.

When you have DICOM data, it is usually a good idea to keep the PDF of MRI acquisition parameters with your source data.

πŸ–‹ a text editor
A good choice is to use Visual Studio code (Notepad does not really count).
πŸ“₯ [OPTIONAL] BIDS validator
  • Install Node.js (at least version 12.12.0).
  • Update npm to be at least version 7 (npm install --global npm@^7)
  • From a terminal run npm install -g bids-validator
  • Run bids-validator to start validating datasets.
See the full instruction here.


Recipe

1. Preheat the oven: creating folders

By now you should have this.
  β”œβ”€β”€ sourcedata
  └── sub-01
      └── ses-mri
          β”œβ”€β”€ anat
          └── func
  


a. Cooking is not just about the taste, it is also about how things look: naming files

In case you do not remember which suffix to use and which entities are required or optional, the BIDS specification has:

b. Taste your dish while you prepare it: using the BIDS validator

Try it directly in your browser.

c. Season to taste: adding missing files

You can get template content for those files from:

Suggestion:

Add the β€œtable” output of the BIDS validator to your README to give a quick overview of the content of your dataset.

🚨 About JSON files
JSON files are text files to store key-value pairs.

More information on how read and write JSON files is available on the BIDS stater kit and also on the bids stats model website.

JSON CONTENT EXAMPLE:

  {
    "key": "value",
    "key2": "value2",
    "key3": {
      "subkey1": "subvalue1"
    },
    "array": [ 1, 2, 3 ],
    "boolean": true,
    "color": "gold",
    "null": null,
    "number": 123,
    "object": {
      "a": "b",
      "c": "d"
    },
    "string": "Hello World"
  }

d. Icing on the cake: adding extra information

🚨 About TSV files
A Tab-Separate Values (TSV) file is a text file where tab characters (\t) separate fields that are in the file. It is structured as a table, with each column representing a field of interest, and each row representing a single data point.

More information on how read and write TSV files is available on the BIDS stater kit

TSV CONTENT EXAMPLE:

participant_id\tage\tgender\n
sub-01\t34\tM
By now you should have this.
  β”œβ”€β”€ sourcedata
  β”œβ”€β”€ sub-01
  β”‚   └── ses-mri
  β”‚       β”œβ”€β”€ anat
  β”‚       β”‚   β”œβ”€β”€ sub-01_ses-mri_T1w.json
  β”‚       β”‚   └── sub-01_ses-mri_T1w.nii
  β”‚       └── func
  β”œβ”€β”€ README
  β”œβ”€β”€ participants.tsv
  β”œβ”€β”€ participants.json
  └── dataset_description.json
  


3. Main course: converting the functional MRI files

By now you should have this.
  β”œβ”€β”€ sourcedata
  β”œβ”€β”€ sub-01
  β”‚   └── ses-mri
  β”‚       β”œβ”€β”€ anat
  β”‚       β”‚   └── sub-01_ses-mri_T1w.nii
  β”‚       └── func
  β”‚           β”œβ”€β”€ sub-01_ses-mri_task-FaceSymmetry_run-1_bold.nii
  β”‚           β”œβ”€β”€ sub-01_ses-mri_task-FaceSymmetry_run-1_events.tsv
  β”‚           β”œβ”€β”€ sub-01_ses-mri_task-FaceSymmetry_run-2_bold.nii
  β”‚           └── sub-01_ses-mri_task-FaceSymmetry_run-2_events.tsv
  β”œβ”€β”€ README
  β”œβ”€β”€ participants.tsv
  β”œβ”€β”€ participants.json
  β”œβ”€β”€ T1w.json
  β”œβ”€β”€ task-FaceSymmetry_bold.json
  └── dataset_description.json