Skip to content

Commit a4c27dd

Browse files
authored
Add doc pages on context groups and dcmterms link (#408)
1 parent b351fb5 commit a4c27dd

4 files changed

Lines changed: 55 additions & 14 deletions

File tree

docs/ann.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ contains. The required metadata elements include:
3737
* An ``annotated_property_category`` and ``annotated_property_type``
3838
(:class:`highdicom.sr.CodedConcept`), coded values (see :ref:`coding`)
3939
describing the category and specific structure that has been annotated.
40+
See :dcm:`CID 7151 <part16/sect_CID_7151.html>` and
41+
:dcm:`CID 8135 <part16/sect_CID_8135.html>` respectively for the associated
42+
context groups.
4043
* A ``graphic_type`` (:class:`highdicom.ann.GraphicTypeValues`) indicating the
4144
"form" of the annotations. Permissible values are ``"ELLIPSE"``, ``"POINT"``,
4245
``"POLYGON"``, ``"RECTANGLE"``, and ``"POLYLINE"``.

docs/coding.rst

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,27 @@ hash to the same value if you use them within sets or as keys in dictionaries.
127127
For equality and hashing, two codes are considered equivalent if they have the
128128
same coding scheme, and value, regardless of how their meaning is represented.
129129

130+
Context Groups
131+
--------------
132+
133+
Many places where codes are used in the standard are associated with a
134+
`Context Group`. These are sets of codes determined to be suitable for a
135+
particular purpose. Most are `extensible`, meaning you can choose codes
136+
outside the context group if you wish. However, it is best practice to use
137+
a code within the context group if a suitable code exists within it.
138+
139+
Context groups are have an identifier called a `CID`. For example, :dcm:`CID
140+
7150 <part16/sect_CID_7150.html>` is the context group containing codes to use
141+
to describe segmented properties categories in a DICOM segmentation and
142+
:dcm:`CID 7151 <part16/sect_CID_7151.html>` contains values for the more
143+
specific segmented property types. Note that this second example includes other
144+
CIDs recursively.
145+
130146
Finding Suitable Codes
131147
----------------------
132148

133149
The `pydicom` code dictionary allows searching for concepts via simple string
134-
matching. However, for more advanced searching it is generally advisable to
135-
search the documentation for the coding scheme itself.
150+
matching. You can also search with context groups.
136151

137152
.. code-block:: python
138153
@@ -146,3 +161,24 @@ search the documentation for the coding scheme itself.
146161
147162
print(codes.SCT.Liver)
148163
# Code(value='10200004', scheme_designator='SCT', meaning='Liver', scheme_version=None)
164+
165+
# Search within a context group (e.g. CID7150)
166+
print(codes.cid7150.dir())
167+
# ['AnatomicalStructure',
168+
# 'BodySubstance',
169+
# 'Function',
170+
# 'MorphologicallyAbnormalStructure',
171+
# 'PhysicalObject',
172+
# 'SpatialAndRelationalConcept',
173+
# 'Substance',
174+
# 'Tissue']
175+
176+
# Check whether a code lies within a context group
177+
print(codes.SCT.BodySubstance in codes.cid7150)
178+
# True
179+
180+
However, for more advanced searching it is generally advisable to search the
181+
documentation for the coding scheme itself. This
182+
`webpage <https://fedorov.github.io/dcmterms/terminology.html>`_ is a nice
183+
interactive tool for searching the terms and Context Groups defined within
184+
DICOM.

docs/seg.rst

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ description includes the following information:
6767
segment represents an anatomical structure, a tissue type, or an abnormality.
6868
This is passed as either a
6969
:class:`highdicom.sr.CodedConcept`, or a :class:`pydicom.sr.coding.Code`
70-
object.
70+
object. See
71+
:dcm:`CID 7150 <part16/sect_CID_7150.html>` for the associated context group.
7172
- **Segmented Property Type**: Another coded value that more specifically
7273
describes the segmented region, as for example a kidney or tumor. This is
7374
passed as either a :class:`highdicom.sr.CodedConcept`, or a
74-
:class:`pydicom.sr.coding.Code` object.
75+
:class:`pydicom.sr.coding.Code` object. See
76+
:dcm:`CID 7151 <part16/sect_CID_7151.html>` for the associated context group.
7577
- **Algorithm Type**: Whether the segment was produced by an automatic,
7678
semi-automatic, or manual algorithm. The valid values are contained within the
7779
enum :class:`highdicom.seg.SegmentAlgorithmTypeValues`.
@@ -112,7 +114,7 @@ representing a liver that has been manually segmented.
112114
liver_description = hd.seg.SegmentDescription(
113115
segment_number=1,
114116
segment_label='liver',
115-
segmented_property_category=codes.SCT.Organ,
117+
segmented_property_category=codes.SCT.AnatomicalStructure,
116118
segmented_property_type=codes.SCT.Liver,
117119
algorithm_type=hd.seg.SegmentAlgorithmTypeValues.MANUAL,
118120
display_color=hd.color.CIELabColor.from_string('red'),
@@ -244,7 +246,7 @@ everything else the same.
244246
liver_description = hd.seg.SegmentDescription(
245247
segment_number=1,
246248
segment_label='liver',
247-
segmented_property_category=codes.SCT.Organ,
249+
segmented_property_category=codes.SCT.AnatomicalStructure,
248250
segmented_property_type=codes.SCT.Liver,
249251
algorithm_type=hd.seg.SegmentAlgorithmTypeValues.MANUAL,
250252
)
@@ -321,7 +323,7 @@ example to use the labelmap segmentation type.
321323
liver_description = hd.seg.SegmentDescription(
322324
segment_number=1,
323325
segment_label='liver',
324-
segmented_property_category=codes.SCT.Organ,
326+
segmented_property_category=codes.SCT.AnatomicalStructure,
325327
segmented_property_type=codes.SCT.Liver,
326328
algorithm_type=hd.seg.SegmentAlgorithmTypeValues.MANUAL,
327329
)
@@ -387,7 +389,7 @@ segmentation type.
387389
liver_description = hd.seg.SegmentDescription(
388390
segment_number=1,
389391
segment_label='liver',
390-
segmented_property_category=codes.SCT.Organ,
392+
segmented_property_category=codes.SCT.AnatomicalStructure,
391393
segmented_property_type=codes.SCT.Liver,
392394
algorithm_type=hd.seg.SegmentAlgorithmTypeValues.MANUAL,
393395
)
@@ -475,7 +477,7 @@ always be present even if there is a single source frame.
475477
liver_description = hd.seg.SegmentDescription(
476478
segment_number=2,
477479
segment_label='liver',
478-
segmented_property_category=codes.SCT.Organ,
480+
segmented_property_category=codes.SCT.AnatomicalStructure,
479481
segmented_property_type=codes.SCT.Liver,
480482
algorithm_type=hd.seg.SegmentAlgorithmTypeValues.MANUAL,
481483
)
@@ -635,7 +637,7 @@ must have exactly one channel dimension with the descriptor being the
635637
liver_description = hd.seg.SegmentDescription(
636638
segment_number=1,
637639
segment_label='liver',
638-
segmented_property_category=codes.SCT.Organ,
640+
segmented_property_category=codes.SCT.AnatomicalStructure,
639641
segmented_property_type=codes.SCT.Liver,
640642
algorithm_type=hd.seg.SegmentAlgorithmTypeValues.MANUAL,
641643
)
@@ -734,7 +736,7 @@ For example:
734736
liver_description = hd.seg.SegmentDescription(
735737
segment_number=1,
736738
segment_label='liver',
737-
segmented_property_category=codes.SCT.Organ,
739+
segmented_property_category=codes.SCT.AnatomicalStructure,
738740
segmented_property_type=codes.SCT.Liver,
739741
algorithm_type=hd.seg.SegmentAlgorithmTypeValues.MANUAL,
740742
)
@@ -827,7 +829,7 @@ between the items of the ``source_images`` list and axis 0 of the segmentation
827829
liver_description = hd.seg.SegmentDescription(
828830
segment_number=1,
829831
segment_label='liver',
830-
segmented_property_category=codes.SCT.Organ,
832+
segmented_property_category=codes.SCT.AnatomicalStructure,
831833
segmented_property_type=codes.SCT.Liver,
832834
algorithm_type=hd.seg.SegmentAlgorithmTypeValues.MANUAL,
833835
)
@@ -1187,7 +1189,7 @@ representing a probabilistic segmentation of the liver.
11871189
liver_description = hd.seg.SegmentDescription(
11881190
segment_number=1,
11891191
segment_label='liver',
1190-
segmented_property_category=codes.SCT.Organ,
1192+
segmented_property_category=codes.SCT.AnatomicalStructure,
11911193
segmented_property_type=codes.SCT.Liver,
11921194
algorithm_type=hd.seg.SegmentAlgorithmTypeValues.MANUAL,
11931195
)

docs/volume.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ spatial metadata in the output object is correct.
630630
brain_description = hd.seg.SegmentDescription(
631631
segment_number=1,
632632
segment_label='brain',
633-
segmented_property_category=codes.SCT.Organ,
633+
segmented_property_category=codes.SCT.AnatomicalStructure,
634634
segmented_property_type=codes.SCT.Brain,
635635
algorithm_type=hd.seg.SegmentAlgorithmTypeValues.AUTOMATIC,
636636
algorithm_identification=algorithm_identification,

0 commit comments

Comments
 (0)