arrow-left

All pages
gitbookPowered by GitBook
1 of 21

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

General principles

We use JSONarrow-up-right to represent metadata that is either passed to the converter into DICOM, or that is extracted from DICOM representation.

As such, you will need to have some understanding of both DICOM and JSON if you want to use dcmqi.

We provide the following tools that can help you use dcmqi more effectively.

  • dicom-dumparrow-up-right is an extension for Atomarrow-up-right text editor that can be used to explore the content of DICOM data

  • web app can be used to see examples of metadata JSON for specific object types, to explore the schema, and to validate your own metadata JSON against the schema

You can check out our section for some reference material about JSON and DICOM that we found helpful.

dcmqi validatorsarrow-up-right
Learning resourcesarrow-up-right

Installation

dcmqi is a collection of libraries and command line tools. It is currently possible to install dcmqi using one of the following approaches:

  1. Using binaries for your platform from either the "latest" or named releasearrow-up-right

  2. Using docker

We are also working on providing a downloadable binaries of dcmqi independent of the 3D Slicer application. This option will be supported in the future.

Build from source
From 3D Slicer extension

Binary packages

Platform-specific packages of dcmqi accompany the library starting from release v1.0.1. You can download these packages for Windows, macOS and Linux at https://github.com/QIICR/dcmqi/releasesarrow-up-right. Extract the package archive for your operating system to access command line tools.

Docker images

hashtag
Background

Dockerarrow-up-right is a project that automates deployment of applications inside software containers. Docker application is defined by images that contain all of the components and steps needed to initialize the application instance. A container is a running instance of the image. We provide an image that contains the compiled dcmqi library. By using dcmqi Docker container you can use dcmqi on any operating system without having to compile it. All you need to do is install Docker on your system, and download the dcmqi Docker image.

hashtag
Usage

You will first need to install Docker on your system following . Docker is available for Mac, Windows and Linux. For the most part Docker installation is straightforward, but some extra steps need to be taken on Windows as discussed below.

hashtag
If you use Docker on Windows ...

Note the :

  • you will need to have Windows 10 Pro or above

  • you will need to enable Hyper-V package (Docker will prompt you)

  • you will need to enable virtualization; to learn how to check if it is enabled, and if it is not - here is that may help you do that, but it assumes you can access your BIOS settings

IMPORTANT: You will also need to share the drive you will be using to communicate data to and from Docker image in Docker Settings as shown in the screenshot below.

Most likely you will experience the display of an error message similar to the one shown below.

If you have this error, make sure that the drive, where the HOST_DIR is located, is shared:

  1. right click onto the Docker task bar icon and choose "Settings"

  2. choose "Shared Drives" from the left menu (a list of drives that are available to share will be displayed)

  3. select the drive for your HOST_DIR to be shared

hashtag
Once Docker is installed

Pull the dcmqi image to your system to instantiate the dcmqi container:

You can now run any of the command line converter provided by dcmqi by passing the name of the converter as shown below:

The Dockerfile for qiicr/dcmqi is available in the main repository of dcmqi . It does not rely on any proprietary or non-open-source components.

hashtag
Shared directory between Docker container and host

Docker containers cannot directly access the filesystem of the host. In order to pass files as arguments to the dcmqi converter and to access files that converters create, an extra step is required to specify which directories will be used for file exchange using the -v argument:

The argument above will make the HOST_DIR path available within the container at CONTAINER_DIR location. The files that will be read or written by the converter run from the docker container should be referred to via the CONTAINER_DIR path.

hashtag
Usage example

(also see !)

Assuming the docker image is installed, create an empty directory docker_test.

Put the following test files from dcmqi source code repository into the docker_test directory:

Run the itkimage2paramap converter

The output DICOM object will be saved as docker_output_paramap.dcm in the docker_test directory.

confirm with Apply and continue

these instructionsarrow-up-right
system requirementsarrow-up-right
read thisarrow-up-right
one guidearrow-up-right
herearrow-up-right
dcmqi introduction tutorialarrow-up-right
the input parametric map in NRRD formatarrow-up-right
the DICOM file containing the metadata to be propagated into the outputarrow-up-right
the metadata JSON describing the parametric maparrow-up-right

Coding schemes

One of the fundamental principles of DICOM is the use of controlled terminologies, or lexicons, or coding schemes (for the purposes of this guide, these can be used interchangeably). While using dcmqi you will encounter various situations where you will need to select codes to describe the data you are converting into DICOM. In this and the following sections we give you an overview and describe the general principles of deciding on how to choose such codes.

Controlled terminologies define a set of codes, and sometimes their relationships, that are carefully curated to describe entities for a certain application domain. Consistent use of such terminologies helps with uniform data collection and is critical for harmonization of activities conducted by independent groups.

When codes are used in DICOM, they are saved as triplets that consist of

  • CodeValue: unique identifier for a term

  • CodingSchemeDesignator: code for the authority that issued this code

  • CodeMeaning: human-readable code description

DICOM relies on various sources of codes, all of which are listed in of the standard.

The first question while choosing the coding scheme is whether you will use an existing code, or define your own. Depending on your choice, follow one of the two recipes below.

  1. If there is no matching code that is already included in DICOM, you can : this option often requires more effort, but it will make your resulting data consistent with the existing controlled terminologies, facilitating reasoning on the resulting data, and aggregation of the results collected from different sources. This “semantic” approach using standard codes allows for greater reuse and harmonization with other data sets, since the need for natural language parsing of plain text during “data mining” is obviated by the commonality of standard codes for standard entities, such as anatomical regions, types of tumor, etc. The choice of the coding scheme and specific codes will depend on the specific data conversion task.

DICOM-defined coding schemes

In DICOM, the process of choosing a code, and a coding scheme, depends on the context. In the following, we will discuss some of the guidelines that can be used to choose suitable codes for the tasks of segmentation, measurements and parametric map conversion supported by dcmqi.

  • Segmentation

  • Measurements

hashtag
Segmentation

