Skip to content

Commit

Permalink
Minor fixes to segmentation (#195)
Browse files Browse the repository at this point in the history
* Minor fixes to segmentation

* Fix docstring typo in type
  • Loading branch information
CPBridge authored Aug 15, 2022
1 parent 366c58a commit ed5901f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Derive a Segmentation image from a multi-frame Slide Microscopy (SM) image:
)
# Create the Segmentation instance
seg_dataset = Segmentation(
seg_dataset = hd.seg.Segmentation(
source_images=[image_dataset],
pixel_array=mask,
segmentation_type=hd.seg.SegmentationTypeValues.BINARY,
Expand Down
2 changes: 1 addition & 1 deletion src/highdicom/seg/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(
"Anatomic Region", :dcm:`CID 4031 <part16/sect_CID_4031.html>`
"Common Anatomic Regions", as as well as other CIDs for
domain-specific anatomic regions)
primary_anatomic_structures: Union[Sequence[Union[highdicom.sr.Code, highdicom.sr.CodedConcept]], None], optional
primary_anatomic_structures: Union[Sequence[Union[pydicom.sr.coding.Code, highdicom.sr.CodedConcept]], None], optional
Anatomic structure(s) the segment represents
(see CIDs for domain-specific primary anatomic structures)
Expand Down
13 changes: 2 additions & 11 deletions src/highdicom/seg/sop.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ def __init__(

if pixel_array.ndim == 2:
pixel_array = pixel_array[np.newaxis, ...]
if pixel_array.ndim not in [3, 4]:
raise ValueError('Pixel array must be a 2D, 3D, or 4D array.')

super().__init__(
study_instance_uid=src_img.StudyInstanceUID,
Expand Down Expand Up @@ -568,17 +570,6 @@ def __init__(
self.NumberOfFrames = 0
self.PerFrameFunctionalGroupsSequence: List[Dataset] = []

if pixel_array.ndim == 2:
pixel_array = pixel_array[np.newaxis, ...]
if pixel_array.ndim not in [3, 4]:
raise ValueError('Pixel array must be a 2D, 3D, or 4D array.')

if pixel_array.shape[1:3] != (self.Rows, self.Columns):
raise ValueError(
'Pixel array representing segments has the wrong number of '
'rows and columns.'
)

# Check segment numbers
described_segment_numbers = np.array([
int(item.SegmentNumber)
Expand Down

0 comments on commit ed5901f

Please sign in to comment.