diff --git a/docs/usage.rst b/docs/usage.rst index 8bd86bb5..73fe02d3 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -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, diff --git a/src/highdicom/seg/content.py b/src/highdicom/seg/content.py index ff4b7fe6..9617f151 100644 --- a/src/highdicom/seg/content.py +++ b/src/highdicom/seg/content.py @@ -77,7 +77,7 @@ def __init__( "Anatomic Region", :dcm:`CID 4031 ` "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) diff --git a/src/highdicom/seg/sop.py b/src/highdicom/seg/sop.py index 581ac851..4e9ce557 100644 --- a/src/highdicom/seg/sop.py +++ b/src/highdicom/seg/sop.py @@ -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, @@ -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)