-
Notifications
You must be signed in to change notification settings - Fork 7
JSON format of NIfTI meta data
JSON is a typed data format, with the following types:
- number (integer and real)
- string (encoded in UTF-8)
- boolean
- array
- object (equivalent to a dictionary in Python, a map in C++ or a hash in Perl)
- null (an empty value)
The key of each meta-data item is the keyword of a DICOM element. This keyword implicitly defines the type of the value using the Value Representation listed in the Registry of DICOM Data Elements. The DICOM VRs are mapped to JSON types as described in the DICOM standard (PS 3.18, F.2.3).
A few common mappings are described below:
Meta-data item | Keyword | JSON type |
---|---|---|
Identifier of the patient, subject or animal | PatientID | string |
Echo time (MR images) | EchoTime | number (floating point) |
Date of acquisition | AcquisitionDate | string (YYYYMMDD format) |
Time of acquisition | AcquisitionTime | string (HHMMSS format) |
In order to keep a consistent representation between single-valued items (e.g. AcquisitionDate) and multiple-valued items (e.g. ImageType), all values are expressed as array. The value may apply to subsets of different dimensions:
- PatientID: whole NIfTI file
- EchoTime: whole NIfTI file (3D case) or 3D subset (4D case)
- PhaseEncodingDirection: may vary from slice to slice To keep this variety and at the same type avoid repeating the values for each pixel, the value can be compacted: for an n-D NIfTI file, an (m+1)-D meta-data item applies to the (n-m)-D subsets of the NIfTI data.
For a simple example, consider an ImageType item of value ["ORIGINAL", "PRIMARY"]
: it is and 1-D array and applies to the whole n-D NIfTI data (since m equals 0). This means that each subset of the NIfTI data has an ImageType of value ["ORIGINAL", "PRIMARY"]
.
An intermediate example is an EchoTime item of value [[10], [20]]
. It is a 2-D array, and for a 4-D NIfTI file, each value (respectively [10]
and [20]
) apply to a 3-D volume (since m equals 1). The first 3D volume in the 4D NIfTI file will have an echo time value of [10]
(remember that each value is an array, even single-valued items) and that the second 3D volume in the 4D NIfTI file will have an echo time value of [20]
.
A reference implementation computing the value of a meta-data item at a single voxel or on the whole volume is given in the source code of dicomifier.