While converting segmentations, you will need to define the following coded entities in the JSON file:

  • SegmentedPropertyCategoryCodeSequence

  • SegmentedPropertyTypeCodeSequence

  • SegmentedPropertyTypeModifierCodeSequence (when applicable)

This looks overwhelming indeed! That's why we developed to help you interactively choose the codes for each of those items. If you want to know the details, read on!

For each of these attributes, DICOM provides guidance on the selection of the suitable codes.

SegmentedPropertyCategoryCodeSequence codes are listed in context group ID (CID) (extensible, i.e., you are not forced to use only the codes from this selection)

SegmentedPropertyTypeCodeSequence codes are defined in , which points to the application-specific CIDs that you can follow for the lists of codes

SegmentedPropertyTypeModifierCodeSequence is an optional attribute that augments segmented property type code. As an example, if SegmentedPropertyTypeModifier is "Kidney", SegmentedPropertyTypeModifier can be "Left" to specify laterality. More modifier codes are available in , as an example see .

AnatomicRegionSequence and its modifier do not always have to be specified. In some situations, information contained in SegmentedPropertyType is sufficient. E.g., if one is creating an atlas, where the properties are purely anatomical, and there is no more to say about them than the anatomy, then the anatomy goes in the Segmented Property Type Code Sequence. If one has different types of properties (e.g., necrosis, enhancing rim, gross tumor volume), but one wants to say something about the anatomy (e.g., where the tumor is at), then the property goes in Segmented Property Type Code Sequence and the anatomy goes in Anatomic Region Sequence. When you do want to specify AnatomicRegion, you can consult for the list of codes. Modifier for this code is specified as needed, following the same approach as discussed for SegmentedPropertyTypeModifierCodeSequence.

we mentioned earlier provides an interactive interface to somewhat simplify the task of populating the codes discussed above.

hashtag
SNOMED CT

Most, if not all codes listed in the contexts referenced earlier are from SNOMED CT, and have DICOM CodingSchemeDesignator SRT. The reason for this is that coding scheme is the preferred controlled terminology used by DICOM . Most, if not all, of the codes used to define the entities above are from SNOMED CT. SNOMED CT maintains a systematically organized computer processable collection of medical terms providing codes, terms, synonyms and definitions used in clinical documentation and reporting. SNOMED CT maintains the hierarchy of relationships among the codes, which can be used for semantic reasoning on the data. As an example, see .

hashtag
SNOMED CT License exemption

Note that SNOMED CT codes included in the DICOM standard are exempt from . The details are discussed in . In short:

Users and commercial and open source DICOM developers can be reassured that they may continue to use the subset of SNOMED concepts in the DICOM standard in their products and software, globally and without a fee or individual license.

hashtag
Measurements

TBD - work in progress

hashtag
Parametric map

The following codes can be passed to describe the parametric map you are converting using :

  • QuantityValueCode: Quantity being measured at each pixel - select code from , or introduce a .

  • MeasurementUnitsCode: Units of measurement. DICOM uses code system (CodingSchemeDesignator UCUM) to describe units. Some of the commonly used unit codes are listed in , but as discussed in , any of the UCUM codes can be used in DICOM.

In the future we plan to provide specific recipes that describe the sets of codes suitable for specific use-cases (e.g., estimating Apparent Diffusion Coefficient (ADC) from Diffusion-Weighted MRI, or performing pharmacokinetic modeling of the Dynamic Contrast-Enhanced MRI).

Relevant development of the codes related to ADC calculation can be found in DICOM Correction Proposal (CP). These codes are expected to become part of the standard in Spring 2017.

For now, the best place to start is (select pm-schema in the Validation schema selector) that you can use to choose an existing example and modify it to tailor to your use case.

Searching for codes outside DICOM

To find a suitable code in an existing terminology, you will need to know what terminology to search, and you will need a tool that would facilitate your search.

DICOM has a preference for using SNOMED-CT codes. If you find a code in SNOMED-CT that would fill an important gap, but is not in the standard, you can propose inclusion of that new code into the standard. While looking for codes in SNOMED-CT, note the following guideline from the standard (PS3.16, Section 8.1.1arrow-up-right):

hashtag
8.1.1 Use of SNOMED Anatomic Concepts

In general, DICOM uses the anatomic concepts with the term "structure", rather than with the term "entire". This is an important distinction in SNOMED. "Entire" is a child concept to "structure", has a more restricted meaning, and typically is used in conjunction with treatments (e.g., "excision of entire right kidney"). It is used in distinction to other sibling children of the parent concept that may identify parts of the parent anatomic feature. Since imaging typically targets both the anatomic feature and the area around it, or sometimes just part of the anatomic feature, DICOM usually uses "structure" concepts that are more inclusive than the "entire" concepts.

However, keep in mind that:

  1. the process of contributing something into the DICOM standard is lengthy and can take a year before you see your change in the standard text;

  2. you will need to learn the procedures of contributing changes to the standard;

  3. although the SNOMED-CT codes included in the standard are , the ontology defined by SNOMED-CT is NOT covered by the exemption. Therefore, you will still need a secondary ontology if you are concerned about the license, and want to do reasoning on your data.

If a certain term is not found in SNOMED, it might be possible to add it. If you would like to request adding a new term in the context of DICOM, you can contact DICOM secretariat at , and they would then pass your request to the person responsible for the interactions with SNOMED. Also, each country has its SNOMED national member contact: , in case you want to make a non-DICOM related request.

hashtag
Using existing terminologies other than SNOMED

Therefore, it can be more practical to find a suitable term in an ontology other than SNOMED-CT.

In this regard, David Clunie, the long-time Editor of the DICOM standard, gave the following guidance on what terminologies to consider when a gap in the standard is identified:

[...] we (DICOM) use FMA then NeuroNames as a fallback when there are no appropriate SNOMED codes (yet), and have contacts with each of the appropriate groups to extend the schemes as necessary. We have not used RadLex for anatomy, since it is all/mostly(?) in FMA anyway (and if I recall correctly, was derived from it, since the original RadLex protagonists had no interest in reinventing that wheel).

