@@ -569,7 +569,7 @@ Segmentations from Volumes
569569In the simple cases we have seen so far, the geometry of the segmentation
570570``pixel_array `` has matched that of the source images, i.e. there is a spatial
571571correspondence between a given pixel in the ``pixel_array `` and the
572- corresponding pixel in the relevant source frame. While this covers most use
572+ corresponding pixel in the relevant source frame. While this covers many use
573573cases, DICOM SEGs actually allow for more general segmentations in which there
574574is a more complicated geometrical relationship between the source frames and
575575the segmentation masks. This could arise when a source image is resampled or
@@ -892,7 +892,7 @@ There are three possibilities here:
892892
893893If you require the "Derivation Image Sequence" be populated and you are using a
894894:class: `highdicom.Volume ` as input to the constructor, follow the method in the
895- previous section to match the geometry before passing to the constructor.
895+ ` seg-from-volume `_ section to match the geometry before passing to the constructor.
896896
897897Constructing SEG Images from a Total Pixel Matrix
898898-------------------------------------------------
@@ -922,10 +922,9 @@ tile size of the source image will be used (regardless of whether the
922922segmentation is represented at the same resolution as the source image).
923923
924924If you need to specify the plane positions of the image explicitly, you should
925- pass a single item to the ``plane_positions `` argument giving the location of
926- the top left corner of the full total pixel matrix, or alternatively (and more
927- conveniently) pass a :meth: `highdicom.Volume `. Otherwise, all the usual options
928- are available to you.
925+ pass a :meth: `highdicom.Volume ` or alternatively, pass single item to the
926+ ``plane_positions `` argument giving the location of the top left corner of the
927+ full total pixel matrix. Otherwise, all the usual options are available to you.
929928
930929.. code-block :: python
931930
@@ -1318,7 +1317,7 @@ attribute (5200, 9230) with the matching frame number, it is possible to
13181317determine the meaning of a certain segmentation frame. We will not describe the
13191318full details of this mechanism here.
13201319
1321- Instead, `highdicom ` provides a family of methods to help users reconstruct
1320+ Instead, `highdicom ` provides a family of methods to help users access
13221321segmentation masks from SEG objects in a predictable and more intuitive way. We
13231322recommend using these methods over the basic ``.pixel_array `` in nearly all
13241323circumstances.
@@ -1461,23 +1460,24 @@ whose descriptions meet certain criteria. For example:
14611460
14621461 .. _seg-get-pixels :
14631462
1464- Reconstructing Segmentation Masks By Source Frame or Source Instance
1465- --------------------------------------------------------------------
1466-
1467- `Highdicom ` provides the
1468- :meth: `highdicom.seg.Segmentation.get_pixels_by_source_instance() ` and
1469- :meth: `highdicom.seg.Segmentation.get_pixels_by_source_frame() ` methods to
1470- handle reconstruction of segmentation masks from SEG objects in which each
1471- frame in the SEG object is derived from one or more known source images or
1472- image frames, as described within the "Derivation Image Sequence" (see
1473- :ref: `derivation-sequence `). The only difference between the two methods is
1474- that the :meth: `highdicom.seg.Segmentation.get_pixels_by_source_instance() ` is
1475- used when the segmentation is derived from a source series consisting of
1476- multiple single-frame instances, while
1463+ Accessing Segmentation Masks By Source Frame or Source Instance
1464+ ---------------------------------------------------------------
1465+
1466+ `Highdicom ` provides various methods for accessing the pixels of a segmentation
1467+ image. The choice of method depends on how you would like the resulting array
1468+ to be arranged.
1469+
1470+ The first two methods are used to access frames of the segmentation according
1471+ to the frames/instances of the source image from which they are derived, as
1472+ described within the "Derivation Image Sequence" (see
1473+ :ref: `derivation-sequence `). The
1474+ :meth: `highdicom.seg.Segmentation.get_pixels_by_source_instance() ` is used when
1475+ the segmentation is derived from a source series consisting of multiple
1476+ single-frame instances, while
14771477:meth: `highdicom.seg.Segmentation.get_pixels_by_source_frame() ` is used when
14781478the segmentation is derived from a single multiframe source instance.
14791479
1480- When reconstructing a segmentation mask using
1480+ When accessing a segmentation mask using
14811481:meth: `highdicom.seg.Segmentation.get_pixels_by_source_instance() `, the user
14821482must provide a list of SOP Instance UIDs of the source images for which the
14831483segmentation mask should be constructed. Whatever order is chosen here will be
@@ -1524,7 +1524,7 @@ on GitHub.
15241524 assert pixels.shape == (2 , 16 , 16 , 1 )
15251525 assert np.unique(pixels).tolist() == [0 , 1 ]
15261526
1527- This second example demonstrates reconstructing segmentation masks from a
1527+ This second example demonstrates accessing segmentation masks from a
15281528segmentation derived from a multiframe image, in this case a whole slide
15291529microscopy image, and also demonstrates an example with multiple, in
15301530this case 20, segments:
@@ -1555,18 +1555,17 @@ this case 20, segments:
15551555 # Each segment is still binary
15561556 assert np.unique(pixels).tolist() == [0 , 1 ]
15571557
1558- Note that these two methods may only be used when the segmentation's metadata
1559- indicates that each segmentation frame is derived from exactly one source
1560- instance or frame of a source instance. If this is not the case, a
1561- ``RuntimeError `` is raised.
1558+ Note that these two methods may only be used when the provided frame numbers or
1559+ instance UIDs match exactly one segmentation frame per segment in the
1560+ segmentation metadata If this is not the case, a ``RuntimeError `` is raised.
15621561
15631562In the general case, the
15641563:meth: `highdicom.seg.Segmentation.get_pixels_by_dimension_index_values() ` method
15651564is available to query directly by the underlying dimension index values. We
15661565will not cover this advanced topic.
15671566
1568- Reconstructing Specific Segments
1569- --------------------------------
1567+ Accessing Specific Segments
1568+ ---------------------------
15701569
15711570A further optional parameter, ``segment_numbers ``, allows the user to request
15721571only a subset of the segments available within the SEG object by providing a
@@ -1603,8 +1602,8 @@ After this, the array ``pixels[:, :, :, 0]`` contains the pixels for segment
16031602number 10, ``pixels[:, :, :, 1] `` contains the pixels for segment number 9, and
16041603``pixels[:, :, :, 2] `` contains the pixels for segment number 8.
16051604
1606- Reconstructing Segmentation Masks as "Label Maps"
1607- -------------------------------------------------
1605+ Accessing Segmentation Masks as "Label Maps"
1606+ --------------------------------------------
16081607
16091608If the segments do not overlap, it is possible to combine the multiple segments
16101609into a simple "label map" style mask, as described above. This can be achieved
@@ -1696,11 +1695,11 @@ the ``relabel`` parameter.
16961695 # Now the output segments have been relabelled to 1, 2, 3
16971696 assert np.unique(pixels).tolist() == [0 , 1 , 2 , 3 ]
16981697
1699- Reconstructing Fractional Segmentations
1700- ---------------------------------------
1698+ Accessing Fractional Segmentations
1699+ ----------------------------------
17011700
17021701For ``"FRACTIONAL" `` SEG objects, `highdicom ` will rescale the pixel values in
1703- the segmentation masks from the integer values as which they are stored back
1702+ the segmentation masks from the integer values used to store them back
17041703down to the range `0.0 ` to `1.0 ` as floating point values by scaling by the
17051704"MaximumFractionalValue" attribute. If desired, this behavior can be disabled
17061705by specifying ``rescale_fractional=False ``, in which case the raw integer array
@@ -1730,8 +1729,8 @@ as stored in the SEG will be returned.
17301729 print (np.unique(pixels))
17311730 # [0. 0.2509804 0.5019608]
17321731
1733- Reconstructing Volumes
1734- ----------------------
1732+ Accessing Volumes
1733+ -----------------
17351734
17361735If the segmentation is defined on a regularly-sampled 3D grid (possibly with
17371736omittted frames, tiled frames, and/or multiple segments), the
@@ -1759,8 +1758,8 @@ are also available here.
17591758 # [ 0. 0. 0. 1. ]]
17601759
17611760
1762- Reconstructing Total Pixel Matrices from Tiled Segmentations
1763- ------------------------------------------------------------
1761+ Accessing Total Pixel Matrices from Tiled Segmentations
1762+ -------------------------------------------------------
17641763
17651764For segmentations of digital pathology images that are stored as tiled images,
17661765the :meth: `highdicom.seg.Segmentation.get_pixels_by_source_frame() ` method will
0 commit comments