Learn · Chapter 15 of 15
The command line
Every step of the course has a command. Use them to convert on a server without a display, to repeat a conversion in a script, or to convert the project you curated in the GUI.
The commands
| Command | What it does | In the GUI |
|---|---|---|
bidsmgr |
Opens the GUI | |
bidsmgr-create |
Creates a project | Home > Create a new dataset |
bidsmgr-adopt |
Makes an existing BIDS dataset a project | Home > Open dataset folder |
bidsmgr-project |
Lists a project's scan tables | Scan table, in the Converter |
bidsmgr-scan |
Scans raw data into a scan table (inventory.tsv) |
Scan… |
bidsmgr-classify |
Names MRI series again from their acquisition parameters | Settings > Classification |
bidsmgr-rebuild |
Rebuilds the BIDS names of an edited inventory.tsv |
Editing the table |
bidsmgr-convert |
Converts a scan table | Run conversion |
bidsmgr-metadata |
Writes the dataset's metadata and TODO placeholders | the post-convert chain |
bidsmgr-validate |
Validates a dataset | Validate dataset |
bidsmgr-deface |
Removes faces, or keeps the brain only | Tools > Deface |
bidsmgr-qc |
Runs the quality check | Tools > Quality check |
bidsmgr-view |
Opens an image in the viewer, or renders it to a file | the viewer |
--help on any of them lists its options; every option is in Command line.
Convert the course's project
The project keeps the scan table and every edit you made to it in the GUI, so the commands can pick up where the GUI left off. --project names the project folder.
Step 1. List the project's scan tables
bidsmgr-project /tmp/studies/multimodal_study
Project: /tmp/studies/multimodal_study
1 scan version(s); active = latest:
* 0001__raw [curating] 19 rows source=raw raw=/tmp/studies/BIDS_Manager_multimodal_sample_v2/raw
The table marked * is the one the other commands use, unless --version names another.
Step 2. Convert it
bidsmgr-convert --project /tmp/studies/multimodal_study -j 4
The conversion replays the edits recorded in the project (one subject, one session, the spectroscopy names) and the PET dose values saved with the scan table. The description and the participants file are written by the next step, bidsmgr-metadata. -j 4 converts four series at a time. It took 5.3 seconds on the sample.
Step 3. Write the metadata
bidsmgr-metadata --project /tmp/studies/multimodal_study --fill-todos
TODO placeholders inserted: 69 fields across 8 files
--fill-todos writes the TODO placeholders the GUI's default post-convert chain writes; --fill-scope required|recommended|optional chooses how far they go.
Step 4. Validate
bidsmgr-validate /tmp/studies/multimodal_study --strict --html
=== /tmp/studies/multimodal_study ===
severity: ERR (ok=27 warn=112 err=1)
--strict runs the deep checks and --html writes validation_report.html into the project's .bidsmgr/ folder. The result is the GUI's, file for file: the same 65 files, the same one error (chapter 9 fixes it).
From raw data to BIDS in a script
For a study you convert the same way every time, the whole workflow can run without the GUI:
bidsmgr-create /data/bids/my_study --name "My study"
bidsmgr-scan /data/raw/my_study --project /data/bids/my_study -j 8
bidsmgr-convert --project /data/bids/my_study -j 8 --pet-spreadsheet dose_sheet.csv
bidsmgr-metadata --project /data/bids/my_study --participants participants.csv --fill-todos
bidsmgr-validate /data/bids/my_study --strict --html
What the GUI lets you do between the scan and the conversion (reconcile subjects, rename a task, leave a series out), a script does in inventory.tsv. Two ways:
- Scan rules in a JSON file (
bidsmgr-scan --rules-file rules.json): leave out series by name and give your own names to series, applied at every scan. Settings > Scan rules keeps rules of the same form in BIDS Manager's own settings, but cannot save them to a file; write the JSON by hand (bidsmgr-scan --helpshows its form). - Edit
inventory.tsv, a tab-separated table, then runbidsmgr-rebuildto rebuild the names. Theentitiescolumn holds every row's entities as JSON and is what the names are built from: edit it, and runbidsmgr-rebuild inventory.tsv(the default,--from entities).
Without a project
The commands also work on a free-standing inventory.tsv and output folder, which suits one-off conversions:
bidsmgr-scan /data/raw/my_study inventory.tsv -j 8
bidsmgr-convert inventory.tsv /data/bids --raw-root /data/raw/my_study -j 8
bidsmgr-metadata /data/bids/my_study --fill-todos
bidsmgr-validate /data/bids/my_study
The dataset folder is named after the raw folder (in lower case) unless bidsmgr-scan --dataset names it. Without a project, nothing records your edits and there are no scan versions; for anything you will come back to, use a project.
Viewing and checking from the command line
bidsmgr-view sub-001/ses-01/anat/sub-001_ses-01_acq-tfl3p2_T1w.nii.gz --layout multi
bidsmgr-view T1w.nii.gz --render t1.png --planes axial coronal --height 400
bidsmgr-qc /tmp/studies/multimodal_study --datatype anat dwi -j 4
--render draws the image to a file without opening a window, which works on a server. Save > Show the command line... in the viewer writes the bidsmgr-view command that reproduces what is on screen.
Your progress is kept in this browser only.