Skip to content

Commit 89ba5c3

Browse files
authored
Merge pull request #442 from sappelhoff/camelsnake
FIX: Clarify snake_case+CamelCase in TSV+JSON
2 parents 0e5c902 + 3b59659 commit 89ba5c3

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

src/02-common-principles.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ additional meta information extracted from DICOM files in a sidecar JSON file
264264
(with the same filename as the `.nii[.gz]` file, but with a `.json` extension).
265265
Extraction of BIDS compatible metadata can be performed using [dcm2niix](https://github.com/rordenlab/dcm2niix)
266266
and [dicm2nii](http://www.mathworks.com/matlabcentral/fileexchange/42997-dicom-to-nifti-converter/content/dicm2nii.m)
267-
DICOM to NIfTI converters. A provided
268-
[validator](https://github.com/bids-standard/bids-validator)
267+
DICOM to NIfTI converters. The [BIDS-validator](https://github.com/bids-standard/bids-validator)
269268
will check for conflicts between the JSON file and the data recorded in the
270269
NIfTI header.
271270

@@ -274,9 +273,13 @@ NIfTI header.
274273
Tabular data MUST be saved as tab delimited values (`.tsv`) files, i.e., CSV
275274
files where commas are replaced by tabs. Tabs MUST be true tab characters and
276275
MUST NOT be a series of space characters. Each TSV file MUST start with a header
277-
line listing the names of all columns (with the exception of physiological and
278-
other continuous acquisition data - see below for details). Names MUST be
279-
separated with tabs. String values containing tabs MUST be escaped using double
276+
line listing the names of all columns (with the exception of
277+
[physiological and other continuous recordings](04-modality-specific-files/06-physiological-and-other-continuous-recordings.md)).
278+
Names MUST be separated with tabs.
279+
It is RECOMMENDED that the column names in the header of the TSV file are
280+
written in [`snake_case`](https://en.wikipedia.org/wiki/Snake_case) with the
281+
first letter in lower case (e.g., `variable_name`, not `Variable_name`).
282+
String values containing tabs MUST be escaped using double
280283
quotes. Missing and non-applicable values MUST be coded as `n/a`. Numerical
281284
values MUST employ the dot (`.`) as decimal separator and MAY be specified
282285
in scientific notation, using `e` or `E` to separate the significand from the
@@ -340,8 +343,14 @@ format can be found here: [http://json.org/](http://json.org/). Several editors
340343
have built-in support for JSON syntax highlighting that aids manual creation of
341344
such files. An online editor for JSON with built-in validation is available at:
342345
[http://jsoneditoronline.org](http://jsoneditoronline.org)
346+
It is RECOMMENDED that keys in a JSON file are written in [CamelCase](https://en.wikipedia.org/wiki/Camel_case)
347+
with the first letter in upper case (e.g., `SamplingFrequency`, not
348+
`samplingFrequency`). Note however, when a JSON file is used as an accompanying
349+
sidecar file for a [TSV file](#tabular-files), the keys linking a TSV column
350+
with their description in the JSON file need to follow the exact formatting
351+
as in the TSV file.
343352

344-
Example:
353+
Example of a hypothetical `*_bold.json` file, accompanying a `*_bold.nii` file:
345354

346355
```JSON
347356
{
@@ -350,6 +359,23 @@ Example:
350359
}
351360
```
352361

362+
Example of a hypothetical `*_events.json` file, accompanying an
363+
`*_events.tsv` file. Note that the JSON file contains a key describing an
364+
*arbitrary* column `stim_presentation_side` in the TSV file it accompanies.
365+
See [task events section](04-modality-specific-files/05-task-events.md)
366+
for more information.
367+
368+
```JSON
369+
{
370+
"stim_presentation_side": {
371+
"Levels": {
372+
"1": "stimulus presented on LEFT side",
373+
"2": "stimulus presented on RIGHT side"
374+
}
375+
}
376+
}
377+
```
378+
353379
## Participant names and other labels
354380

355381
BIDS uses custom user-defined labels in several situations (naming of

src/04-modality-specific-files/01-magnetic-resonance-imaging-data.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ Useful for multimodal co-registration with MEG, (S)EEG, TMS, etc.
102102
| InstitutionAddress | RECOMMENDED. The address of the institution in charge of the equipment that produced the composite instances. Corresponds to DICOM Tag 0008, 0081 `InstitutionAddress`. |
103103
| InstitutionalDepartmentName | RECOMMENDED. The department in the institution in charge of the equipment that produced the composite instances. Corresponds to DICOM Tag 0008, 1040 `Institutional Department Name`. |
104104

105-
When adding additional metadata please use the camelcase version of
105+
When adding additional metadata please use the CamelCase version of
106106
[DICOM ontology terms](https://scicrunch.org/scicrunch/interlex/dashboard)
107-
whenever possible.
107+
whenever possible. See also
108+
[recommendations on JSON files](../02-common-principles.md#keyvalue-files-dictionaries).
108109

109110
### Anatomy imaging data
110111

src/04-modality-specific-files/05-task-events.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ the first volume.
4545

4646
An arbitrary number of additional columns can be added. Those allow describing
4747
other properties of events that could be later referred in modelling and
48-
hypothesis extensions of BIDS.
48+
hypothesis extensions of BIDS. Note that any additional columns in a TSV file
49+
SHOULD be documented in an accompanying JSON sidecar file.
4950

5051
In case of multi-echo task run, a single `_events.tsv` file will suffice for all
5152
echoes.

0 commit comments

Comments
 (0)