If you need to automate anatomical code mapping, consider using the UMLS as a tool ... frequently both SNOMED and FMA terms map to a common UMLS code which helps a lot.

You can also use the FMAIDs included in the RadLex ontology () to map from RadLex back to FMA (or the reverse, since I think the FMA OWL file also includes the RadLex RIDs), then to UMLS and on to SNOMED, and indeed then undo the pre-coordinated laterality (if necessary) using the SNOMED hierarchy.

To search existing terminologies, you can consider using the following tools that search across different ontologies:

With both of these search engines you have an option of the advanced search to restrict the terms to a specific ontology.

There are also some search tools that provide searches for the individual ontologies (such as FMA), but in some instances their search capabilities are not flexible enough, and as such we recommend BioPortal and OLS. Unfortunately, neither BioPortal nor OLS include Neuronames, so you will need to use the specialized search tool for that ontology: .

Here is an illustrative example of searching for a term "anterior cingulate gyrus", which is not included in DICOM (note that you can use AnatomicRegionModifier to encode laterality of the structure).

  1. Using BioPortal, go to the , put the search term in the search box, and specify FMA in the "Ontologies" selector:

The search is successful, leading to , which includes the FMA ID 61916. Coding scheme designator for FMA is FMA, so the you can use the following code to describe the item:

(61916, FMA, "Anterior cingulate gyrus")

  1. Using OLS, you can , and for the same term, which :

Note that OLS is (as of writing this) using a "slimmed down version of FMA", but for common purposes perhaps this should still be sufficient.

hashtag
References

  • Definition of post-coordinated codes from UMLS:

C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: \ 
C: drive is not shared. Please share it in Docker for Windows Settings.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.
$ docker pull qiicr/dcmqi
Using default tag: latest
latest: Pulling from qiicr/dcmqi
38892065247a: Already exists
87b645034784: Pull complete
c72dd60da47b: Pull complete
01a53946a0eb: Pull complete
8bb93fc0167f: Pull complete
0cea230bb5f0: Pull complete
4b26feab9bc2: Pull complete
82b0182ab925: Pull complete
3af6a0b06e1b: Pull complete
Digest: sha256:af03e96c28b92d0108453da546217a38665404a2ec327478ce68eaef6b092b14
Status: Downloaded newer image for qiicr/dcmqi:latest
$ docker run qiicr/dcmqi itkimage2segimage --help
-v <HOST_DIR>:<CONTAINER_DIR>
$ mkdir docker_test
$ pwd
/Users/fedorov/docker_test
$ ls
pm-example-float.json     
pm-example-float.nrrd     
pm-example-slice.dcm
$ docker run -v /Users/fedorov/docker_test:/tmp qiicr/dcmqi itkimage2paramap \ 
   --inputImage /tmp/pm-example-float.nrrd \
   --inputMetadata /tmp/pm-example-float.json \
   --outputDICOM /tmp/docker_output_paramap.dcm \
   --inputDICOM /tmp/pm-example-slice.dcm

Input image size: [256, 256, 20]
Directions: 0.999981 -0.00540165 -0.00298377
0.00480058 0.984755 -0.173879
0.00387751 0.173861 0.984763

