The bidsmap creation is the most annoying and complex part of bidsification with bidsme
.
In this instruction we tried to provide the step-by-step instructions how to create the map.
There main guidelines:
- Have a list of series per session in their expected order, useful to retrieve names and make notes
- Prepare bidsified names beforehand, this will streamline process and avoid errors in
IntendedFor
meta-fields - Work on a good subject i.e. complete without deviation from protocol, without duplicated acquisition etc.
bidme map
will stop at each error and warning, so make sure to fix errors and warnings thatbidsme
report- Rerun map command at each occasion
Some vocabulary (just to avoid confusion):
- recording -- an individual nii file (single volume) with its header exported as json
- header -- a json file containing exported recording header
- series -- a collection of recordings belonging to the same acquisition (here I use DICOM definition of term).
- series Id -- a string identifying given series (usually the name of used protocol)
- series no -- Acquisition number of a given series in their chronological order
- session -- collection of series acquired in one visit
- data type -- kind of data acquired (MRI, EEG, PET etc.)
- data format -- format that recordings are stored (dicom, nifti, nifti+json etc.)
- modality -- type of recording, corresponds to lowest level folder in bids structure (func, anat, dwi, beh, edf etc.)
- suffix -- BIDS identifier differentiating different types of recording within modality, last part of bidsified name
- entity -- a underscore-separated blocks constructing bidsified name, entity is composed of name and value, separated by dash. Entity must be as uniform as possible within modality, values must be intuitive
- map entry -- bidsmap block corresponding to one recording, starting with
provenance
field and ending withjson
For MRI the relevant page is there.
In following I will use []
to indicate context-depending variables, usually specific paths.
For example [path-to-source-dataset]
should be replaced by by your specific path to source dataset.
Don't worry about plugins at this stage, but if in your map you find something not robust, too rigid or awkward note this in the list of your series. Do not note how, but note what. For example in MPM just note "remove reliance on series number"
If you are not sure on name to give to one entity, or suffix, just use something easy to spot, like "ToRename".
In the prepared folder data is always organized as follows:
sub-[subject Id]/ses-[session Id]/[data type]/[series number]-[series Id]/data
bidsme
will try to provide as much of information about encountered errors and warnings as possible. Read the printed log not only at error, but also before -- bidsme
will say on which series he worked when error occurred.
I start with prepared dataset, stored in the prepared
folder in my actual directory.
Bidsified dataset will be put into already existing and empty folder bidsified
, in output directory.
Map creation is an iterative process, bidsme
will analyse each series in order of appearance, and will go to the next one only if previous was processed without errors.
Start with prepared dataset (in prepared
directory) and empty bidsified dataset (in bidsified
directory)>
Execute:
bidsme map prepared bidsified
bidsme
will get one series and will try to much it with the template, depending if file matches current bidsmap
, template or no matches are found, the actions are similar:
bidsme
will put a new map entry into bidsified/code/bidsme/bidsmap.yaml
with pre-filled bids entities and json fields from the template.
bidsme
will complete the entities and json fields with one from BIDS that corresponds to given modality and suffix.
Depending on luck/template/data bidsme
may show some warnings and/or errors, that must be addressed.
Independently of errors/warnings you must open the bidsmap.yaml
file and do following actions, in order:
-
- Find relevant map entry (search for line
template:true
or for series name, it should appear inprovenance
field)
- Find relevant map entry (search for line
-
- Set
template
tofalse
- Set
-
- Check
example
field -- it will show generated bidsified name for the file inprovenance
, compare it with what you expect, then adjustbids
section to much the expectations
- Check
-
- Check the json section, if you will need some custom metadata add new field.
-
- Go to step 0 (run map again) -- do not correct errors/warnings at this point
If corresponding map entry, the field checked
is false
, bidsme
will update example
, provenance
fields, and complete the entities and json fields.
The field template: true
will always produce a warning that will make bidsme
will always stop after processing this series.
You can use this for forbid bidsme
to go further, even if series do not produce errors or warnings.
bidsme
will consider series processed and will analyse the next one.
bidsme
encountered some issues that require user input.
You must open/reload bidsified/code/bidsme/bidsmap.yaml
:
-
- Find relevant map entry (search for series name, it should appear in
provenance
field)
- Find relevant map entry (search for series name, it should appear in
-
- Identify one issue, read the error/warning message attentively (see below)
-
- Fix this issue
-
- Go to step 0 (run map again) -- it is better (at least in the beginning) to correct one issue at the time
Some classical warnings and errors:
placeholder found
: The field value<placeholder>
are the reminders that some entities/metadata are mandatory (for ex.task
entity forfunc
). This value will always produce a warning, you need to replace this value with desired one.ruamel error
: usually an extra space, this error will point to the faulty line- Unable to get [field]:
bidsme
can't find the requested metadata, find the mentioned field (usually in json section), and manually set the correct value, or set to~
if this field is not needed Failed: [N] examples matching several runs
: this error indicates that there several data files in the series which will be bidsified with exactly same name. It can happen typically with multi-volumes recordings likefunc
ordwi
. You need add a new entity tobids
section that allow to attribute different names to these files (for ex:run: <AcquisitionNumber>
orrun: <AcquisitionNumber>
).Suffix not defined
: manually set thesuffix
fieldBidsified name same as first file of recording
: This error happens when a bidsified name of current series coincide with a bidsified name of different series, both series should be mentioned in the message. You need to find both relevant map entries and modify them to ensure that bidsified names are distinct. If one of the recordings haschecked: true
, it must be changed tochecked: false
to insure that changes do not generate an error andexample
field will be updatedschema not BIDS
: this warning indicates that you set up entities in the manner that are not BIDS compatible. You are invited to cross-check if the bidsified name is exactly what needed, and if so setchecked: true
to silence the warning.run [] also matches run []
: this error will raise than mentioned file will match two different map entries, referenced by their index andprovenance
field (for easier search). You need to find both map entries and ensure thatattributes
section matches only desired series.IntendedFor value not found
: if a json section of a given map entry containIntendedFor
field and bidsified directory already contains current subject bidsified,bidsme
will try to find if all entries fromIntendedFor
are present on in the bidsified subject and will report all missing files. You need just adapt theIntendedFor
content to match bidsified dataset.
bidsme
will create e new entry for each file in the series in bidsified/code/bidsme/unknown.yaml
, with __unknown__
modality, empty suffix
, bids
, json
sections and partially filled attributes
section.
-
- Identify the correct modality of the first map entry in the
unknown.yaml
- Identify the correct modality of the first map entry in the
-
- Copy the first map entry to corresponding modality in
bidsmap.yaml
. Bothunknown.yaml
andbidsmap.yaml
follows the same structure and copy-paste should be enough, but sometimes the spaces and tabulations becomes shifted -- you need to correct them, or you will see yaml parsing errors
- Copy the first map entry to corresponding modality in
-
- Fill the
suffix
field, leavejson
andbids
empty -- they will be automatically filled at the next iteration
- Fill the
-
- Go to step 0 (run map again) -- it is better (at least in the beginning) to correct one issue at the time
Eventually all series in prepared
directories will have corresponding map entry, without any errors/warnings.
bidsme
may still show a warning found [N] unchecked runs
and/or found [N] template runs
.
This is reminder that not all templates map entries are removed and not all entries was manually validated.
This validation is almost final step for map creation.
You need to go trough all map entries and:
-
- Set
template
tofalse
if it istrue
- Set
-
- Check
example
field, if it is as you need
- Check
-
- Check
json
fields, if they contains needed information
- Check
-
- Remove all empty ('' and
~
) json fields
- Remove all empty ('' and
- 3a. If both
example
andjson
are correct, setchecked
totrue
- 3b. If you set some modifications to map entry, rerun
map
to ensure that the modifications do not induce warnings/errors
Backup bidsified/code/bidsme/bidsmap.yaml
file in safe place.
When all warnings from bidsme map
command are fixed, it is the time to test that subject will be well bidsified by running:
bidsme bidsify prepared bidsified
If there no errors, go to the next step, map is created. If there errors:
-
- Identify error (see below)
-
- Decide if error comes from data or from
bidsmap.yaml
- Decide if error comes from data or from
-
- Correct either data in
prepared
directory or modifybidsmap.yaml
- Correct either data in
-
- Run map on the subject where error has occurred to ensure that error was fixed
bidsme map prepared bidsified --participants sub-<XYZ>
- Run map on the subject where error has occurred to ensure that error was fixed
-
- Remove all
sub-*
frombidsified
directory (be careful to not removecode
directory it containsbidsmap.yaml
file)
- Remove all
-
- Go to step 30 (re-run bidsification)
In some modalities (usually fmap
) BIDS require to define dependencies of files using IntendedFor
metadata.
This metadata must contain the list of data paths (starting from subject root directory) that depends on current file.
bidsme
can check if all files in IntendedFor
are found.
To do the check, you just need to re-run map
with already bidsified dataset:
bidsme map prepared bidsified
If some files are missing, you will see a warning IntendedFor value not found
with references to faulty map entry.
You need just correct the values.
After these steps, the dataset should be bidsified. If there some new data arriving, the bidsified dataset can be completed by:
bidsme prepare source prepared --skip-in-tsv
bisdme bidsify prepared bidsified --skip-in-tsv
The option --skip-in-tsv
will ensure that subjects already prepared/bidsified will not be processed again.