The Brain Imaging Data Structure (BIDS) is a standard for organizing, annotating, and describing data collected during neuroimaging experiments. It is based on a formalized file/folder structure and JSON based metadata files with controlled vocabulary. BIDS has standard conventions for file names. A filename consists of a chain of entities, or key-value pairs, a suffix and an extension.
BIDS has a standardized way of naming files that tries to implement the following principles:
Do not white spaces in file names
Use only letters, numbers, hyphens, and underscores.
Do not rely on letter case (UPPERCASE and lowercase)
Use separators provide a meaningful way to describe the content of the file. Filename template
key1-value1_key2-value2_suffix.extension
Entities are composed ofkey-valuepairs separated by underscores.Keys,valueandsuffixescan only contain letters and/or numbers.Suffixdenotes de neuroimaging modality: e.g.,eegSuffixesare preceded by an underscore.
Extensioncan contain three or more character and they can be:.edf .set .fdt
An example of a valid filename is:
sub-100_task-motor_eeg.setThis filename describes the electroencephalography (eeg) data of the subject (sub) number100which performed amotortask.
Create a program that asks the user for a valid BIDS filename, validates the filename and inform the user the result according to the following cases:
Validate Expected format Description
Separator symbols
-_
The only valid separators are dash, underscore, and dot. Dashes are part of key-value pairs, while underscores separate those pairs. Any other symbol is not valid as well as misplacing the dashes and underscore. A dot can only appear one time in the correct place (15 points).
The subject entity
sub-DDD
The first three characters are fixed (“sub”), a dash, and a number with three digits followed by an underscore (15 points).
The task entity
task-LLLLL
The first four characters are fixed (“task”), a dash, five characters (only letters) followed by an underscore (15 EXTRA points).
The suffix entity LLL The exact string “eeg” followed by a dot (‘.’) (15 points).
The extension LLLEither of the extensions: “edf” or ”set” (15 points).
Expected solution:
The output of the program can be any of these three cases:
- The filename is complete and valid.
- The filename is not valid (error in separators).
- The filename is not valid (error in subject entity).
- The filename is not valid (error in task entity).
- The filename is not valid (error in suffix entity).
- The filename is not valid (error in extension).
Examples:
i)
Enter a BIDS-valid filename:
sub-100_task-motor_eeg.set
The filename is valid and complete.
ii)
sub-23_task-motor_eeg.set
The filename is not valid (error in subject entity)
Explanation: the number format for the subject is not valid because it has only two digits (it should be four digits).
iii)
sub-100_task-motor_egg.set
The filename is not valid (error in suffix entity)
Explanation: Expected “eeg” and “egg” received instead iv)Enter a BIDS-valid filename: sub_100-task_motor-egg.set
Explanation: Not valid separators. They are not valid because the underscores are in the dashes places and vice versa.
Suggested reading
•zyBook, 3.6 Character operationsRequired style (10 pts. each):
Add a multi-line comment at the top of the file with the format:
/*TITLE OF THE PROGRAM Input dataInputVar1 : Explanation InputVar2 : Explanation ...OutputOutputVar1 : Explanation */
Add single-line comments to describe every step of your program: For instance, each condition must have a brief explanation.
Use descriptive names for the identifiers and one style (snake_case or camelCase; choose only one).
Print numbers using the integer format.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here