(99QIICR,DWMPxxxxx1,Source image diffusion b-value): NUMERIC: 0, Units: (UCUM,s/mm2,seconds per square millimeter)), Float value(s): <none>
(99QIICR,DWMPxxxxx1,Source image diffusion b-value): NUMERIC: 1400, Units: (UCUM,s/mm2,seconds per square millimeter)), Float value(s): <none>
Saved parametric map as /tmp/docker_output_paramap.dcm
Introduce a new coding scheme: if you follow this option, you can either reuse an existing terminology which is not listed in the DICOM standard herearrow-up-right, or define your own terminology and set of codes. You can still produce the data that is harmonized with other sources, but to achieve this you will need to make sure all "data producers" follow your coding scheme! This approach is suitable when you are working on an application where no established terminology exists (e.g., no consensus within your community is reached), or when semantic interoperability is not a priority.
PS3.16 Section 8arrow-up-right
Use one of the codes defined in DICOM
search one of the existing terminologies/ontologies for a suitable code
AnatomicRegionSequence (when applicable)
  • AnatomicRegionModifierSequence (when applicable)

  • DerivationCode: select code from CID 7203arrow-up-right, or introduce a private codearrow-up-right.
  • AnatomicRegionSequence and Modifier (optional): follow the same guidelines as discussed for Segmentation

    anatomic codes selection.

  • MeasurementMethodCode (optional): code describing the model used for deriving the quantity.

  • ModelFittingMethodCode (optional): code describing the model fitting method.

  • Parametric map
    a web applicationarrow-up-right
    CID 7150arrow-up-right
    CID 7151arrow-up-right
    part 16 of the standardarrow-up-right
    CID 2 Anatomic Modifierarrow-up-right
    CID 4 Anatomic Regionarrow-up-right
    The web applicationarrow-up-right
    Systematized Nomenclature of Medicine Clinical Terms (SNOMED® CT)arrow-up-right
    hierarchy of the entities related to the Liver code in the SNOMED CT Browserarrow-up-right
    SNOMED CT licensearrow-up-right
    this blog postarrow-up-right
    itkimage2paramap converterarrow-up-right
    TID 7180arrow-up-right
    private codearrow-up-right
    Unified Code of Units of Measurement (UCUM)arrow-up-right
    CID 7181arrow-up-right
    Part 16 Section 7.2.2arrow-up-right
    CP-1665arrow-up-right
    this web applicationarrow-up-right

    "Private" coding schemes

    While DICOM allows for reuse of the codes defined in other terminologies, such as SNOMED, as well as those defined in the DICOM standard itself, so called “private” codes can also be defined by the creator of the object, when no standard codes are available. Such private codes are distinguished by a coding scheme designator that must start with the “99” prefix.

    As an example, consider Dr. Smith developed a new model for estimate ADC from diffusion MRI. Since the method is new, there is no standard code for it. Dr. Smith then can establish her own coding scheme designator, say, 99DRSMITH, and define a new code as the following triple:

    ('SADC123','99SMITH','Smith Diffusion Model').

    Segmentations

    dcmqi provides command line tools to convert rasterized segmentations stored in commonly used research formats, such as NRRD or NIfTI, into DICOM Segmentation image storage (DICOM Segmentation) object.

    DICOM Segmentations are organized as a lists of segments, where each segment corresponds to a separate object/label being segmented. Segments can overlap (i.e., a single voxel of the source image can have multiple labels). Each segment contains information about what it describes, and what method was used to generate it.

    To perform the conversion to DICOM, the segmentation (image volume representing the labeling of the individual image voxels) needs to be accompanied by a JSON file that describes segmentation metadata (such as the one in this examplearrow-up-right), and by the DICOM dataset corresponding to the source image data being segmented. The source DICOM dataset is used to populate metadata attributes that are inherited by the segmentation (i.e., composite context), such as information about patient and imaging study.

    Conversion from DICOM Segmentation to research formats produces one file per segment saving the labeled image raster in the research format, such as NRRD or NIfTI, and a metadata JSON file.

    Measurements

    dcmqi provides command line tools to convert lists of measurements calculated from the images for the regions defined by rasterized segmentations into DICOM representation. Specifically, the DICOM representation suitable for such data is DICOM Structured Reporting (SR) Template ID 1500arrow-up-right.

    Each measurement is associated with a specific segment in the corresponding DICOM Segmentation object. For each measurements, Quantity, Units and Derivation (when appropriate) must be specified as coded tuples. Multiple measurements can be assigned in a list for the individual segment.

    At the moment, the measurements must be specified in a JSON file, such as the one shown in this examplearrow-up-right. It is in our plansarrow-up-right to provide support of the CSV format for bi-directional conversion of the measurements data.

    You can use this online validator to check if the JSON file you are passing to the converter is conforming to the schema: https://qiicr.org/dcmqi/#/validatorsarrow-up-right.

    exempt from the licensing constraints of SNOMED-CTarrow-up-right
    http://www.dicomstandard.org/contact/secretariat/arrow-up-right
    http://www.snomed.org/our-customers/membersarrow-up-right
    http://purl.bioontology.org/ontology/RADLEXarrow-up-right
    BioPortalarrow-up-right
    EMBL-EBI Ontology Lookup Service (OLS)arrow-up-right
    http://braininfo.rprc.washington.edu/arrow-up-right
    Advanced searcharrow-up-right
    this entryarrow-up-right
    select the specific ontologyarrow-up-right
    search specifically in FMAarrow-up-right
    will result in the same codearrow-up-right
    https://utsreport.nlm.nih.gov/umlsreport/sourceDocs/postcoordinated.htmlarrow-up-right

    tid1500reader

    This tool can be used to convert a DICOM Structured Report object that follows template TID1500arrow-up-right into a JSON representation of the measurements. The converter was developed and tested specifically to recognize SR TID1500 objects that store measurements derived from volumetric rasterized segmentations. It will not work for other use cases of TID1500.

    hashtag
    Usage

       --outputMetadata <std::string>
         File name of the JSON file that will keep the metadata and
         measurements information.
    
       --inputDICOM <std::string>
         File name of the DICOM SR TID1500 object.

    hashtag
    Example objects

    Build from source

    dcmqi should build on Linux, Mac and Windows. You can confirm this is the case for the current version of the code by looking at the continuous integration (CI) platforms.

    • Linux build:

    • Windows build:

    • Mac OS X build:

    Note that the failure icons indicate that something in the dashboard script failed - this could be build error, failed test, failed artifact upload, or failed download of a prerequisite. You will need to check the console output for the specific platform to see if there are problems with the build.

    hashtag
    Checking out the source code

    We use git/github to maintain the repository. You can clone the repository using this command:

    git clone https://github.com/QIICR/dcmqi.git

    If you are not familiar with git, there are many guides to help you get started, such as this one that should take about 10 minutes: .

    hashtag
    Prerequisites

    1. developer environment for your platform (compiler, git)

    2. recent version of

    Note that you can also see the specific components and steps needed to build dcmqi by looking at the CI configuration scripts ( for Lunux, for Mac, and for Windows).

    If you would like to run dcmqi tests, you will need to install few extra tools for validating JSON files. These tools depend on npm installed as part of , and are the following:

    Both can be installed with npm as follows:

    hashtag
    Superbuild approach

    With the superbuild approach, all of the will be build as part of the build process. This approach is the easiest, but also most time-consuming. 1. create dcmqi-superbuild directory 2. configure the project by running cmake <dcmqi source directory> from dcmqi-superbuild 3. run make from the superbuild directory

    hashtag
    Non-superbuild approach

    You can use this approach if you have (some of) the dependency libraries already built on your platform. dcmqi dependencies are

    To reuse builds of those libraries, you will need to pass the corresponding variables to cmake as shown in the example below:

    hashtag
    Troubleshooting

    • Under certain conditions, line endings may be incorrectly initialized for your platform by the checkout process (reported by @CJGoch in ), which may result in errors like below:

    To resolve this, check your global git settings. If you have autocrlf set, you may try setting it to auto.

    3D Slicer extension

    You can access the functionality provided by dcmqi in 3D Slicer using QuantitativeReporting extension. Specifically, you can use QuantitativeReporting to prepare segmentations of DICOM imaging series, define semantics of the segmentation, calculate measurements and export the result as DICOM. You can also load DICOM segmentations, measurement structured reports and parametric maps with QuantitativeReporting, which is using dcmqi to support data conversion. See user guide of QuantitativeReporting for further details.

    dcmqi itself is also available as a 3D Slicer extension. It provides the libraries and converters that can be integrated with other 3D Slicer extensions. If you are developing an extension for 3D Slicer, you can access dcmqi converters by specifying dependency on dcmqi 3D Slicer extension.

    should be available as an extension in the nightly version of , starting November 2016. We always suggest that you use the latest (nightly) version of the software when you try it for the first time.

    Download the latest nightly release for your platform from .

    Do NOT use installers tagged as "Stable Release"!

    After downloading, follow the installation procedure for your platform.

    If you use Mac, make sure you move the Slicer application to the Applications folder on your computer before launching it!

    Once installed, open 3D Slicer Extension Manager by clicking the icon as shown below.

    Search for QuantitativeReporting and install the extension by clicking the INSTALL button.

    hashtag
    Upgrade

    It is currently not possible to upgrade an extension without upgrading the 3D Slicer application.

    If you need to upgrade the software, download the latest nightly release of 3D Slicer and install QuantitativeReporting as explained above.

    itkimage2segimage

    itkimage2segimage tool can be used to save the volumetric segmentation(s) stored as labeled pixels using any of the formats supported by ITK, such as NRRD or NIFTI, as a DICOM Segmentation Object (further referred to as SEG).

    hashtag
    Usage

    hashtag
    Detailed usage

    Most of the effort will be required to populate the content of the meta-information JSON file. You can use the that provides a user interface to help with populating the content of the metadata JSON file. The details are discussed below.

    The structure of the metadata JSON is defined by JSON-Schema file. Interpretation of JSON-Schema may require some effort, especially considering that this particular file uses externally defined items. It may be easier to start with an example JSON file that "instantiates" this schema, such as .

    In the following, we will guide you through the contents of this file - line by line.

    This opening line references the schema this parameter file should conform to. Make sure you include this line without changes!

    These lines correspond to the metadata attributes that will be populated in the resulting DICOM SEG object. It is your choice how you want to populate those. There are certain constraints on the values of these attributes. If those constraints are not met, converter will fail. In the future, we will provide instructions for validating your meta-information file.

    The remainder of the file is a nested list (top-level list corresponds to the input segmentation files, and the inner list corresponds to the individual segments within each file) that specifies metadata attributes for each of the segments that are present in the input segmentation files.

    For each of the segments, you will need to specify the following attributes that are mandatory:

    labelID defines the value of the segment in the segmentation file that will be assigned attributes listed.

    WARNING: labelID is not stored in the output DICOM! The sole purpose of this attribute is to establish the connection between the labels encoded in the input ITK files and the metadata describing those labels (segments). The output DICOM files will have segments numbered consecutively starting from 1, and labelID should not be used to encode the type of structure being segmented. What the segment actually represents is indicated by a set of "codes": SegmentedPropertyCategoryCodeSequence, SegmentedPropertyTypeCodeSequence, and SegmentedPropertyTypeModifierCodeSequence (optionally), as discussed below.

    Note that if you really wanted to preserve a particular identifier from a source format, though DICOM SegmentNumber is required to start from 1 and increase by 1 (and is used for internal reference within the segment instance), SegmentLabel can be anything that fits within a 64 character string.

    E.g., one could write:

    and

    or

    or

    or, what the standard recommends but does not mandate (use CodeMeaning of SegmentedPropertyTypeCodeSequence):

    Note that the anatomic region (where the primary tumor is) can be coded separately.

    SegmentDescription is a short free-text description of the segment.

    SegmentAlgorithmType can be assigned to MANUAL, SEMIAUTOMATIC or AUTOMATIC. If the value of this attribute is not MANUA, SegmentAlgorithmName attribute is required to be initialized!

    This attribute should be used to assign short name of the algorithm used to perform the segmentation.

    This attribute can be used to specify the RGB color with the recommended. Alternatively, RecommendedDisplayCIELabValue attribute can be used to specify the color in CIELab color space.

    SegmentedPropertyCategoryCodeSequence and SegmentedPropertyCategoryCodeSequence are attributes that should be assigned code tuples to describe the meaning of what is being segmented.

    Each code tuple consists of the three components: CodeValue, CodingSchemeDesignator and CodeMeaning. CodingSchemeDesignator defines the "authority", or source of the code. Each CodeValue should be unique for a given CodingSchemeDesignator. CodeMeaning is a human-readable meaning of the code. DICOM defines several coding schemes recognized by the standard listed .

    The task of selecting a code to describe a given segment may not be trivial, since there are implicit constraints/expectations on the values of these codes. As an example, the possible values of SegmentedPropertyTypeCodeSequence are predicated on the value of the SegmentedPropertyCategoryCodeSequence. It is also possible to define SegmentedPropertyTypeModifierCodeSequence that can be used , for example, to define the laterality. In some situations, it is appropriate or required to also specify anatomical location of the segmentation (e.g., organ a tumor was segmented). The latter can be achieved using AnatomicRegionSequence and AnatomicRegionModifierSequence coded attributes.

    To simplify selection of codes for defining semantics of the segment, we provide a that can be used to browse supported codes and automatically generate the corresponding section of the JSON file. When no suitable codes can be found, it is also permissible to define so called private, or local, coding schemes (see ).

    You can also see of the documentation discussing the various options of searching for the coded terms that are available to you.

    segimage2itkimage

    hashtag
    segimage2itkimage

    This tool can be used to convert DICOM Segmentation into volumetric segmentations stored as labeled pixels using research format, such as NRRD or NIfTI, and meta information stored in the JSON file format.

    hashtag
    Usage

    hashtag
    Examples of DICOM Segmentation objects

    If you are looking for publicly available examples of segmentation objects, or other DICOM images, you should check out (IDC) (see documentation ).

    Here are some representative examples of DICOM Segmentations:

    • Segmentation of a lung nodule from the collection

      • viewer link:

    • TotalSegmentator segmentation results from the collection

    To download the files for the studies listed above:

    1. install idc-index package with pip install --upgrade idc-index

    2. download the study by specifying StudyInstanceUID (listed in the URLs above after the '=' sign) with idc download 1.2.840.113654.2.55.256011367872217445472654886973509892961

    tid1500writer

    This tool can be used to save measurements calculated from the image over a volume defined by image segmentation into a DICOM Structured Report that follows template TID1500arrow-up-right.

    hashtag
    Usage

    hashtag
    Usage details

    Most of the effort will be required to populate the content of the meta-information JSON file. Its structure is defined by JSON-Schema file. Interpretation of JSON-Schema may require some effort, especially considering that this particular file uses externally defined items. It may be easier to start with an example JSON file that "instantiates" this schema, such as .

    In the following, we will guide you through the contents of this file - line by line.

    This opening line references the schema this parameter file should conform to. Make sure you include this line without changes!

    These lines define top-level attributes of the resulting DICOM object. You can change these to adjust to your needs, subject to some constraints that are not covered here for now.

    These two items contain lists of file names that should exist in the directories specified by the --compositeContextDataDir and --imageLibraryDataDir, correspondingly. You should include the file with the DICOM Segmentation object defining the segmented region in the compositeContext attribute!

    These are the attributes of either the person that performed the measurements. If you want to list the device instead of a person, it is also possible, but should be done differently. Please ask about details.

    Values for VerificationFlag can be one of VERIFIED or UNVERIFIED. CompletionFlag values are either PARTIAL or COMPLETE.

    activitySession attribute can be used to encode session number, when, for example, the same structure was segmented multiple times. timePoint can be used in the situation of longitudinal tracking of the measurements.

    This is the beginning of the structure where the actual measurements are stored. The measurements are stored hierarchically, and can include 1 or more measurement groups, where each measurement group encodes one or more measurement items.

    For each measurement group, you will need to define certain common attributes shared by all measurement items within that group:

    • TrackingIdentifier is a human-readable string naming the group

    • ReferencedSegment is the ID of the segment within the DICOM segmentation object that defines the region used to calculate the measurement.

    • SourceSeriesForImageSegmentation

    Finally, measurementItems contains the list of individual measurement. Each measurement is encoded by specifying the following properties:

    • value: the number, the actual measurement

    • quantity: code triplet encoding the quantity.

    • units

    The most challenging part of encoding measurements is arguably the process of identifying the codes corresponding to the quantity and derivation modifier (if necessary). You may want to read the discussion on this topic on p.19 of . For practical purposes, you can study the measurements encoded in this example and follow the pattern: . In the future, we will add more details, more examples, and more user-level tools to simplify the process of selecting such codes.

    Once you generated the output DICOM object using tid1500writer tool, it is always a very good idea to validate the resulting object. For this purpose we recommend DicomSRValidator tool from the :

    You can also examine the content of the resulting document with various tools such as from the suite

    or (more colorful!) from

    You can also use in the to conveniently view the content without having to use the terminal.

    hashtag
    Examples

    hashtag
    Encoding measurements over segmentation of liver in CT

    *

    itkimage2paramap

    itkimage2paramap can be used to convert a parametric map provided in any of the formats supported by ITK, such as NRRD or NIFTI, as a DICOM Parametric Map image object.

    hashtag
    Usage

    hashtag

       --skip <int>
         Skip empty slices while encoding segmentation image. By default, empty
         slices will not be encoded, resulting in a smaller output file size.
         (value: 1)
    
       --inputImageList <std::vector<std::string>>
         Comma-separated list of file names of the segmentation images in a
         format readable by ITK (NRRD, NIfTI, MHD, etc.). Each of the
         individual files can contain one or more labels (segments). Segments
         from different files are allowed to overlap. See documentation for
         details.
    
       --inputDICOMDirectory <std::string>
         Directory with the DICOM files corresponding to the original image
         that was segmented.
    
       --inputDICOMList <std::vector<std::string>>
         Comma-separated list of DICOM images that correspond to the original
         image that was segmented. This means you must have access to the
         original data in DICOM in order to use the converter (at least for
         now).
    
       --outputDICOM <std::string>
         File name of the DICOM SEG object that will store the result of
         conversion.
    
       --inputMetadata <std::string>
         JSON file containing the meta-information that describes the
         measurements to be encoded. See documentation for details.
         
       --useLabelIDAsSegmentNumber
         Use label IDs from ITK images as Segment Numbers in DICOM. Only works
         if label IDs are consecutively numbered starting from 1, otherwise
         conversion will fail. (value: 0)
       --inputImageLibraryDirectory <std::string>
         Location of input DICOM Data to be used for populating image library.
         See documentation.
    
       --inputCompositeContextDirectory <std::string>
         Location of input DICOM Data to be used for populating composite
         context. See documentation.
    
       --outputDICOM <std::string>
         File name of the DICOM SR object that will store the result of the
         conversion.
    
       --inputMetadata <std::string>
         JSON file that contains the list of mesurements and other meta data
         items that can be specified by the user. See documentation for
         details.
    measurements over liver segmentationarrow-up-right
    measurements for multiple regions segmented from PETarrow-up-right
    helper web applicationarrow-up-right
    thisarrow-up-right
    this onearrow-up-right
    in PS3.16 Section 8arrow-up-right
    helper web applicationarrow-up-right
    PS3.16 Section 8.2arrow-up-right
    the dedicated section

    viewer link: https://viewer.imaging.datacommons.cancer.gov/v3/viewer/?StudyInstanceUIDs=1.2.840.113654.2.55.256011367872217445472654886973509892961arrow-up-right

    NCI Imaging Data Commonsarrow-up-right
    herearrow-up-right
    DICOM-LIDC-IDRI-Nodulesarrow-up-right
    https://viewer.imaging.datacommons.cancer.gov/v3/viewer/?StudyInstanceUIDs=1.3.6.1.4.1.14519.5.2.1.6279.6001.101324598070011890446155612648arrow-up-right
    TotalSegmentator-CT-Segmentationsarrow-up-right
    Detailed usage

    Most of the effort will be required to populate the content of the meta-information JSON file. Its structure is defined by thisarrow-up-right JSON-Schema file. Interpretation of JSON-Schema may require some effort, especially considering that this particular file uses externally defined items. It may be easier to start with an example JSON file that "instantiates" this schema, such as this onearrow-up-right.

    In the following, we will guide you through the contents of this file - line by line.

    These lines correspond to the metadata attributes that will be populated in the resulting DICOM Parametric Map image object. It is your choice how you want to populate those. There are certain constraints on the values of these attributes. If those constraints are not met, converter will fail. In the future, we will provide instructions for validating your meta-information file.

    QuantityValueCode, MeasurementUnitsCode, MeasurementMethodCode, AnatomicRegionSequence are attributes (code tuples) to describe the meaning the pixels stored in this parametric map. AnatomicRegionSequence, DerivedPixelContrast, FrameLaterality are the only attributes that are required. All others are optional.

    Each code tuple consists of the three components: CodeValue, CodingSchemeDesignator and CodeMeaning. CodingSchemeDesignator defines the "authority", or source of the code. Each CodeValue should be unique for a given CodingSchemeDesignator. CodeMeaning is a human-readable meaning of the code. DICOM defines several coding schemes recognized by the standard listed in PS3.16 Section 8arrow-up-right.

    {
      "@schema": "https://raw.githubusercontent.com/qiicr/dcmqi/master/doc/schemas/seg-schema.json#",
      "ContentCreatorName": "Doe^John",
      "ClinicalTrialSeriesID": "Session1",
      "ClinicalTrialTimePointID": "1",
      "ClinicalTrialCoordinatingCenterName": "BWH",
      "SeriesDescription": "Segmentation",
      "SeriesNumber": "300",
      "InstanceNumber": "1",
      "segmentAttributes": [
        [
          {
            "labelID": 1,
    SegmentedPropertyCategoryCodeSequence = (M-01000, SRT, "Morphologically
    Altered Structure")
    SegmentedPropertyTypeCodeSequence = (M-80003, SRT, "Neoplasm, Primary")
    SegmentNumber=1
    SegmentLabel = 255
    SegmentLabel = "primary tumor"
    SegmentLabel = "primary tumor (255)"
    SegmentLabel = "Neoplasm, Primary"
            "SegmentDescription": "Liver Segmentation",
            "SegmentAlgorithmType": "SEMIAUTOMATIC",
            "SegmentAlgorithmName": "SlicerEditor",
            "recommendedDisplayRGBValue": [
              221,
              130,
              101
            ]
            "SegmentedPropertyCategoryCodeSequence": {
              "CodeValue": "T-D0050",
              "CodingSchemeDesignator": "SRT",
              "CodeMeaning": "Tissue"
            },
            "SegmentedPropertyTypeCodeSequence": {
              "CodeValue": "T-62000",
              "CodingSchemeDesignator": "SRT",
              "CodeMeaning": "Liver"
            },
       -t <nrrd|mhd|mha|nii|nifti|hdr|img>,  --outputType <nrrd|mhd|mha|nii
          |nifti|hdr|img>
         Output file format for the resulting image data. (default: nrrd)
    
       -p <std::string>,  --prefix <std::string>
         Prefix for output file.
    
       --outputDirectory <std::string>
         Directory to store individual segments saved using the output format
         specified files. When specified, file names will contain prefix,
         followed by the segment number.
    
       --inputDICOM <std::string>
         File name of the input DICOM Segmentation image object.
         
       --mergeSegments
         Save all segments into a single file. When segments are
         non-overlapping, output is a single 3D file. If overlapping segments
         are identified, multiple 3D files will be created each containing
         non-overlapping segments. Metadata JSON files will be created for each
         such 3D file. (value: 0)
       --inputDICOM <std::string>
         File name of the DICOM image file that should be used to populate the
         composite context (attributes related to the patient and imaging
         study).
    
       --outputDICOM <std::string>
         File name of the DICOM Parametric map object with the result of the
         conversion.
    
       --inputMetadata <std::string>
         File name of the JSON files containing metadata attributes.
    
       --inputImage <std::string>
         File name of the parametric map image in a format readable by ITK
         (NRRD, NIfTI, MHD, etc.).
    {
      "@schema": "https://raw.githubusercontent.com/qiicr/dcmqi/master/doc/schemas/pm-schema.json#",
      "SeriesDescription": "Apparent Diffusion Coefficient",
      "SeriesNumber": "701",
      "InstanceNumber": "1",
      "BodyPartExamined": "PROSTATE",
      "QuantityValueCode": {
        "CodeValue": "113041",
        "CodingSchemeDesignator": "DCM",
        "CodeMeaning": "Apparent Diffusion Coefficient"
      },
      "MeasurementUnitsCode": {
        "CodeValue": "um2/s",
        "CodingSchemeDesignator": "UCUM",
        "CodeMeaning": "um2/s"
      },
      "MeasurementMethodCode": {
        "CodeValue": "DWMPxxxx10",
        "CodingSchemeDesignator": "99QIICR",
        "CodeMeaning": "Mono-exponential diffusion model"
      },
      "SourceImageDiffusionBValues": [
        "0",
        "1400"
      ],
      "AnatomicRegionSequence": {
        "CodeValue": "T-9200B",
        "CodingSchemeDesignator": "SRT",
        "CodeMeaning": "Prostate"
      },
      "FrameLaterality": "U",
      "RealWorldValueSlope": 1,
      "DerivedPixelContrast": "ADC"
    }
    zlibarrow-up-right
    https://guides.github.com/activities/hello-world/arrow-up-right
    cmakearrow-up-right
    circle.ymlarrow-up-right
    .travis.ymlarrow-up-right
    appveyor.ymlarrow-up-right
    Node.jsarrow-up-right
    jsonlintarrow-up-right
    ajv-cliarrow-up-right
    dependenciesarrow-up-right
    DCMTKarrow-up-right
    ITKarrow-up-right
    SlicerExecutionModelarrow-up-right
    https://github.com/QIICR/dcmqi/issues/14arrow-up-right
    Circle CI
    is the SeriesInstanceUID of the original image series on which the segmentation was created.
  • segmentationSOPInstanceUID is the SOPInstanceUID of the DICOM Segmentation object.

  • Finding is a triplet of (code, codingSchemeDesignator, codeMeaning) defining the finding over which the measurement is being performed. You can read more about how these triples are defined herearrow-up-right.

  • : code triplet defining the units corresponding of the value. DICOM is using the Unified Code for Units of Measure (UCUM) system for encoding units.
  • derivationModifier: code triplet encoding the quantity modifier.

  • thisarrow-up-right
    this onearrow-up-right
    this paperarrow-up-right
    https://github.com/QIICR/dcmqi/blob/master/doc/sr-tid1500-ct-liver-example.jsonarrow-up-right
    Pixelmed toolkitarrow-up-right
    dcsrdumparrow-up-right
    dicom3toolsarrow-up-right
    dsrdumparrow-up-right
    DCMTKarrow-up-right
    dicom-dump pluginarrow-up-right
    Atom editorarrow-up-right
    image
    image
    QuantitativeReportingarrow-up-right
    3D Slicerarrow-up-right
    http://download.slicer.orgarrow-up-right

    Parametric maps

    dcmqi provides command line tools to convert results of post-processing of the image data, such as by applying certain model to the data, into DICOM format. As an example, Apparent Diffusion Coefficient (ADC) maps derived by fitting various models to the Diffusion-Weighted Magnetic Resonance Imaging (DW-MRI) data have been shown promising in characterizing aggressiveness of prostate cancer. The result of conversion is DICOM Parametric map objectarrow-up-right.

    Mandatory metadata that needs to be specified to enable conversion include:

    • Quantity being measured

    • Units of the quantity being measured

    • Measurement method

    Each of these items, in addition to some other attributes, must be specified using coded values. An example of the metadata file is available .

    paramap2itkimage

    This tool can be used to convert a DICOM Parametric Map Image object into ITK image format, and generate a JSON file holding meta information.

    hashtag
    Usage

       -t <nrrd|mhd|mha|nii|nifti|hdr|img>,  --outputType <nrrd|mhd|mha|nii
          |nifti|hdr|img>
         Output ITK format for the output image. (default: nrrd)
    
       --outputDirectory <std::string>
         Directory to store parametric map in an ITK format, and the JSON
         metadata file.
    
       --inputDICOM <std::string>
         File name of the DICOM Parametric map image.

    hashtag
    Examples of DICOM Parametric map objects

    You can experiment with the converter using the following objects:

    • (zip archive)

    sudo npm install jsonlint -g
    sudo npm install ajv-cli -g
    cmake DITK_DIR:PATH=C:\ITK-install \ 
      -DSlicerExecutionModel_DIR:PATH=C:\SlicerExecutionModel\SlicerExecutionModel-build \
      -DDCMTK_DIR:PATH=C:\DCMTK-install\cmake  \
      -DZLIB_ROOT:PATH=c:\zlib-install \ 
      -DZLIB_INCLUDE_DIR:PATH=c:\zlib-install\include \ 
      -DZLIB_LIBRARY:FILEPATH=c:\zlib-install\lib\zlib.lib \
      <dcmqi source directory>
    dcmqi/dcmqi-build/apps/seg/itkimage2segimageCLP.h:214:1: error: stray ‘\’ in program
    {
    ^
    dcmqi/dcmqi-build/apps/seg/itkimage2segimageCLP.h:214:3: warning: missing terminating " character
    {
    ^
    dcmqi/dcmqi-build/apps/seg/itkimage2segimageCLP.h:214:1: error: missing terminating " character
    {
    ^
    {
      "@schema": "https://raw.githubusercontent.com/qiicr/dcmqi/master/doc/schemas/sr-tid1500-schema.json#",
      "SeriesDescription": "Measurements",
      "SeriesNumber": "1001",
      "InstanceNumber": "1",
      "compositeContext": [
        "liver.dcm"
      ],
    
      "imageLibrary": [
        "01.dcm",
        "02.dcm",
        "03.dcm"
      ],
      "observerContext": {
        "ObserverType": "PERSON",
        "PersonObserverName": "Reader1"
      },
      "VerificationFlag": "VERIFIED",
      "CompletionFlag": "COMPLETE",
      "activitySession": "1",
      "timePoint": "1",
      "Measurements": [
        {
          "MeasurementGroup": {
            "TrackingIdentifier": "Measurements group 1",
            "ReferencedSegment": 1,
            "SourceSeriesForImageSegmentation": "1.2.392.200103.20080913.113635.2.2009.6.22.21.43.10.23431.1",
            "segmentationSOPInstanceUID": "1.2.276.0.7230010.3.1.4.0.42154.1458337731.665796",
            "Finding": {
              "codeValue": "T-D0060",
              "codingSchemeDesignator": "SRT",
              "codeMeaning": "Organ"
            },
            "measurementItems": [
              {
                "value": "37.3289",
                "quantity": {
                  "codeValue": "122713",
                  "codingSchemeDesignator": "DCM",
                  "codeMeaning": "Attenuation Coefficient"
                },
                "units": {
                  "codeValue": "[hnsf'U]",
                  "codingSchemeDesignator": "UCUM",
                  "codeMeaning": "Hounsfield unit"
                },
                "derivationModifier": {
                  "codeValue": "R-00317",
                  "codingSchemeDesignator": "SRT",
                  "codeMeaning": "Mean"
                }
              },
    bash DicomSRValidator.sh <sr_object>
    herearrow-up-right
    ADC map image of the prostatearrow-up-right
    TravisCI

    User guide

    The following section is intended for the users of command-line tools provided by dcmqi.

    We are continuously working on the content of this guide. It will change and improve in the future.

    Your feedback is very important in improving the quality of this guide.

    To contribute your feedback, you can initiate a discussion for a specific paragraph of text. If you mouse over the paragraph while reading the web version of the book on gitbooks.io, you should see a + symbol to the right of the paragraph you are reading. You can click it and initiate a new discussion, as shown in the screenshot below.

    Once you post your feedback, developers of this guide will receive automatic notifications, and will respond to your suggestions or concerns.

    Note that you will need to sign in before you can participate in a discussion (gitbook accepts Facebook, Twitter, Google and Github authentication).

    Command line tools usage

    dcmqi provides a set of command line tools that perform conversion between research formats and .

    DICOMarrow-up-right
    Build status